Skip to content

Commit 28372af

Browse files
committed
Ubuntu Upgrade Script tweaks
- Tweaked ordering to fix various issues - Added additional tags so that you can resume if something goes wrong
1 parent 53a1a51 commit 28372af

1 file changed

Lines changed: 63 additions & 41 deletions

File tree

etc/kayobe/ansible/ubuntu-upgrade.yml

Lines changed: 63 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,76 @@
139139
ansible.builtin.setup:
140140
filter: "{{ kayobe_ansible_setup_filter }}"
141141
gather_subset: "{{ kayobe_ansible_setup_gather_subset }}"
142+
vars:
143+
ansible_python_interpreter: /usr/bin/python3
144+
145+
- name: Run the Kayobe network configuration playbook, to ensure definitions are not lost on reboot
146+
import_playbook: "{{ lookup('ansible.builtin.env', 'VIRTUAL_ENV') }}/share/kayobe/ansible/network.yml"
147+
vars:
148+
ansible_python_interpreter: /usr/bin/python3
149+
tags: post
142150

143151
- name: Run the Kayobe kayobe-target-venv playbook to ensure kayobe venv exists on remote host
144152
import_playbook: "{{ lookup('ansible.builtin.env', 'VIRTUAL_ENV') }}/share/kayobe/ansible/kayobe-target-venv.yml"
145153
tags: post
146154

155+
- name: Clean up old repos
156+
hosts: overcloud:infra-vms:seed:seed-hypervisor
157+
vars:
158+
ansible_python_interpreter: /usr/bin/python3
159+
tags:
160+
- post
161+
- cleanup-repos
162+
tasks:
163+
- name: Ensure Noble repo definitions do not exist in sources.list
164+
ansible.builtin.blockinfile:
165+
path: "{{ item }}"
166+
state: absent
167+
become: true
168+
loop:
169+
- /etc/apt/sources.list
170+
171+
- name: Ensure Kolla Ansible Docker repo definition does not exist
172+
ansible.builtin.file:
173+
path: /etc/apt/sources.list.d/docker.list
174+
state: absent
175+
become: true
176+
when: apt_repositories | selectattr('url', 'match', '.*docker-ce.*') | list | length > 0
177+
178+
# Make a backup, in case of having broken apt configuration.
179+
- name: Backup upstream ubuntu.sources
180+
ansible.builtin.copy:
181+
src: /etc/apt/sources.list.d/ubuntu.sources
182+
dest: /etc/apt/ubuntu.sources.bak
183+
backup: true
184+
remote_src: true
185+
become: true
186+
when: hostvars[inventory_hostname].stackhpc_repos_enabled
187+
tags: post
188+
189+
- name: Ensure only Kayobe defined apt repositories are defined
190+
ansible.builtin.file:
191+
path: "/etc/apt/{{ item }}"
192+
state: absent
193+
loop:
194+
- sources.list.distUpgrade
195+
- sources.list.d/third-party.sources
196+
- sources.list.d/ubuntu.sources
197+
become: true
198+
when: hostvars[inventory_hostname].stackhpc_repos_enabled
199+
tags: post
200+
147201
- name: Run the Kayobe apt playbook to ensure Noble repositories are set on remote host
148202
import_playbook: "{{ lookup('ansible.builtin.env', 'VIRTUAL_ENV') }}/share/kayobe/ansible/apt.yml"
149-
tags: post
203+
tags:
204+
- post
205+
- post-cleanup
150206

151207
- name: Fix broken packages after upgrade
152208
hosts: overcloud:infra-vms:seed:seed-hypervisor
153-
tags: post
209+
tags:
210+
- post
211+
- post-cleanup
154212
tasks:
155213
- name: Ensure iproute2 is installed
156214
ansible.builtin.apt:
@@ -171,30 +229,15 @@
171229
filter: "{{ kayobe_ansible_setup_filter }}"
172230
gather_subset: "{{ kayobe_ansible_setup_gather_subset }}"
173231

174-
- name: Run the Kayobe network configuration playbook, to ensure definitions are not lost on reboot
175-
import_playbook: "{{ lookup('ansible.builtin.env', 'VIRTUAL_ENV') }}/share/kayobe/ansible/network.yml"
176-
tags: post
177-
178232
- name: Reboot and confirm the host is upgraded to Noble 24.04
179233
hosts: overcloud:infra-vms:seed:seed-hypervisor
180234
vars:
181235
ansible_python_interpreter: /usr/bin/python3
182236
reboot_timeout_s: "{{ 20 * 60 }}"
183-
tags: post
237+
tags:
238+
- post
239+
- post-cleanup
184240
tasks:
185-
- name: Ensure Noble repo definitions do not exist in sources.list
186-
ansible.builtin.blockinfile:
187-
path: /etc/apt/sources.list
188-
state: absent
189-
become: true
190-
191-
- name: Ensure Kolla Ansible Docker repo definition does not exist
192-
ansible.builtin.file:
193-
path: /etc/apt/sources.list.d/docker.list
194-
state: absent
195-
become: true
196-
when: apt_repositories | selectattr('url', 'match', '.*docker-ce.*') | list | length > 0
197-
198241
- name: Reboot and wait
199242
ansible.builtin.reboot:
200243
reboot_timeout: "{{ reboot_timeout_s }}"
@@ -210,27 +253,6 @@
210253
- /usr/local/sbin
211254
become: true
212255

213-
# Make a backup, in case of having broken apt configuration.
214-
- name: Backup upstream ubuntu.sources
215-
ansible.builtin.copy:
216-
src: /etc/apt/sources.list.d/ubuntu.sources
217-
dest: /etc/apt/ubuntu.sources.bak
218-
backup: true
219-
remote_src: true
220-
become: true
221-
when: hostvars[inventory_hostname].stackhpc_repos_enabled
222-
223-
- name: Ensure only Kayobe defined apt repositories are defined
224-
ansible.builtin.file:
225-
path: "/etc/apt/{{ item }}"
226-
state: absent
227-
loop:
228-
- sources.list.distUpgrade
229-
- sources.list.d/third-party.sources
230-
- sources.list.d/ubuntu.sources
231-
become: true
232-
when: hostvars[inventory_hostname].stackhpc_repos_enabled
233-
234256
- name: Ensure all packages are in Noble version
235257
ansible.builtin.apt:
236258
upgrade: full

0 commit comments

Comments
 (0)