Getting started

Default configuration

The role will check if a host requires a reboot - this is usually indicated by the presence of the /var/run/reboot-required file. If it's found, the role will perform a reboot and will wait for the host to come back. Otherwise, nothing will happen.

The reboot can be forced using the reboot__force boolean variable, either via inventory or using the --extra-vars ansible-playbook parameter, for example:

debops run reboot -l <host> -e 'reboot__force=true'

If the display_skipped_hosts option is set to False in the ansible.cfg configuration file, the task which performs the reboot will not show up in the ansible-playbook output immediately, which might appear as Ansible "hanging" while waiting for the host to come back. This is an expected behaviour.

Example inventory

The playbook will work only on hosts that are in the main DebOps host group in the Ansible inventory:

[debops_all_hosts]
hostname1
hostname2

Example playbook

If you are using this role without DebOps, here's an example Ansible playbook that uses the debops.reboot role:

---
# SPDX-License-Identifier: GPL-3.0-only
#
# This playbook will reboot all DebOps hosts (use with caution)
# if required, or if forced.

- name: Reboot DebOps hosts
  hosts: [ 'debops_all_hosts' ]
  become: True

  gather_facts: False

  environment: '{{ inventory__environment | d({})
                   | combine(inventory__group_environment | d({}))
                   | combine(inventory__host_environment  | d({})) }}'

  roles:

    - role: reboot
      tags: [ 'role::reboot', 'skip::reboot' ]