--- - name: Update and upgrade all servers hosts: all become: yes become_method: sudo become_user: root tasks: - name: Update apt cache (tolerate repo codename changes) shell: apt-get update -o Acquire::AllowReleaseInfoChange=true -o Acquire::AllowReleaseInfoChange::Origin=true -o Acquire::AllowReleaseInfoChange::Suite=true -o Acquire::AllowReleaseInfoChange::Codename=true register: apt_update changed_when: "'packages can be upgraded' in apt_update.stdout" - name: Upgrade all packages (tolerate repo codename changes) shell: apt-get dist-upgrade -y --autoremove --autoclean -o Acquire::AllowReleaseInfoChange=true -o Acquire::AllowReleaseInfoChange::Origin=true -o Acquire::AllowReleaseInfoChange::Suite=true -o Acquire::AllowReleaseInfoChange::Codename=true register: apt_upgrade changed_when: "'upgraded,' in apt_upgrade.stdout"