Skip to content

Instantly share code, notes, and snippets.

@lqueryvg
Created June 30, 2016 21:16
Show Gist options
  • Save lqueryvg/bd8772e1fb4e4b7d59742f807cef65cc to your computer and use it in GitHub Desktop.
Save lqueryvg/bd8772e1fb4e4b7d59742f807cef65cc to your computer and use it in GitHub Desktop.
ansible reboot machines
---
- hosts: h1 h2 h3
gather_facts: False
become: True
tasks:
- name: sending shutdown -r now to hosts
shell: sleep 2; shutdown -r now "Ansible triggering reboot..."
async: 1
poll: 0
ignore_errors: yes
- name: waiting for hosts to come back
local_action:
module: wait_for
host={{ inventory_hostname }}
port=22
delay=2
timeout=300
become: false
- command: uptime
register: result
- debug: msg={{ result.stdout_lines }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment