Fix reboot logic
This commit is contained in:
parent
db1210697d
commit
e238bd1a9f
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
20
roles/os_config/tasks/reboot.yml
Normal file
20
roles/os_config/tasks/reboot.yml
Normal 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
|
Reference in a new issue