diff --git a/Ansible/inventory/example_hosts.ini b/Ansible/inventory/example_hosts.ini index e38ef73..7a71bb9 100644 --- a/Ansible/inventory/example_hosts.ini +++ b/Ansible/inventory/example_hosts.ini @@ -18,7 +18,7 @@ raspberry-pi ansible_host=x.x.x.x [lxc] ansible ansible_host=x.x.x.x zabbix-proxy ansible_host=x.x.x.x -pi-hole ansible_host=x.x.x.x +localhost ansible_connection=local # for testing playbooks on the control node [proxmox_backup] proxmox-backup ansible_host=x.x.x.x diff --git a/Ansible/playbooks/apt_upgrade.yml b/Ansible/playbooks/apt_upgrade.yml index fed9d6e..30362c1 100644 --- a/Ansible/playbooks/apt_upgrade.yml +++ b/Ansible/playbooks/apt_upgrade.yml @@ -1,14 +1,23 @@ -- name: Upgrade packages +--- +- name: Upgrade all apt packages hosts: ubuntu - become: true - + become: yes tasks: - - name: Update cache - ansible.builtin.apt: - update_cache: true - register: cache_updated + - name: Update apt cache + ansible.builtin.apt: + update_cache: yes + cache_valid_time: 3600 - - name: Upgrade packages if something is changed - ansible.builtin.apt: - upgrade: "yes" - when: cache_updated.changed \ No newline at end of file + - name: Upgrade all apt packages + ansible.builtin.apt: + upgrade: dist + + - name: Check if a reboot is required + ansible.builtin.stat: + path: /var/run/reboot-required + register: reboot_required_file + + - name: Display reboot message + ansible.builtin.debug: + msg: "A reboot is required to apply the latest updates." + when: reboot_required_file.stat.exists