Skip to content

Instantly share code, notes, and snippets.

@divi255
Last active March 9, 2020 19:57
Show Gist options
  • Save divi255/1ea5254b676c83063c0cbcc40f59bc32 to your computer and use it in GitHub Desktop.
Save divi255/1ea5254b676c83063c0cbcc40f59bc32 to your computer and use it in GitHub Desktop.
ansible playbook for debian/ubuntu updates
---
- hosts:
- all
remote_user: root
tasks:
- name: update everything
apt: upgrade=dist force_apt_get=yes autoclean=yes
- name: check if a reboot is necessary
register: reboot_required_file
stat: path=/var/run/reboot-required get_md5=no
- name: reboot
reboot:
msg: "reboot initiated by ansible due to kernel updates"
connect_timeout: 5
reboot_timeout: 30
pre_reboot_delay: 0
post_reboot_delay: 30
test_command: uptime
when: reboot_required_file.stat.exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment