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 - ufw
- unattended-upgrades - 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 - name: Clone apt-update-push
git: git:
dest: "/home/{{ ansible_user }}/apt-update-push" dest: "/home/{{ ansible_user }}/apt-update-push"

View file

@ -3,6 +3,11 @@
- name: Configure system base - name: Configure system base
import_tasks: base.yml import_tasks: base.yml
- name: Reboot if needed
import_tasks: reboot.yml
tags:
- reboot
- name: Configure firewall - name: Configure firewall
import_tasks: firewall.yml 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