From f330c2b1588cf1e4afea74dd7e3cde96b308fe1f Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Mon, 23 Jun 2025 08:32:11 +0100 Subject: [PATCH] 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. --- docs/changelog.rst | 3 +++ tests/ansible/ansible.cfg | 6 ++++-- tests/ansible/integration/process/unix_socket_cleanup.yml | 2 ++ tests/ansible/integration/runner/missing_module.yml | 2 ++ tests/ansible/integration/ssh/timeouts.yml | 2 ++ tests/ansible/integration/ssh/variables.yml | 4 ++++ tests/ansible/integration/stub_connections/setns_lxc.yml | 2 ++ tests/ansible/integration/stub_connections/setns_lxd.yml | 2 ++ tox.ini | 3 +++ 9 files changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 78037347..224b40c4 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -32,6 +32,9 @@ Running Ansible 12 + Mitogen will currently print a deprecation warning Ansible + Mitogen will still work for now. Mitogen is considering alternatives to strategy plugins under :gh:issue:`1278`. +* :gh:issue:`1285` CI: use `result_format = yaml` for Ansible test output, + instead of deprecated `stdout_callback = yaml` + v0.3.25a2 (2025-06-21) ---------------------- diff --git a/tests/ansible/ansible.cfg b/tests/ansible/ansible.cfg index 48a4eec3..4060d9ea 100644 --- a/tests/ansible/ansible.cfg +++ b/tests/ansible/ansible.cfg @@ -1,5 +1,7 @@ [defaults] any_errors_fatal = true +# Ansible >= 6 (ansible-core >= 2.13) +callback_result_format = yaml # callbacks_enabled was added in Ansible 4 (ansible-core 2.11). # profile_tasks: Displays timing for each task and summary table of top N tasks # timer: Displays "Playbook run took 0 days, 0 hours, ..." @@ -17,13 +19,13 @@ strategy_plugins = ../../ansible_mitogen/plugins/strategy inventory_plugins = lib/inventory action_plugins = lib/action callback_plugins = lib/callback -stdout_callback = yaml vars_plugins = lib/vars library = lib/modules filter_plugins = lib/filters module_utils = lib/module_utils retry_files_enabled = False -show_task_path_on_failure = true # Added in ansible-core 2.11 +# Ansible >= 4 (ansible-core >= 2.11) +show_task_path_on_failure = true display_args_to_stdout = True forks = 100 diff --git a/tests/ansible/integration/process/unix_socket_cleanup.yml b/tests/ansible/integration/process/unix_socket_cleanup.yml index 21747494..4466aa2e 100644 --- a/tests/ansible/integration/process/unix_socket_cleanup.yml +++ b/tests/ansible/integration/process/unix_socket_cleanup.yml @@ -11,6 +11,8 @@ vars: ansible_python_interpreter: "{{ ansible_playbook_python }}" shell: >- + ANSIBLE_CALLBACK_RESULT_FORMAT=json + ANSIBLE_LOAD_CALLBACK_PLUGINS=false ANSIBLE_STRATEGY=mitogen_linear ANSIBLE_SSH_ARGS="-o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa" ANSIBLE_VERBOSITY="{{ ansible_verbosity }}" diff --git a/tests/ansible/integration/runner/missing_module.yml b/tests/ansible/integration/runner/missing_module.yml index b42e3af3..b641cbe3 100644 --- a/tests/ansible/integration/runner/missing_module.yml +++ b/tests/ansible/integration/runner/missing_module.yml @@ -5,6 +5,8 @@ - name: Run missing_module connection: local environment: + ANSIBLE_CALLBACK_RESULT_FORMAT: json + ANSIBLE_LOAD_CALLBACK_PLUGINS: "false" ANSIBLE_STRATEGY: "{{ lookup('env', 'ANSIBLE_STRATEGY') | mandatory }}" ANSIBLE_VERBOSITY: "{{ ansible_verbosity }}" vars: diff --git a/tests/ansible/integration/ssh/timeouts.yml b/tests/ansible/integration/ssh/timeouts.yml index 7ea905f5..0cb59422 100644 --- a/tests/ansible/integration/ssh/timeouts.yml +++ b/tests/ansible/integration/ssh/timeouts.yml @@ -13,6 +13,8 @@ - name: Cause Ansible connection timeout connection: local environment: + ANSIBLE_CALLBACK_RESULT_FORMAT: json + ANSIBLE_LOAD_CALLBACK_PLUGINS: "false" ANSIBLE_SSH_TIMEOUT: 10 ANSIBLE_STRATEGY: "{{ lookup('env', 'ANSIBLE_STRATEGY') | mandatory }}" ANSIBLE_VERBOSITY: "{{ ansible_verbosity }}" diff --git a/tests/ansible/integration/ssh/variables.yml b/tests/ansible/integration/ssh/variables.yml index bb4bd179..5eb54dde 100644 --- a/tests/ansible/integration/ssh/variables.yml +++ b/tests/ansible/integration/ssh/variables.yml @@ -19,6 +19,8 @@ - name: ansible_user, ansible_ssh_private_key_file shell: > ANSIBLE_ANY_ERRORS_FATAL=false + ANSIBLE_CALLBACK_RESULT_FORMAT=json + ANSIBLE_LOAD_CALLBACK_PLUGINS=false ANSIBLE_STRATEGY=mitogen_linear ANSIBLE_SSH_ARGS="-o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa" ANSIBLE_VERBOSITY="{{ ansible_verbosity }}" @@ -37,6 +39,8 @@ - name: ansible_user, wrong ansible_ssh_private_key_file shell: > ANSIBLE_ANY_ERRORS_FATAL=false + ANSIBLE_CALLBACK_RESULT_FORMAT=json + ANSIBLE_LOAD_CALLBACK_PLUGINS=false ANSIBLE_STRATEGY=mitogen_linear ANSIBLE_SSH_ARGS="-o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa" ANSIBLE_VERBOSITY="{{ ansible_verbosity }}" diff --git a/tests/ansible/integration/stub_connections/setns_lxc.yml b/tests/ansible/integration/stub_connections/setns_lxc.yml index 584a6806..f7654ad8 100644 --- a/tests/ansible/integration/stub_connections/setns_lxc.yml +++ b/tests/ansible/integration/stub_connections/setns_lxc.yml @@ -15,6 +15,8 @@ - name: Run stub-lxc-info.py environment: + ANSIBLE_CALLBACK_RESULT_FORMAT: json + ANSIBLE_LOAD_CALLBACK_PLUGINS: "false" ANSIBLE_STRATEGY: "{{ lookup('env', 'ANSIBLE_STRATEGY') | mandatory }}" ANSIBLE_VERBOSITY: "{{ ansible_verbosity }}" command: | diff --git a/tests/ansible/integration/stub_connections/setns_lxd.yml b/tests/ansible/integration/stub_connections/setns_lxd.yml index 2e07aca3..c461845e 100644 --- a/tests/ansible/integration/stub_connections/setns_lxd.yml +++ b/tests/ansible/integration/stub_connections/setns_lxd.yml @@ -15,6 +15,8 @@ - name: Run ansible stub-lxc.py environment: + ANSIBLE_CALLBACK_RESULT_FORMAT: json + ANSIBLE_LOAD_CALLBACK_PLUGINS: "false" ANSIBLE_STRATEGY: "{{ lookup('env', 'ANSIBLE_STRATEGY') | mandatory }}" ANSIBLE_VERBOSITY: "{{ ansible_verbosity }}" command: | diff --git a/tox.ini b/tox.ini index 9f3be10f..3cad99c0 100644 --- a/tox.ini +++ b/tox.ini @@ -112,6 +112,9 @@ setenv = NOCOVERAGE_ERASE = 1 NOCOVERAGE_REPORT = 1 PIP_CONSTRAINT={toxinidir}/tests/constraints.txt + # Superceded in Ansible >= 6 (ansible-core >= 2.13) by result_format=yaml + # Deprecated in Ansible 12 (ansible-core 2.19) + ansible{2.10,3-5}: DEFAULT_STDOUT_CALLBACK=yaml # Print warning on the first occurence at each module:linenno in Mitogen. Available Python 2.7, 3.2+. PYTHONWARNINGS=default:::ansible_mitogen,default:::mitogen # Ansible 6 - 8 (ansible-core 2.13 - 2.15) require Python 2.7 or >= 3.5 on targets