From 018f4c989da828bd22b0aa18eb3cb258299efe7c Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 2 Aug 2025 18:02:57 +0200 Subject: [PATCH] [stable-9] diy callback: add test for on_any_msg (#10550) (#10554) diy callback: add test for on_any_msg (#10550) Add test for on_any_msg. (cherry picked from commit ac4aca200489fc25b58e83bf82e10169fe855603) --- .../targets/callback_diy/tasks/main.yml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/integration/targets/callback_diy/tasks/main.yml b/tests/integration/targets/callback_diy/tasks/main.yml index fa468b52ba..d1a3af1940 100644 --- a/tests/integration/targets/callback_diy/tasks/main.yml +++ b/tests/integration/targets/callback_diy/tasks/main.yml @@ -460,3 +460,63 @@ "PLAY RECAP *********************************************************************", "testhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 " ] + + - name: Set on_any_msg + environment: + ANSIBLE_NOCOLOR: 'true' + ANSIBLE_FORCE_COLOR: 'false' + ANSIBLE_STDOUT_CALLBACK: community.general.diy + ANSIBLE_CALLBACK_DIY_ON_ANY_MSG: foo + playbook: !unsafe | + - hosts: testhost + gather_facts: false + tasks: + - name: A loop + debug: + msg: "{{ item }}" + loop: + - 1 + - 2 + - name: Sample task name + debug: + msg: sample debug msg + - name: Skipped task + command: ls / + when: false + expected_output: + - "foo" + - "" + - "PLAY [testhost] ****************************************************************" + - "foo" + - "" + - "TASK [A loop] ******************************************************************" + - "foo" + - "foo" + - "ok: [testhost] => (item=1) => {" + - " \"msg\": 1" + - "}" + - "foo" + - "ok: [testhost] => (item=2) => {" + - " \"msg\": 2" + - "}" + - "foo" + - "foo" + - "" + - "TASK [Sample task name] ********************************************************" + - "foo" + - "foo" + - "ok: [testhost] => {" + - " \"msg\": \"sample debug msg\"" + - "}" + - "foo" + - "" + - "TASK [Skipped task] ************************************************************" + - "foo" + - "foo" + - "skipping: [testhost]" + - "foo" + - "" + - "PLAY RECAP *********************************************************************" + - "testhost : ok=2 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0 " + - "" + - "foo"