Skip to content

Commit 4575b69

Browse files
authored
Ubuntu Upgrade Script tweaks (#2141)
- Tweaked ordering to fix various issues - Added additional tags so that you can resume if something goes wrong
1 parent a86d1df commit 4575b69

File tree

1 file changed

+59
-41
lines changed

1 file changed

+59
-41
lines changed

etc/kayobe/ansible/ubuntu-upgrade.yml

Lines changed: 59 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,72 @@
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: /etc/apt/sources.list
166+
state: absent
167+
become: true
168+
169+
- name: Ensure Kolla Ansible Docker repo definition does not exist
170+
ansible.builtin.file:
171+
path: /etc/apt/sources.list.d/docker.list
172+
state: absent
173+
become: true
174+
when: apt_repositories | selectattr('url', 'match', '.*docker-ce.*') | list | length > 0
175+
176+
# Make a backup, in case of having broken apt configuration.
177+
- name: Backup upstream ubuntu.sources
178+
ansible.builtin.copy:
179+
src: /etc/apt/sources.list.d/ubuntu.sources
180+
dest: /etc/apt/ubuntu.sources.bak
181+
backup: true
182+
remote_src: true
183+
become: true
184+
when: hostvars[inventory_hostname].stackhpc_repos_enabled
185+
186+
- name: Ensure only Kayobe defined apt repositories are defined
187+
ansible.builtin.file:
188+
path: "/etc/apt/{{ item }}"
189+
state: absent
190+
loop:
191+
- sources.list.distUpgrade
192+
- sources.list.d/third-party.sources
193+
- sources.list.d/ubuntu.sources
194+
become: true
195+
when: hostvars[inventory_hostname].stackhpc_repos_enabled
196+
147197
- name: Run the Kayobe apt playbook to ensure Noble repositories are set on remote host
148198
import_playbook: "{{ lookup('ansible.builtin.env', 'VIRTUAL_ENV') }}/share/kayobe/ansible/apt.yml"
149-
tags: post
199+
tags:
200+
- post
201+
- post-cleanup
150202

151203
- name: Fix broken packages after upgrade
152204
hosts: overcloud:infra-vms:seed:seed-hypervisor
153-
tags: post
205+
tags:
206+
- post
207+
- post-cleanup
154208
tasks:
155209
- name: Ensure iproute2 is installed
156210
ansible.builtin.apt:
@@ -171,30 +225,15 @@
171225
filter: "{{ kayobe_ansible_setup_filter }}"
172226
gather_subset: "{{ kayobe_ansible_setup_gather_subset }}"
173227

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-
178228
- name: Reboot and confirm the host is upgraded to Noble 24.04
179229
hosts: overcloud:infra-vms:seed:seed-hypervisor
180230
vars:
181231
ansible_python_interpreter: /usr/bin/python3
182232
reboot_timeout_s: "{{ 20 * 60 }}"
183-
tags: post
233+
tags:
234+
- post
235+
- post-cleanup
184236
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-
198237
- name: Reboot and wait
199238
ansible.builtin.reboot:
200239
reboot_timeout: "{{ reboot_timeout_s }}"
@@ -210,27 +249,6 @@
210249
- /usr/local/sbin
211250
become: true
212251

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-
234252
- name: Ensure all packages are in Noble version
235253
ansible.builtin.apt:
236254
upgrade: full

0 commit comments

Comments
 (0)