Fix reboot logic

This commit is contained in:
Sam A. 2022-12-26 01:39:55 +01:00
parent db1210697d
commit e238bd1a9f
Signed by: samsapti
GPG Key ID: CBBBE7371E81C4EA
3 changed files with 25 additions and 23 deletions

View File

@ -28,29 +28,6 @@
- ufw
- unattended-upgrades
- name: Check if a reboot is needed
stat:
path: /var/run/reboot-required
register: needs_reboot
tags:
- reboot
- name: Reboot host
reboot:
connect_timeout: 120
when: needs_reboot.stat.exists or
(force_reboot is defined and force_reboot)
register: reboot
tags:
- reboot
- name: Re-gather facts
setup:
filter:
- ansible_mounts
- ansible_swaptotal_mb
when: not reboot.skipped and reboot.rebooted
- name: Clone apt-update-push
git:
dest: "/home/{{ ansible_user }}/apt-update-push"

View File

@ -3,6 +3,11 @@
- name: Configure system base
import_tasks: base.yml
- name: Reboot if needed
import_tasks: reboot.yml
tags:
- reboot
- name: Configure firewall
import_tasks: firewall.yml

View File

@ -0,0 +1,20 @@
# vim: ft=yaml.ansible
---
- name: Check if a reboot is needed
stat:
path: /var/run/reboot-required
register: needs_reboot
- name: Reboot host
reboot:
connect_timeout: 120
when: needs_reboot.stat.exists or
(force_reboot is defined and force_reboot)
register: reboot
- name: Re-gather facts
setup:
filter:
- ansible_mounts
- ansible_swaptotal_mb
when: reboot.rebooted is defined and reboot.rebooted