# Daily package maintenance
#
# Run 'aptitude safe-upgrade' on all registered hosts followed by
# apt-autoremove
#
# Run like:
#
#   $ ansible-playbook -i hosts playbook-daily-upgrade.yml
#
- hosts: all
  become: true
  become_user: root
  tasks:
  - name: safe-upgrade
    # ignore_errors: true
    register: upgrade
    apt:
        update_cache: yes
        upgrade: safe
  - name: autoremove-old-pkgs
    apt:
        autoremove: yes
    when:
        upgrade.changed
