From 4ceffa9453e462dc44850d570bdd60429bbfa9b3 Mon Sep 17 00:00:00 2001 From: rpwolff Date: Mon, 12 Jun 2023 19:20:10 +0200 Subject: [PATCH] =?UTF-8?q?=E2=80=9Eupdate.yml=E2=80=9C=20hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- update.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 update.yml diff --git a/update.yml b/update.yml new file mode 100644 index 0000000..ed877de --- /dev/null +++ b/update.yml @@ -0,0 +1,23 @@ +- hosts: all + become: true + become_user: root + tasks: + - name: Update apt repo and cache on all Debian/Ubuntu boxes + apt: update_cache=yes force_apt_get=yes cache_valid_time=3600 + + - name: Upgrade all packages on servers + apt: upgrade=dist force_apt_get=yes + + - name: Check if a reboot is needed on all servers + register: reboot_required_file + stat: path=/var/run/reboot-required get_md5=no + + - name: Reboot the box if kernel updated + reboot: + msg: "Reboot initiated by Ansible for kernel updates" + connect_timeout: 5 + reboot_timeout: 300 + pre_reboot_delay: 0 + post_reboot_delay: 30 + test_command: uptime + when: reboot_required_file.stat.exists