Skip to content

Commit 7e70c12

Browse files
committed
Add tasks for Noble upgrade
1 parent 33a89ac commit 7e70c12

File tree

1 file changed

+83
-5
lines changed

1 file changed

+83
-5
lines changed

etc/kayobe/ansible/ubuntu-upgrade.yml

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
22
# To prevent Ansible role dependency errors, this playbook requires that environment variable
33
# ANSIBLE_ROLES_PATH is defined and includes '$KAYOBE_PATH/ansible/roles' on the Ansible control host.
4-
- name: Migrate hosts from Ubuntu Jammy 22.04 to Noble 24.04
4+
- name: Prepare upgrade from Ubuntu Jammy 22.04 to Noble 24.04
55
hosts: overcloud:infra-vms:seed:seed-hypervisor
66
vars:
77
ansible_python_interpreter: /usr/bin/python3
88
reboot_timeout_s: "{{ 20 * 60 }}"
9+
tags: pre
910
tasks:
1011
- name: Assert that hosts are running Ubuntu Jammy
1112
ansible.builtin.assert:
@@ -67,10 +68,49 @@
6768
ansible.builtin.command: sudo mount -o remount,exec /tmp
6869
become: true
6970

70-
- name: Do release upgrade
71-
ansible.builtin.command: do-release-upgrade -f DistUpgradeViewNonInteractive
72-
become: true
73-
71+
- name: Upgrade hosts from Ubuntu Jammy 22.04 to Noble 24.04
72+
hosts: overcloud:infra-vms:seed:seed-hypervisor
73+
vars:
74+
ansible_python_interpreter: /usr/bin/python3
75+
reboot_timeout_s: "{{ 20 * 60 }}"
76+
tags: upgrade
77+
tasks:
78+
- name: Perform in-place Ubuntu upgrade
79+
block:
80+
- name: Run do-release-upgrade
81+
ansible.builtin.command: do-release-upgrade -f DistUpgradeViewNonInteractive
82+
become: true
83+
register: upgrade_result
84+
rescue:
85+
- name: Ensure Noble repo definitions do not exist in sources.list
86+
ansible.builtin.blockinfile:
87+
path: /etc/apt/sources.list
88+
state: absent
89+
become: true
90+
91+
- name: Ensure Kolla Ansible Docker repo definition does not exist
92+
ansible.builtin.file:
93+
path: /etc/apt/sources.list.d/docker.list
94+
state: absent
95+
become: true
96+
when: apt_repositories | selectattr('url', 'match', '.*docker-ce.*') | list | length > 0
97+
98+
- name: Display recommanded action on upgrade failure
99+
ansible.builtin.debug:
100+
msg: >
101+
Ubuntu upgrade failed. You can check the upgrade logs at /var/log/dist-upgrade
102+
on the failed host.
103+
It is likely due to packages with broken dependency. You can find broken packages
104+
by running following command from the host.
105+
cat /var/log/dist-upgrade/apt.log | grep "Holding Back" | awk '{print $3}'
106+
107+
- name: Post upgrade of Ubuntu Jammy 22.04 to Noble 24.04
108+
hosts: overcloud:infra-vms:seed:seed-hypervisor
109+
vars:
110+
ansible_python_interpreter: /usr/bin/python3
111+
reboot_timeout_s: "{{ 20 * 60 }}"
112+
tags: post
113+
tasks:
74114
- name: Ensure old venvs do not exist
75115
ansible.builtin.file:
76116
path: /opt/kayobe/venvs/{{ item }}
@@ -87,15 +127,37 @@
87127

88128
- name: Run the Kayobe kayobe-target-venv playbook to ensure kayobe venv exists on remote host
89129
import_playbook: "{{ lookup('ansible.builtin.env', 'VIRTUAL_ENV') }}/share/kayobe/ansible/kayobe-target-venv.yml"
130+
tags: post
131+
132+
- name: Run the Kayobe apt playbook to ensure Noble repositories are set on remote host
133+
import_playbook: "{{ lookup('ansible.builtin.env', 'VIRTUAL_ENV') }}/share/kayobe/ansible/apt.yml"
134+
tags: post
135+
136+
- name: Fix broken packages after upgrade
137+
hosts: overcloud:infra-vms:seed:seed-hypervisor
138+
tags: post
139+
tasks:
140+
- name: Ensure iproute2 is installed
141+
ansible.builtin.apt:
142+
name: iproute2
143+
state: present
144+
become: true
145+
146+
- name: Update Python and current user facts before running Kayobe network playbook
147+
ansible.builtin.setup:
148+
filter: "{{ kayobe_ansible_setup_filter }}"
149+
gather_subset: "{{ kayobe_ansible_setup_gather_subset }}"
90150

91151
- name: Run the Kayobe network configuration playbook, to ensure definitions are not lost on reboot
92152
import_playbook: "{{ lookup('ansible.builtin.env', 'VIRTUAL_ENV') }}/share/kayobe/ansible/network.yml"
153+
tags: post
93154

94155
- name: Reboot and confirm the host is upgraded to Noble 24.04
95156
hosts: overcloud:infra-vms:seed:seed-hypervisor
96157
vars:
97158
ansible_python_interpreter: /usr/bin/python3
98159
reboot_timeout_s: "{{ 20 * 60 }}"
160+
tags: post
99161
tasks:
100162
- name: Ensure Noble repo definitions do not exist in sources.list
101163
ansible.builtin.blockinfile:
@@ -125,6 +187,22 @@
125187
- /usr/local/sbin
126188
become: true
127189

190+
- name: Ensure only Kayobe defined apt repositories are defined
191+
ansible.builtin.file:
192+
path: "/etc/apt/{{ item }}"
193+
state: absent
194+
loop:
195+
- sources.list.distUpgrade
196+
- sources.list.d/third-party.sources
197+
- sources.list.d/ubuntu.sources
198+
become: true
199+
200+
- name: Ensure all packages are in Noble version
201+
ansible.builtin.apt:
202+
upgrade: full
203+
update_cache: true
204+
become: true
205+
128206
- name: Update distribution facts
129207
ansible.builtin.setup:
130208
filter: "{{ kayobe_ansible_setup_filter }}"

0 commit comments

Comments
 (0)