---
- name: Do something that requires a reboot when it results in a change.
...
register: task_result
- name: Reboot immediately if there was a change.
shell: "sleep 5 && reboot"
async: 1
poll: 0
when: task_result is changed
- name: Wait for the reboot to complete if there was a change.
wait_for_connection:
connect_timeout: 20
sleep: 5
delay: 5
timeout: 300
when: task_result is changed
...
Reference – https://blog.confirm.ch/calling-ansible-handlers-based-on-os-distributions/
Ansible Fundamental tutorial by Manish in 2020
Ansible Advance Tutorial for Beginners with Demo 2020 — By DevOpsSchool
Ansible with network module (Part 01) — By DevOpsSchool
Ansible with network module (Part 02) — By DevOpsSchool
Ansible with network module (Part 03) — By DevOpsSchool
Ansible with network module (Part 04) — By DevOpsSchool
Ansible with network module (Part 05) — By DevOpsSchool
Ansible with network module (Part 06) — By DevOpsSchool
Ansible with network module (Part 07) — By DevOpsSchool
Ansible with network module (Part 08) — By DevOpsSchool
Ansible with network module (Part 09) — By DevOpsSchool
Ansible with network module (Part 10) — By DevOpsSchool
Ansible with network module (Part 11) — By DevOpsSchool
Ansible with network module (Part 12) — By DevOpsSchool
Ansible with network module (Part 13) — By DevOpsSchool
Latest posts by Rajesh Kumar (see all)
- Best AI tools for Software Engineers - November 4, 2024
- Installing Jupyter: Get up and running on your computer - November 2, 2024
- An Introduction of SymOps by SymOps.com - October 30, 2024