Skip to content

Commit f330c2b

Browse files
committed
CI: replace stdout=yaml with result_format=yaml for Ansible >= 6 tests
Ansible >= 12 (ansible-core >= 2.19) deprecates `stdout_callback=yaml`, superceded by `callback_result_format=yaml`. There is a change in behaviour: `callback_result_format` applies to output of both `ansible-playbook` _and_ `ansible`. Tests that run `ansible` in a subprocess are now explicitly configured to use json (even if they don't inspect that output yet) for more assert-able output across all versions of Ansible.
1 parent 8ddc181 commit f330c2b

File tree

9 files changed

+24
-2
lines changed

9 files changed

+24
-2
lines changed

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Running Ansible 12 + Mitogen will currently print a deprecation warning
3232
Ansible + Mitogen will still work for now. Mitogen is considering alternatives
3333
to strategy plugins under :gh:issue:`1278`.
3434

35+
* :gh:issue:`1285` CI: use `result_format = yaml` for Ansible test output,
36+
instead of deprecated `stdout_callback = yaml`
37+
3538

3639
v0.3.25a2 (2025-06-21)
3740
----------------------

tests/ansible/ansible.cfg

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[defaults]
22
any_errors_fatal = true
3+
# Ansible >= 6 (ansible-core >= 2.13)
4+
callback_result_format = yaml
35
# callbacks_enabled was added in Ansible 4 (ansible-core 2.11).
46
# profile_tasks: Displays timing for each task and summary table of top N tasks
57
# timer: Displays "Playbook run took 0 days, 0 hours, ..."
@@ -17,13 +19,13 @@ strategy_plugins = ../../ansible_mitogen/plugins/strategy
1719
inventory_plugins = lib/inventory
1820
action_plugins = lib/action
1921
callback_plugins = lib/callback
20-
stdout_callback = yaml
2122
vars_plugins = lib/vars
2223
library = lib/modules
2324
filter_plugins = lib/filters
2425
module_utils = lib/module_utils
2526
retry_files_enabled = False
26-
show_task_path_on_failure = true # Added in ansible-core 2.11
27+
# Ansible >= 4 (ansible-core >= 2.11)
28+
show_task_path_on_failure = true
2729
display_args_to_stdout = True
2830
forks = 100
2931

tests/ansible/integration/process/unix_socket_cleanup.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
vars:
1212
ansible_python_interpreter: "{{ ansible_playbook_python }}"
1313
shell: >-
14+
ANSIBLE_CALLBACK_RESULT_FORMAT=json
15+
ANSIBLE_LOAD_CALLBACK_PLUGINS=false
1416
ANSIBLE_STRATEGY=mitogen_linear
1517
ANSIBLE_SSH_ARGS="-o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa"
1618
ANSIBLE_VERBOSITY="{{ ansible_verbosity }}"

tests/ansible/integration/runner/missing_module.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
- name: Run missing_module
66
connection: local
77
environment:
8+
ANSIBLE_CALLBACK_RESULT_FORMAT: json
9+
ANSIBLE_LOAD_CALLBACK_PLUGINS: "false"
810
ANSIBLE_STRATEGY: "{{ lookup('env', 'ANSIBLE_STRATEGY') | mandatory }}"
911
ANSIBLE_VERBOSITY: "{{ ansible_verbosity }}"
1012
vars:

tests/ansible/integration/ssh/timeouts.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
- name: Cause Ansible connection timeout
1414
connection: local
1515
environment:
16+
ANSIBLE_CALLBACK_RESULT_FORMAT: json
17+
ANSIBLE_LOAD_CALLBACK_PLUGINS: "false"
1618
ANSIBLE_SSH_TIMEOUT: 10
1719
ANSIBLE_STRATEGY: "{{ lookup('env', 'ANSIBLE_STRATEGY') | mandatory }}"
1820
ANSIBLE_VERBOSITY: "{{ ansible_verbosity }}"

tests/ansible/integration/ssh/variables.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
- name: ansible_user, ansible_ssh_private_key_file
2020
shell: >
2121
ANSIBLE_ANY_ERRORS_FATAL=false
22+
ANSIBLE_CALLBACK_RESULT_FORMAT=json
23+
ANSIBLE_LOAD_CALLBACK_PLUGINS=false
2224
ANSIBLE_STRATEGY=mitogen_linear
2325
ANSIBLE_SSH_ARGS="-o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa"
2426
ANSIBLE_VERBOSITY="{{ ansible_verbosity }}"
@@ -37,6 +39,8 @@
3739
- name: ansible_user, wrong ansible_ssh_private_key_file
3840
shell: >
3941
ANSIBLE_ANY_ERRORS_FATAL=false
42+
ANSIBLE_CALLBACK_RESULT_FORMAT=json
43+
ANSIBLE_LOAD_CALLBACK_PLUGINS=false
4044
ANSIBLE_STRATEGY=mitogen_linear
4145
ANSIBLE_SSH_ARGS="-o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa"
4246
ANSIBLE_VERBOSITY="{{ ansible_verbosity }}"

tests/ansible/integration/stub_connections/setns_lxc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
- name: Run stub-lxc-info.py
1717
environment:
18+
ANSIBLE_CALLBACK_RESULT_FORMAT: json
19+
ANSIBLE_LOAD_CALLBACK_PLUGINS: "false"
1820
ANSIBLE_STRATEGY: "{{ lookup('env', 'ANSIBLE_STRATEGY') | mandatory }}"
1921
ANSIBLE_VERBOSITY: "{{ ansible_verbosity }}"
2022
command: |

tests/ansible/integration/stub_connections/setns_lxd.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
- name: Run ansible stub-lxc.py
1717
environment:
18+
ANSIBLE_CALLBACK_RESULT_FORMAT: json
19+
ANSIBLE_LOAD_CALLBACK_PLUGINS: "false"
1820
ANSIBLE_STRATEGY: "{{ lookup('env', 'ANSIBLE_STRATEGY') | mandatory }}"
1921
ANSIBLE_VERBOSITY: "{{ ansible_verbosity }}"
2022
command: |

tox.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ setenv =
112112
NOCOVERAGE_ERASE = 1
113113
NOCOVERAGE_REPORT = 1
114114
PIP_CONSTRAINT={toxinidir}/tests/constraints.txt
115+
# Superceded in Ansible >= 6 (ansible-core >= 2.13) by result_format=yaml
116+
# Deprecated in Ansible 12 (ansible-core 2.19)
117+
ansible{2.10,3-5}: DEFAULT_STDOUT_CALLBACK=yaml
115118
# Print warning on the first occurence at each module:linenno in Mitogen. Available Python 2.7, 3.2+.
116119
PYTHONWARNINGS=default:::ansible_mitogen,default:::mitogen
117120
# Ansible 6 - 8 (ansible-core 2.13 - 2.15) require Python 2.7 or >= 3.5 on targets

0 commit comments

Comments
 (0)