On 27. mai 2016 21:28, Francisco Lopes wrote:
I see. I guess a found a good default for my case, which would be:
- name: reboot system if required
shell: removes=/var/run/reboot-required sleep 2 && shutdown -r now
async: 1
poll: 0
ignore_errors: true
- name: wait for server to come back
local_action: wait_for host={{ inventory_hostname }} state=started
delay=5 timeout=30
So right now it correctly waits for the server to come back.
Is it possible to add a condition on the wait task in order to skip it if a
reboot was not required?
Not tested but this should work
- stat: /var/run/reboot-required
register: result_reboot
- name: reboot system if required
shell: sleep 2 && shutdown -r now
async: 1
poll: 0
ignore_errors: true
when: result_reboot.stat.exists == True
- name: wait for server to come back
local_action: wait_for host={{ inventory_hostname }} state=started
delay=5 timeout=30
when: result_reboot.stat.exists == True
--
Kai Stian Olstad
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/3658b971-0c8e-a0f5-8aa7-2edbcc2aeab7%40olstad.com.
For more options, visit https://groups.google.com/d/optout.