Had some questions at work about what handlers could do. So we built this playbook to test.
- handlers can be called "dynamicly" ie called with variable name.
- handlers can iterate over a list.
Had some questions at work about what handlers could do. So we built this playbook to test.
| --- | |
| - name: hahah | |
| hosts: all | |
| connection: local | |
| become: true | |
| become_method: sudo | |
| vars: | |
| foo: | |
| - foo | |
| - bar | |
| - baz | |
| handlers: | |
| - name: run foo | |
| debug: msg="running foo" | |
| - name: run bar | |
| debug: msg="running bar" | |
| - name: run baz | |
| debug: msg="running baz with {{ item }}" | |
| with_items: "{{ foo }}" | |
| tasks: | |
| - command: touch /tmp/{{ item }} warn=false | |
| notify: | |
| - run {{ item }} | |
| with_items: "{{ foo }}" |