Hi, 

I have a playbook containing several Plays and each Play is executed on a 
bunch of hosts. 

I would like to quit the whole playbook (not only the current play) for a 
particular host if a  "when: condition" is met. 

Example Playbook with 2 Plays: 

- name: Play for patching precheck and download updates
  hosts: patchgroup
  remote_user: ansible
  gather_facts: true
  become: true
  timeout: 300
  roles:
    - patching_precheck_download

- name: Play for setting Icinga downtime
  hosts: patchgroup
  remote_user: ansible
  gather_facts: true
  roles:
    - role: icinga_downtime
      vars: 
        host_and_services: true

In the role patching_precheck_download there is the following task

- block:
    - name: Red Hat | Quit playbook when no updates are found
      fail:
        msg: "Quit playbook for the current host since no updates are 
found."
    #- meta: end_host

  when: updates.stdout_lines | length == 0

If the when condition is met, I currently use "fail" which will end for the 
particular host, both the current play and the playbook. This is intended, 
but it will throw an error which should not be the case. 

The other alternative I found is "meta: end_host" this will not throw an 
error and end the play for the current host, but not for the whole Playbook 
(2nd Play will still be executed for this particular host). So, this is no 
solution. 

Any ideas how to quit a Play and Playbook without throwing an error ?

Many thanks
Rainer

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2ef74ff7-f9d3-4366-990d-b8a2c67b84ean%40googlegroups.com.

Reply via email to