From 8b85b7339698bd9099bdb6915618a4ae153332b4 Mon Sep 17 00:00:00 2001 From: Sergei Bobkov Date: Sat, 21 Sep 2024 13:19:57 +0300 Subject: [PATCH] Added to os update playbook control reboot system --- README.md | 2 +- ansible/playbooks/os-linux-apt-update.yml | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c48032c..056d646 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # FAST-RABBIT collection tools and items for automation
-##This repo has Ansible, Packer by HashiCorp and etc auto tools for maintenance and service IT infrastructure.
+This repo has Ansible, Packer by HashiCorp and etc auto tools for maintenance and service IT infrastructure.

diff --git a/ansible/playbooks/os-linux-apt-update.yml b/ansible/playbooks/os-linux-apt-update.yml index 5b51c5c..0d3a3b9 100644 --- a/ansible/playbooks/os-linux-apt-update.yml +++ b/ansible/playbooks/os-linux-apt-update.yml @@ -5,14 +5,28 @@ gather_facts: true vars_files: - /root/.secret/.ansible/vars_creds.yml - tasks: - - name: Upgrage system type of Debian + - name: Upgrage system type of Debian using apt block: - name: Run "apt update" and "apt upgrade" ansible.builtin.apt: upgrade: yes update_cache: yes + - name: Check system for need to reboot after update (kernel) + stat: + path: /var/run/reboot-required + register: file_stat_result + - name: Reboot system if kernel updated and requested by the system + shell: sleep 5 && /sbin/shutdown -r now 'Rebooting system to update system /kernel as needed' + async: 300 + poll: 0 + ignore_errors: true + when: file_stat_result.stat.exists + - name: Wait for system to become reachable again + wait_for_connection: + delay: 20 + timeout: 300 + when: file_stat_result.stat.exists - name: Run "apt autoremove" ansible.builtin.apt: autoremove: yes