Files
ansible-semaphore/apt-update.yml
Joachim Hummel 56d3a7c06f Edit Files
2023-10-25 15:52:10 +00:00

27 lines
835 B
YAML

- hosts: all
sudo: yes
vars:
ansible_host_key_checking: false ##If you get an error about hosts not trusted
become: true
become_user: root
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_md5=no
- 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