-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathutils-debian10to11.yml
66 lines (63 loc) · 2.58 KB
/
utils-debian10to11.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# the tag 'utils-debian10to11' must be passed explicitly for these tasks to run
- name: check if host is already running the target distribution
debug:
msg: "Host is already running Debian 11. Nothing to do."
when: ansible_facts.distribution_release == "bullseye"
- name: run pre-upgrade steps on Proxmox hosts
when: ansible_facts.distribution_release == "buster"
block:
- name: check for presence of proxmox update check script
stat:
path: /usr/bin/pve6to7
register: common_pve6to7
- name: run proxmox update check script
command: /usr/bin/pve6to7
when: common_pve6to7.stat.exists
check_mode: no # run even in check mode, does not change anything
changed_when: no
- name: show message when manual upgrade is required
debug:
msg: "WARNING: {{ inventory_hostname }} is a proxmox node and must be upgraded manually https://pve.proxmox.com/wiki/Upgrade_from_6.x_to_7.0"
changed_when: yes
when: common_pve6to7.stat.exists
- name: upgrade Debian 10 to 11
when: ansible_facts.distribution_release == "buster"
block:
- name: upgrade all packages to latest versions
apt:
upgrade: safe
autoremove: yes
purge: yes
update_cache: yes
- name: list APT sources configuration files
find:
path: /etc/apt/sources.list.d/
patterns: '*.list'
register: common_apt_sources_files
- name: replace buster with bullseye in APT sources list
replace:
path: "{{ item }}"
regexp: "buster"
replace: "bullseye"
with_items: "{{ common_apt_sources_files.files | map(attribute='path') | list + ['/etc/apt/sources.list'] }}"
- name: update Debian security APT source URL for Debian 11
replace:
path: "{{ item }}"
regexp: "deb https?://security.debian.org/debian-security bullseye/updates"
replace: "deb https://security.debian.org/debian-security bullseye-security"
with_items: "{{ common_apt_sources_files.files | map(attribute='path') | list + ['/etc/apt/sources.list'] }}"
- name: upgrade all packages to latest versions
apt:
upgrade: dist
update_cache: yes
autoremove: yes
purge: yes
when: not common_pve6to7.stat.exists
- name: reboot host
reboot:
reboot_timeout: 6000
when: not common_pve6to7.stat.exists
- name: show upgrade completion message
debug:
msg: "Upgrade to Debian 11 complete. Please run the playbook against this host to apply up-to-date configuration for Debian 11."
when: not common_pve6to7.stat.exists