Skip to content

Instantly share code, notes, and snippets.

@tomwassenberg
Last active August 23, 2019 10:05
Show Gist options
  • Save tomwassenberg/3c00e55627d52d0c948e92a416537341 to your computer and use it in GitHub Desktop.
Save tomwassenberg/3c00e55627d52d0c948e92a416537341 to your computer and use it in GitHub Desktop.
A combination of Ansible tasks to trigger an apt upgrade, and wait for it to be done. In contrast to simply using the `apt` module, this is compatible with an apt upgrade already in progress. This is useful when you need to run a playbook on a host with `unattended-upgrades` enabled and is booted up on demand. Workaround for https://github.com/a…
---
- name: "update all packages"
systemd:
name: "apt-daily-upgrade.service"
state: "started"
- name: "check if updating is done"
systemd:
name: "apt-daily-upgrade.service"
state: "stopped"
register: "apt_upgrade"
check_mode: true
until: "apt_upgrade is skipped or apt_upgrade is not changed"
retries: 300
delay: 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment