|
1 | 1 | ---
|
2 | 2 | # To prevent Ansible role dependency errors, this playbook requires that environment variable
|
3 | 3 | # 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 |
5 | 5 | hosts: overcloud:infra-vms:seed:seed-hypervisor
|
6 | 6 | vars:
|
7 | 7 | ansible_python_interpreter: /usr/bin/python3
|
8 | 8 | reboot_timeout_s: "{{ 20 * 60 }}"
|
| 9 | + tags: pre |
9 | 10 | tasks:
|
10 | 11 | - name: Assert that hosts are running Ubuntu Jammy
|
11 | 12 | ansible.builtin.assert:
|
|
67 | 68 | ansible.builtin.command: sudo mount -o remount,exec /tmp
|
68 | 69 | become: true
|
69 | 70 |
|
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: |
74 | 114 | - name: Ensure old venvs do not exist
|
75 | 115 | ansible.builtin.file:
|
76 | 116 | path: /opt/kayobe/venvs/{{ item }}
|
|
87 | 127 |
|
88 | 128 | - name: Run the Kayobe kayobe-target-venv playbook to ensure kayobe venv exists on remote host
|
89 | 129 | 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 }}" |
90 | 150 |
|
91 | 151 | - name: Run the Kayobe network configuration playbook, to ensure definitions are not lost on reboot
|
92 | 152 | import_playbook: "{{ lookup('ansible.builtin.env', 'VIRTUAL_ENV') }}/share/kayobe/ansible/network.yml"
|
| 153 | + tags: post |
93 | 154 |
|
94 | 155 | - name: Reboot and confirm the host is upgraded to Noble 24.04
|
95 | 156 | hosts: overcloud:infra-vms:seed:seed-hypervisor
|
96 | 157 | vars:
|
97 | 158 | ansible_python_interpreter: /usr/bin/python3
|
98 | 159 | reboot_timeout_s: "{{ 20 * 60 }}"
|
| 160 | + tags: post |
99 | 161 | tasks:
|
100 | 162 | - name: Ensure Noble repo definitions do not exist in sources.list
|
101 | 163 | ansible.builtin.blockinfile:
|
|
125 | 187 | - /usr/local/sbin
|
126 | 188 | become: true
|
127 | 189 |
|
| 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 | + |
128 | 206 | - name: Update distribution facts
|
129 | 207 | ansible.builtin.setup:
|
130 | 208 | filter: "{{ kayobe_ansible_setup_filter }}"
|
|
0 commit comments