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: Update hostname
73 # eg. ansible-playbook -e '{"UPDATE_HOSTNAME":true}' playbooks/release-upgrade.yml
74 update_hostname: "{{lookup('vars', 'UPDATE_HOSTNAME', default='false')}}"
77 msg: "update_hostname: {{update_hostname}}"
80 regexp: "{{ansible_distribution_release}}"
81 replace: "{{next_release}}"
82 when: update_hostname | bool
85 regexp: "deb{{ansible_distribution_version}}"
86 replace: "deb{{ansible_distribution_version|int + 1 }}"
87 when: update_hostname | bool and ansible_distribution == 'Debian'
88 - name: Debian major version upgrade
91 apt_noninteractive_environment:
92 DEBIAN_FRONTEND: noninteractive
93 APT_LISTCHANGES_FRONTEND: mail
94 apt_common_options: "-o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confnew'"
96 - import_tasks: ../tasks/debian_release_upgrade.yml
97 when: ansible_distribution == 'Debian'
98 - name: Ubuntu major version upgrade
101 - name: Do release upgrade
102 when: ansible_distribution == 'Ubuntu'
104 cmd: 'do-release-upgrade -m server --frontend=DistUpgradeViewNonInteractive'
105 - name: Post-upgrade tasks
108 - name: Mark rsyslog as auto
109 when: next_release == 'bookworm'
111 cmd: 'apt-mark auto rsyslog'
112 - name: Autoremove any packages
116 - name: Clean apt cache