Adjusted apt update to provide a feedback if upgrade is needed and wait one hour for cache update. Added localhost entity into the hosts.ini
This commit is contained in:
@@ -18,7 +18,7 @@ raspberry-pi ansible_host=x.x.x.x
|
|||||||
[lxc]
|
[lxc]
|
||||||
ansible ansible_host=x.x.x.x
|
ansible ansible_host=x.x.x.x
|
||||||
zabbix-proxy 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]
|
||||||
proxmox-backup ansible_host=x.x.x.x
|
proxmox-backup ansible_host=x.x.x.x
|
||||||
|
|||||||
@@ -1,14 +1,23 @@
|
|||||||
- name: Upgrade packages
|
---
|
||||||
|
- name: Upgrade all apt packages
|
||||||
hosts: ubuntu
|
hosts: ubuntu
|
||||||
become: true
|
become: yes
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Update cache
|
- name: Update apt cache
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
update_cache: true
|
update_cache: yes
|
||||||
register: cache_updated
|
cache_valid_time: 3600
|
||||||
|
|
||||||
- name: Upgrade packages if something is changed
|
- name: Upgrade all apt packages
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
upgrade: "yes"
|
upgrade: dist
|
||||||
when: cache_updated.changed
|
|
||||||
|
- 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
|
||||||
|
|||||||
Reference in New Issue
Block a user