From 2fe34b6444502079dc0b84365ce82dbc92de308e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 14:06:49 +0200 Subject: Adding upstream version 6.17.2. Signed-off-by: Daniel Baumann --- examples/playbooks/no_handler_pass.yml | 84 ++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 examples/playbooks/no_handler_pass.yml (limited to 'examples/playbooks/no_handler_pass.yml') diff --git a/examples/playbooks/no_handler_pass.yml b/examples/playbooks/no_handler_pass.yml new file mode 100644 index 0000000..5c44891 --- /dev/null +++ b/examples/playbooks/no_handler_pass.yml @@ -0,0 +1,84 @@ +--- +- name: Fixture for no-handler-pass + hosts: all + tasks: + - name: Execute something + ansible.builtin.command: echo 123 + register: result + changed_when: true + + - name: Print helpful error message + ansible.builtin.debug: + var: result + when: result.failed + + - name: Do something when hello is output + ansible.builtin.debug: + msg: why isn't this a handler + when: result.stdout == "hello" + + - name: Never actually debug + ansible.builtin.debug: + var: result + when: false + + - name: "Don't execute this step" + ansible.builtin.debug: + msg: "debug message" + when: + - false + + - name: Check when with a list + ansible.builtin.debug: + var: result + when: + - conditionA + - conditionB + + - name: Check when with a list of size 1 + ansible.builtin.debug: + var: result + when: + - conditionA + + - name: Registering task 1 + ansible.builtin.command: echo Hello + register: r1 + changed_when: true + + - name: Registering task 2 + ansible.builtin.command: echo Hello + register: r2 + changed_when: true + + - name: Use when task # noqa: no-changed-when + ansible.builtin.command: echo Hello + when: r1.changed and r2.changed + + - name: Use when with or # noqa: no-changed-when + ansible.builtin.command: echo Hello + when: r1.changed or conditionA + + - name: Use when with list of conditions # noqa: no-changed-when + ansible.builtin.command: echo Hello + when: + - r1.changed + - conditionA + + - name: Registering task + ansible.builtin.command: echo Hello + register: r + changed_when: true + + - name: When task not changed # noqa: no-changed-when + ansible.builtin.command: echo Not changed + when: not r.changed + + - name: Execute command # noqa: no-changed-when + ansible.builtin.command: echo hello + register: result + + - name: This should be a handler 2 + ansible.builtin.debug: + msg: why isn't this a handler + when: result | changed -- cgit v1.2.3