Skip to content

Instantly share code, notes, and snippets.

@dekimsey
Last active June 20, 2016 22:05
Show Gist options
  • Save dekimsey/d1f6630df899797256cb989610b4c0a3 to your computer and use it in GitHub Desktop.
Save dekimsey/d1f6630df899797256cb989610b4c0a3 to your computer and use it in GitHub Desktop.
Demonstrate Ansible not completing all Plays when failures are found
---
- 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
[group-with-some-failures]
host2
host1
[group-with-only-failures]
host2
[group-with-only-success]
host1
---
- 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
@dekimsey
Copy link
Author

Play 4 will not execute. In Ansible v1.X, the play would execute.

Verify with:

ansible-playbook -i ansible-14665.hosts ansible-14665.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment