JG-mirror/Ansible/Playbooks/Update/update.yml
Martin Sloup e6251a6cc5
Replace deprecated get_md5 witch get_checksum
The get_md5 for stat is unsupported and get_md5=no doesn't work with ansible 9.3.0.
2024-03-17 10:08:30 +01:00

23 lines
724 B
YAML

---
- hosts: all
become: true
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_checksum=false
- 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