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
22 - name: Run any outstanding upgrades
32 - name: Pre-upgrade backups
35 - name: Check if /etc is a git repo
38 cmd: test -d /etc/.git
40 - name: Tag etc configuration
41 when: etckeeper.rc == 0
48 - "pre-{{next_release}}"
52 - name: Backup package state
55 cmd: "tar czf /var/backups/pre-{{next_release}}-backup.tgz /etc /var/lib/dpkg /var/lib/apt/extended_states"
56 # Mitogen doesn't seem to work with the 'archive' module, since tarfile is
57 # "present in the Mitogent importer blacklist", so a shell command is used
61 cmd: "dpkg --get-selections '*' > /var/backups/dpkg-selections-pre-{{next_release}}.txt"
66 - "/var/backups/pre-{{next_release}}-backup.tgz"
67 - "/var/backups/dpkg-selections-pre-{{next_release}}.txt"
68 - name: Update hostname
71 # eg. ansible-playbook -e '{"UPDATE_HOSTNAME":true}' playbooks/release-upgrade.yml
72 update_hostname: "{{lookup('vars', 'UPDATE_HOSTNAME', default='false')}}"
75 msg: "update_hostname: {{update_hostname}}"
78 regexp: "{{ansible_distribution_release}}"
79 replace: "{{next_release}}"
80 when: update_hostname | bool
83 regexp: "deb{{ansible_distribution_version}}"
84 replace: "deb{{ansible_distribution_version|int + 1 }}"
85 when: update_hostname | bool and ansible_distribution == 'Debian'
86 - name: Debian major version upgrade
89 apt_noninteractive_environment:
90 DEBIAN_FRONTEND: noninteractive
91 APT_LISTCHANGES_FRONTEND: mail
92 apt_common_options: "-o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confnew'"
94 - import_tasks: ../tasks/debian_release_upgrade.yml
95 when: ansible_distribution == 'Debian'
96 - name: Ubuntu major version upgrade
99 - name: Do release upgrade
100 when: ansible_distribution == 'Ubuntu'
102 cmd: 'do-release-upgrade -m server --frontend=DistUpgradeViewNonInteractive'
103 - name: Post-upgrade tasks
106 - name: Mark rsyslog as auto
107 when: next_release == 'bookworm'
109 cmd: 'apt-mark auto rsyslog'
110 - name: Autoremove any packages
114 - name: Clean apt cache