--- # tasks file for ensure_os_upgrade - Debian - name: Update sources.list for Debian Upgrade when: - ansible_facts["os_family"] == 'Debian' - ensure_os_upgrade is defined - ensure_os_upgrade.target_codename is defined ansible.builtin.replace: path: /etc/apt/sources.list regexp: '^(deb(?:-src)?\s+https?://[a-zA-Z0-9.-]*debian\.org\S*\s+)\b{{ ansible_facts["lsb"]["codename"] }}\b(.*)$' replace: '\1{{ ensure_os_upgrade.target_codename }}\2' backup: true - name: Safe Upgrade Debian Packages when: - ansible_facts["os_family"] == 'Debian' - ensure_os_upgrade is defined - ensure_os_upgrade.target_codename is defined ansible.builtin.apt: update_cache: true upgrade: safe dpkg_options: 'force-confnew,force-confdef' environment: DEBIAN_FRONTEND: noninteractive - name: Full Upgrade Debian Packages when: - ansible_facts["os_family"] == 'Debian' - ensure_os_upgrade is defined - ensure_os_upgrade.target_codename is defined ansible.builtin.apt: upgrade: dist dpkg_options: 'force-confnew,force-confdef' autoremove: true autoclean: true environment: DEBIAN_FRONTEND: noninteractive - name: Reboot Debian After Upgrade when: - ansible_facts["os_family"] == 'Debian' - ensure_os_upgrade is defined - ensure_os_upgrade.target_codename is defined ansible.builtin.reboot: msg: "Rebooting for OS Upgrade" connect_timeout: 5 reboot_timeout: 1800 pre_reboot_delay: 5 post_reboot_delay: 15 test_command: whoami