diff --git a/roles/os_config/tasks/base.yml b/roles/os_config/tasks/base.yml index 0289fb1..83b39b8 100644 --- a/roles/os_config/tasks/base.yml +++ b/roles/os_config/tasks/base.yml @@ -27,3 +27,18 @@ - python3-pip - 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) + tags: + - reboot diff --git a/roles/os_config/tasks/main.yml b/roles/os_config/tasks/main.yml index bcfcda4..260f21d 100644 --- a/roles/os_config/tasks/main.yml +++ b/roles/os_config/tasks/main.yml @@ -12,11 +12,6 @@ - name: Configure SSH import_tasks: ssh.yml -- name: Reboot if needed - import_tasks: reboot.yml - tags: - - reboot - - name: Configure disks import_tasks: disks.yml tags: diff --git a/roles/os_config/tasks/reboot.yml b/roles/os_config/tasks/reboot.yml deleted file mode 100644 index c9fdf39..0000000 --- a/roles/os_config/tasks/reboot.yml +++ /dev/null @@ -1,12 +0,0 @@ -# vim: ft=yaml.ansible ---- -- name: Check if reboot is needed - stat: - path: /var/run/reboot-required - register: needs_reboot - -- name: Reboot host - reboot: - connect_timeout: 60 - when: needs_reboot.stat.exists or - (force_reboot is defined and force_reboot)