Last active
August 9, 2018 16:01
-
-
Save drmalex07/00167e3477e13e9b682c6e26285679e7 to your computer and use it in GitHub Desktop.
An example of rebooting all hosts and waiting in an Ansible playbook. #ansible #ansible-playbook #reboot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
vars: | |
tasks: | |
- name: Echo hostname | |
shell: echo {{ansible_host}} | |
- name: Reboot | |
shell: sleep 2 && reboot | |
sudo: yes | |
async: 30 | |
poll: 0 | |
ignore_errors: true | |
- name: Wait for play hosts to be up again | |
wait_for: | |
host: '{{hostvars[item].ansible_host}}' | |
port: 22 | |
state: started | |
delay: 10 | |
timeout: 45 | |
with_items: '{{play_hosts}}' | |
connection: local | |
- name: | |
shell: uptime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment