Last active
June 20, 2016 22:05
-
-
Save dekimsey/d1f6630df899797256cb989610b4c0a3 to your computer and use it in GitHub Desktop.
Demonstrate Ansible not completing all Plays when failures are found
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: Play 0 (all is good) | |
hosts: all | |
become: false | |
connection: local | |
gather_facts: no | |
tasks: | |
- name: Task 1 -- Runs OK | |
command: date | |
- name: Play 1 (all, creates some failures) | |
hosts: all | |
become: false | |
connection: local | |
gather_facts: no | |
tasks: | |
- name: Task 1 -- Creates Failure OK | |
command: date | |
failed_when: "'host2' in inventory_hostname" | |
- name: Play 2 (group with only failures) | |
hosts: | |
- group-with-only-failures | |
become: false | |
connection: local | |
gather_facts: no | |
tasks: | |
- name: Task 2 | |
command: date | |
- name: Play 3 (all, NEVER GETS RUN) | |
hosts: | |
- all | |
become: false | |
connection: local | |
gather_facts: no | |
tasks: | |
- name: Task 3 | |
command: date |
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
[group-with-some-failures] | |
host2 | |
host1 | |
[group-with-only-failures] | |
host2 | |
[group-with-only-success] | |
host1 |
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: Play 0 (all is good) | |
hosts: all | |
become: false | |
connection: local | |
gather_facts: no | |
tasks: | |
- name: Task 1 -- Runs OK | |
command: date | |
- name: Play 1 (all, creates some failures) | |
hosts: all | |
become: false | |
connection: local | |
gather_facts: no | |
tasks: | |
- name: Task 1 -- Creates Failure OK | |
command: date | |
failed_when: "'host2' in inventory_hostname" | |
- name: Play 2 (all, spams NO HOSTS LEFT) | |
hosts: | |
- all | |
become: false | |
connection: local | |
gather_facts: no | |
tasks: | |
- command: date | |
- name: Play 3a (group with only failures) | |
hosts: | |
- group-with-only-failures | |
become: false | |
connection: local | |
gather_facts: no | |
tasks: | |
- name: Task 3 | |
command: date | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Play 4 will not execute. In Ansible v1.X, the play would execute.
Verify with: