From 2aad837ab471e97d20463b7c7e9c924a415b42d8 Mon Sep 17 00:00:00 2001 From: Sam Al-Sapti Date: Sun, 25 Dec 2022 23:51:17 +0100 Subject: [PATCH] Move rebooting into base.yml and increase connect_timeout --- roles/os_config/tasks/base.yml | 15 +++++++++++++++ roles/os_config/tasks/main.yml | 5 ----- roles/os_config/tasks/reboot.yml | 12 ------------ 3 files changed, 15 insertions(+), 17 deletions(-) delete mode 100644 roles/os_config/tasks/reboot.yml 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)