From 3466ec024169129e520561189ed29c3b45426370 Mon Sep 17 00:00:00 2001 From: nixbi93 Date: Mon, 8 Sep 2025 13:39:56 +0000 Subject: [PATCH] =?UTF-8?q?debian-updates.yaml=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian-updates.yaml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 debian-updates.yaml diff --git a/debian-updates.yaml b/debian-updates.yaml new file mode 100644 index 0000000..c5f0b31 --- /dev/null +++ b/debian-updates.yaml @@ -0,0 +1,40 @@ +--- +- name: GNU/Linux Update Playbook + hosts: debian + gather_facts: false + become: true + + tasks: + - name: Update the Apt cache + ansible.builtin.apt: + update_cache: yes + cache_valid_time: 3600 + + - name: Ensure needrestart is installed + ansible.builtin.apt: + name: needrestart + state: present + + - name: Upgrade all packages to latest version + ansible.builtin.apt: + upgrade: full + clean: yes + autoremove: yes + autoclean: yes + environment: + NEEDRESTART_MODE: automatically + + - name: Check if a reboot is required + stat: + path: /var/run/reboot-required + register: reboot_required + + - name: Reboot the machine if required + ansible.builtin.reboot: + msg: "Rebooting after security updates" + connect_timeout: 5 + reboot_timeout: 360 + pre_reboot_delay: 0 + post_reboot_delay: 30 + test_command: uptime + when: reboot_required.stat.exists