ansible-labs/090.Conditional/solution/solution.yml

23 lines
539 B
YAML
Raw Normal View History

2018-08-02 15:48:30 +02:00
- hosts: lab
gather_facts: true
tasks:
- name: Reboot the host if it is up for more than 600s
shell: nohup sh -c '(sleep 5 ; reboot)'
become: true
poll: 0
async: 1
ignore_errors: true
when: ansible_uptime_seconds > 600
notify:
- Wait for Reboot
- Rebooted msg
handlers:
- name: Wait for Reboot
wait_for_connection:
delay: 10
- name: Rebooted msg
debug:
msg: "Host {{ ansible_ssh_host }} has been rebooted"
# vim: set ft=yaml sw=2 et: