Created
June 30, 2016 21:16
-
-
Save lqueryvg/bd8772e1fb4e4b7d59742f807cef65cc to your computer and use it in GitHub Desktop.
ansible reboot machines
This file contains hidden or 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: 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