forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix --force-handlers, and allow it in plays and ansible.cfg
The --force-handlers command line argument was not correctly running handlers on hosts which had tasks that later failed. This corrects that, and also allows you to specify force_handlers in ansible.cfg or in a play.
- Loading branch information
Showing
11 changed files
with
123 additions
and
12 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- name: echoing handler | ||
command: echo CALLED_HANDLER_{{ inventory_hostname }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
|
||
# We notify for A and B, and hosts B and C fail. | ||
# When forcing, we expect A and B to run handlers | ||
# When not forcing, we expect only B to run handlers | ||
|
||
- name: notify the handler for host A and B | ||
shell: echo | ||
notify: | ||
- echoing handler | ||
when: inventory_hostname == 'A' or inventory_hostname == 'B' | ||
|
||
- name: fail task for all | ||
fail: msg="Fail All" | ||
when: fail_all is defined and fail_all | ||
|
||
- name: fail task for A | ||
fail: msg="Fail A" | ||
when: inventory_hostname == 'A' | ||
|
||
- name: fail task for C | ||
fail: msg="Fail C" | ||
when: inventory_hostname == 'C' | ||
|
||
- name: echo after A and C have failed | ||
command: echo CALLED_TASK_{{ inventory_hostname }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
|
||
- name: test force handlers (default) | ||
tags: normal | ||
hosts: testgroup | ||
gather_facts: False | ||
connection: local | ||
roles: | ||
- { role: test_force_handlers } | ||
|
||
- name: test force handlers (set to true) | ||
tags: force_true_in_play | ||
hosts: testgroup | ||
gather_facts: False | ||
connection: local | ||
force_handlers: True | ||
roles: | ||
- { role: test_force_handlers } | ||
|
||
|
||
- name: test force handlers (set to false) | ||
tags: force_false_in_play | ||
hosts: testgroup | ||
gather_facts: False | ||
connection: local | ||
force_handlers: False | ||
roles: | ||
- { role: test_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