---
# This ansible-playbook reboots productive
# servers
#
# What it does:
#   stop all services in need of manual stop
#   then reboot
#   then start all services in need of manual action.
#
# It will normally be run with ``ask-pass``
#
# Sample:
#
#   $ ansible-playbook -i hosts -K -l h5.waeup.org playbook-reboot.yml
#

- include: playbook-prep-reboot.yml

- hosts: nonvirtual
  become: yes
  become_user: root
  tasks:
  - name: Restart machine
    shell: sleep 2 && /sbin/shutdown -r now "Ansible triggered reboot"
    async: 1
    poll: 0
    ignore_errors: true

  - name: Wait for server to come back
    become: no
    local_action: wait_for
                  host={{ inventory_hostname }}
                  port=22
                  state=started
                  delay=30
                  timeout=300
                  connect_timeout=5

- include: playbook-post-reboot.yml
