summaryrefslogtreecommitdiffstats
path: root/examples/playbooks/no_handler_pass.yml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:06:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:06:49 +0000
commit2fe34b6444502079dc0b84365ce82dbc92de308e (patch)
tree8fedcab52bbbc3db6c5aa909a88a7a7b81685018 /examples/playbooks/no_handler_pass.yml
parentInitial commit. (diff)
downloadansible-lint-2fe34b6444502079dc0b84365ce82dbc92de308e.tar.xz
ansible-lint-2fe34b6444502079dc0b84365ce82dbc92de308e.zip
Adding upstream version 6.17.2.upstream/6.17.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'examples/playbooks/no_handler_pass.yml')
-rw-r--r--examples/playbooks/no_handler_pass.yml84
1 files changed, 84 insertions, 0 deletions
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