This repository has been archived on 2023-12-29. You can view files and clone it, but cannot push or open issues or pull requests.
pi-ansible/roles/os_config/tasks/reboot.yml

31 lines
756 B
YAML
Raw Normal View History

2022-12-26 00:39:55 +00:00
# vim: ft=yaml.ansible
---
- name: Check if a reboot is needed
2023-03-22 18:31:21 +00:00
ansible.builtin.stat:
2022-12-26 00:39:55 +00:00
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:
2023-08-05 12:36:12 +00:00
down: true
when: needs_reboot.stat.exists or
2023-08-05 12:18:35 +00:00
(do_reboot is defined and do_reboot)
2022-12-26 00:39:55 +00:00
- name: Reboot host
2023-03-22 18:31:21 +00:00
ansible.builtin.reboot:
2022-12-26 00:39:55 +00:00
when: needs_reboot.stat.exists or
2023-08-05 12:18:35 +00:00
(do_reboot is defined and do_reboot)
register: rebooted
2022-12-26 00:39:55 +00:00
- name: Re-gather facts
2023-03-22 18:31:21 +00:00
ansible.builtin.setup:
2022-12-26 00:39:55 +00:00
filter:
- ansible_mounts
- ansible_swaptotal_mb
when: rebooted.rebooted is defined and rebooted.rebooted