Skip to content

Instantly share code, notes, and snippets.

@drmalex07
Last active August 9, 2018 16:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save drmalex07/00167e3477e13e9b682c6e26285679e7 to your computer and use it in GitHub Desktop.
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
---
- 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