From bdbc512647c9351e7b360fc60a4b20bebacf2838 Mon Sep 17 00:00:00 2001 From: Roxedus Date: Tue, 17 Aug 2021 00:13:23 +0200 Subject: [PATCH] QoL --- ansible/run.yml | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/ansible/run.yml b/ansible/run.yml index f9e86c3..c3e9c7a 100644 --- a/ansible/run.yml +++ b/ansible/run.yml @@ -52,6 +52,11 @@ test_command: uptime when: new_hostname.changed + - name: Update apt cache + ansible.builtin.apt: + update_cache: true + cache_valid_time: 1 + roles: - role: geerlingguy.ntp - role: geerlingguy.security @@ -171,10 +176,10 @@ # https://www.cyberciti.biz/faq/ansible-apt-update-all-packages-on-ubuntu-debian-linux/ - name: Update packages ansible.builtin.apt: - update_cache: true - force_apt_get: true + update_cache: "True" + force_apt_get: "True" cache_valid_time: 3600 - upgrade: true + upgrade: "True" - name: Remove ubuntu motd spam ansible.builtin.file: @@ -185,11 +190,18 @@ - 50-landscape-sysinfo - 50-motd-news - 80-livepatch + - 90-updates-available - 95-hwe-eol when: ansible_distribution == 'Ubuntu' - - name: Update PiHole + - name: Check if pi-hole is installed when: inventory_hostname in groups['piholes'] + stat: + path: "/usr/local/bin/pihole" + register: pihole_exec + + - name: Update PiHole + when: inventory_hostname in groups['piholes'] and pihole_exec.stat.exists become: true ansible.builtin.command: argv: @@ -198,9 +210,12 @@ - name: Check if a reboot is needed for Debian and Ubuntu boxes register: reboot_required_file - stat: path=/var/run/reboot-required get_md5=no + stat: + path: /var/run/reboot-required + get_md5: no - name: Reboot the server + throttle: 1 ansible.builtin.reboot: msg: "Reboot initiated by Ansible due to kernel updates" connect_timeout: 5