Skip to content

Instantly share code, notes, and snippets.

@jenitehan
Created January 28, 2016 13:56
Show Gist options
  • Save jenitehan/44009656f803501ea2da to your computer and use it in GitHub Desktop.
Save jenitehan/44009656f803501ea2da to your computer and use it in GitHub Desktop.
Reboot server if required and wait for it to come back.
- name: Reboot system if required
command: shutdown -r now 'Rebooting to complete system upgrade' removes=/var/run/reboot-required
register: reboot_required
tags:
- apt
- updates
- name: Wait for server to come back.
local_action: wait_for port={{ ansible_ssh_port }} host="{{ ansible_ssh_host | default(inventory_hostname) }}" search_regex=OpenSSH delay=10
when: reboot_required.changed
sudo: false
tags:
- apt
- updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment