Last active
November 29, 2017 22:45
-
-
Save jmehnle/6027e04fd7495fcc9e6b3ff104953dce to your computer and use it in GitHub Desktop.
Ansible handler not role-scoped
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ansible-playbook -i localhost, -v playbook.yml | |
No config file found; using defaults | |
PLAY [all] ********************************************************************* | |
TASK [setup] ******************************************************************* | |
ok: [localhost] | |
TASK [a : set_fact] ************************************************************ | |
ok: [localhost] => {"ansible_facts": {"x": "foo"}, "changed": false} | |
TASK [a : debug] *************************************************************** | |
ok: [localhost] => { | |
"msg": "a task here!" | |
} | |
TASK [b : set_fact] ************************************************************ | |
ok: [localhost] => {"ansible_facts": {"x": "bar"}, "changed": false} | |
TASK [b : debug] *************************************************************** | |
ok: [localhost] => { | |
"msg": "b task here!" | |
} | |
RUNNING HANDLER [a : dummy] **************************************************** | |
ok: [localhost] => { | |
"msg": "a handler here! x=bar" | |
} | |
RUNNING HANDLER [b : dummy] **************************************************** | |
ok: [localhost] => { | |
"msg": "b handler here! x=bar" | |
} | |
PLAY RECAP ********************************************************************* | |
localhost : ok=7 changed=2 unreachable=0 failed=0 | |
$ tree | |
. | |
├── playbook.yml | |
└── roles | |
├── a | |
│ ├── handlers | |
│ │ └── main.yml | |
│ └── tasks | |
│ └── main.yml | |
└── b | |
├── handlers | |
│ └── main.yml | |
└── tasks | |
└── main.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: all | |
roles: | |
- a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: dummy | |
listen: handler | |
debug: msg="a handler here! x={{x}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- set_fact: x=foo | |
- debug: msg="a task here!" | |
changed_when: true | |
notify: handler | |
- include_role: name=b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: dummy | |
listen: handler | |
debug: msg="b handler here! x={{x}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- set_fact: x=bar | |
- debug: msg="b task here!" | |
changed_when: true | |
notify: handler |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment