Last active
August 29, 2015 14:05
-
-
Save darKoram/0a38cce21a607dacb338 to your computer and use it in GitHub Desktop.
test ansible force_handlers
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
I'd like to force handlers to run even if a host fails on a task. Sort of like a tearDown() in a test harness. |
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
# force_handlers/handlers/main.yml | |
- name: Run handler | |
shell: echo "running handler" |
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
(master)] ansible-playbook -i hosts force_handlers.yml --force-handlers | |
PLAY [all] ******************************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [localhost] | |
TASK: [force_handlers | Step1. notify on this step] ************************** | |
changed: [localhost] | |
TASK: [force_handlers | Fail by force] **************************************** | |
skipping: [localhost] | |
TASK: [force_handlers | Next step] ******************************************** | |
changed: [localhost] | |
NOTIFIED: [force_handlers | Run handler] ************************************** | |
changed: [localhost] | |
PLAY RECAP ******************************************************************** | |
localhost : ok=4 changed=3 unreachable=0 failed=0 |
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
# force_handlers/tasks/main.yml | |
- name: Step1. notify on this step | |
shell: echo "Step1" | |
notify: Run handler | |
- name: Fail by force | |
fail: msg="failing" | |
- name: Next step | |
shell: echo "next step" |
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
[kbroughton@mb-kbroughton:git/test_ansible + | |
(master)] ansible-playbook -i hosts force_handlers.yml --force-handlers -e "cli_arg=yes" | |
PLAY [all] ******************************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [localhost] | |
TASK: [force_handlers | Step1. notify on this step] ************************** | |
changed: [localhost] | |
TASK: [force_handlers | Fail by force] **************************************** | |
failed: [localhost] => {"failed": true} | |
msg: failing | |
NOTIFIED: [force_handlers | Run handler] ************************************** | |
FATAL: no hosts matched or all hosts have already failed -- aborting | |
PLAY RECAP ******************************************************************** | |
to retry, use: --limit @/Users/kbroughton/force_handlers.retry | |
localhost : ok=2 changed=1 unreachable=0 failed=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment