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