2 - name: Set next release
6 release_index: "{{lookup('ansible.utils.index_of', data=lookup('vars', ansible_distribution+'_releases', default=[]), test='eq', value=ansible_distribution_release)}}"
7 # If there is not a next release available (as defined below in Debian_releasess
8 # or Ubuntu_releases), the execution of the playbook will fail at this step.
10 next_release: "{{lookup('vars', ansible_distribution+'_releases')[release_index|int + 1]}}"
12 msg: "Upgrading from {{ansible_distribution_release}} to {{next_release}}"
14 # 'stable' releases ordered from oldest to newest
24 - name: Run any outstanding upgrades
34 - name: Pre-upgrade backups
37 - name: Check if /etc is a git repo
40 cmd: test -d /etc/.git
42 - name: Tag etc configuration
43 when: etckeeper.rc == 0
50 - "pre-{{next_release}}"
54 - name: Backup package state
57 cmd: "tar czf /var/backups/pre-{{next_release}}-backup.tgz /etc /var/lib/dpkg /var/lib/apt/extended_states"
58 # Mitogen doesn't seem to work with the 'archive' module, since tarfile is
59 # "present in the Mitogent importer blacklist", so a shell command is used
63 cmd: "dpkg --get-selections '*' > /var/backups/dpkg-selections-pre-{{next_release}}.txt"
68 - "/var/backups/pre-{{next_release}}-backup.tgz"
69 - "/var/backups/dpkg-selections-pre-{{next_release}}.txt"
70 - name: Debian major version upgrade
73 apt_noninteractive_environment:
74 DEBIAN_FRONTEND: noninteractive
75 APT_LISTCHANGES_FRONTEND: mail
77 - import_tasks: ../tasks/debian_release_upgrade.yml
78 when: ansible_distribution == 'Debian'
79 - name: Ubuntu major version upgrade
82 - name: Do release upgrade
83 when: ansible_distribution == 'Ubuntu'
85 cmd: 'do-release-upgrade -m server --frontend=DistUpgradeViewNonInteractive'
86 - name: Post-upgrade tasks
89 - name: Mark rsyslog as auto
90 when: next_release == 'bookworm'
92 cmd: 'apt-mark auto rsyslog'
93 - name: Autoremove any packages
97 - name: Clean apt cache