Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 703 Bytes

2016-03-10-reboot_on_system_upgrade.md

File metadata and controls

25 lines (19 loc) · 703 Bytes

Reboot on system upgrade

Category: ansible Generated on 2016-03-10

source: https://coderwall.com/p/0nckqg/ansible-reboot-ubuntu-if-needed source: http://elnur.pro/rebooting-servers-one-by-one-with-ansible/

Reboot your ansible inventory one host by one if needed by system upgrade.

This is valid for Ubuntu.

Ansible playbook:

---
- hosts: all # all hosts
  serial: 1  # one by one
  sudo: yes  # shutdown requires sudo
  tasks:
    - name: Reboot system if required
      command: shutdown -r now 'Rebooting to complete system upgrade' removes=/var/run/reboot-required
    - name: Wait for the server to reboot
      local_action: wait_for host={{inventory_hostname}} port=22