36 lines
950 B
YAML
36 lines
950 B
YAML
# vim: ft=yaml.ansible
|
|
---
|
|
- name: Check if a reboot is needed
|
|
ansible.builtin.stat:
|
|
path: /var/run/reboot-required
|
|
register: needs_reboot
|
|
|
|
- name: Include docker_services role for service shutdown
|
|
ansible.builtin.include_role:
|
|
name: docker_services
|
|
tasks_from: services.yml
|
|
apply:
|
|
ignore_errors: true
|
|
vars:
|
|
stop: true
|
|
when: needs_reboot.stat.exists or
|
|
(force_reboot is defined and force_reboot)
|
|
|
|
- name: Reboot host
|
|
ansible.builtin.reboot:
|
|
when: needs_reboot.stat.exists or
|
|
(force_reboot is defined and force_reboot)
|
|
register: rebooted
|
|
|
|
- name: End play if reboot is not needed
|
|
ansible.builtin.meta: end_play
|
|
when: reboot is defined and reboot and
|
|
(rebooted.rebooted is undefined or not rebooted.rebooted)
|
|
|
|
- name: Re-gather facts
|
|
ansible.builtin.setup:
|
|
filter:
|
|
- ansible_mounts
|
|
- ansible_swaptotal_mb
|
|
when: rebooted.rebooted is defined and rebooted.rebooted
|