Skip to content

Commit 3818ff9

Browse files
Ubuntu Focal to Jammy migration support (#902)
Add playbook to upgrade ubuntu focal hosts Co-authored-by: Alex-Welsh <[email protected]>
1 parent 4837c8d commit 3818ff9

File tree

6 files changed

+240
-0
lines changed

6 files changed

+240
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
---
2+
# To prevent Ansible role dependency errors, this playbook requires that environment variable
3+
# ANSIBLE_ROLES_PATH is defined and includes '$KAYOBE_PATH/ansible/roles' on the Ansible control host.
4+
- name: Migrate hosts from Ubuntu Focal 20.04 to Jammy 22.04
5+
hosts: overcloud:infra-vms:seed:seed-hypervisor
6+
vars:
7+
ansible_python_interpreter: /usr/bin/python3
8+
tasks:
9+
- name: Assert that hosts are running Ubuntu Focal
10+
assert:
11+
that:
12+
- ansible_facts.distribution == 'Ubuntu'
13+
- ansible_facts.distribution_major_version == '20'
14+
- ansible_facts.distribution_release == 'focal'
15+
- os_distribution == 'ubuntu'
16+
fail_msg: >-
17+
This playbook is only designed for Ubuntu Focal 20.04 hosts. Ensure
18+
that you are limiting it to only run on Focal hosts and
19+
os_distribution is set to ubuntu.
20+
21+
- name: Ensure apt packages are up to date
22+
apt:
23+
update_cache: true
24+
upgrade: yes
25+
become: true
26+
27+
- name: Ensure do-release-upgrade is installed
28+
package:
29+
name: ubuntu-release-upgrader-core
30+
state: latest
31+
become: true
32+
33+
- name: Check whether a reboot is required
34+
stat:
35+
path: /var/run/reboot-required
36+
register: file_status
37+
38+
- name: Reboot to apply updates
39+
reboot:
40+
reboot_timeout: 1200
41+
connect_timeout: 600
42+
become: true
43+
when: file_status.stat.exists
44+
45+
# NOTE: We cannot use apt_repository here because definitions must exist within the standard repos.list
46+
- name: Ensure Jammy repo definitions exist in sources.list
47+
blockinfile:
48+
path: /etc/apt/sources.list
49+
block: |
50+
deb {{ stackhpc_repo_ubuntu_jammy_url }} jammy main restricted universe multiverse
51+
deb {{ stackhpc_repo_ubuntu_jammy_url }} jammy-updates main restricted universe multiverse
52+
deb {{ stackhpc_repo_ubuntu_jammy_url }} jammy-backports main restricted universe multiverse
53+
deb {{ stackhpc_repo_ubuntu_jammy_security_url }} jammy-security main restricted universe multiverse
54+
become: true
55+
56+
- name: Do release upgrade
57+
command: do-release-upgrade -f DistUpgradeViewNonInteractive
58+
become: true
59+
60+
- name: Ensure old venvs do not exist
61+
file:
62+
path: "/opt/kayobe/venvs/{{ item }}"
63+
state: absent
64+
loop:
65+
- kayobe
66+
- kolla-ansible
67+
become: true
68+
69+
- name: Update Python and current user facts before re-creating Kayobe venv
70+
ansible.builtin.setup:
71+
filter: "{{ kayobe_ansible_setup_filter }}"
72+
gather_subset: "{{ kayobe_ansible_setup_gather_subset }}"
73+
74+
- name: Run the Kayobe kayobe-target-venv playbook to ensure kayobe venv exists on remote host
75+
import_playbook: "{{ lookup('ansible.builtin.env', 'VIRTUAL_ENV') }}/share/kayobe/ansible/kayobe-target-venv.yml"
76+
77+
- name: Run the Kayobe network configuration playbook, to ensure definitions are not lost on reboot
78+
import_playbook: "{{ lookup('ansible.builtin.env', 'VIRTUAL_ENV') }}/share/kayobe/ansible/network.yml"
79+
80+
- name: Reboot and confirm the host is upgraded to Jammy 22.04
81+
hosts: overcloud:infra-vms:seed:seed-hypervisor
82+
vars:
83+
ansible_python_interpreter: /usr/bin/python3
84+
tasks:
85+
- name: Ensure Jammy repo definitions do not exist in sources.list
86+
blockinfile:
87+
path: /etc/apt/sources.list
88+
state: absent
89+
become: true
90+
91+
- name: Reboot and wait
92+
reboot:
93+
reboot_timeout: 1200
94+
connect_timeout: 600
95+
become: true
96+
97+
- name: Update distribution facts
98+
ansible.builtin.setup:
99+
filter: "{{ kayobe_ansible_setup_filter }}"
100+
gather_subset: "{{ kayobe_ansible_setup_gather_subset }}"
101+
102+
- name: Assert that hosts are now using Ubuntu 22
103+
assert:
104+
that:
105+
- ansible_facts.distribution_major_version == '22'
106+
- ansible_facts.distribution_release == 'jammy'
107+
108+
- name: Run the OVN chassis priority fix playbook
109+
import_playbook: "{{ lookup('ansible.builtin.env', 'KAYOBE_CONFIG_PATH') }}/ansible/ovn-fix-chassis-priorities.yml"
110+
when: kolla_enable_ovn
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
features:
3+
- |
4+
Add support for automated Ubuntu Focal to Jammy migration.

tools/ubuntu-upgrade-infra-vm.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#! /usr/bin/bash
2+
3+
set -e
4+
5+
if [[ ! $1 ]]; then
6+
echo "Usage: infra-vm-ubuntu-upgrade.sh <infra-vm-hostname>"
7+
exit 2
8+
fi
9+
10+
if [[ ! $KAYOBE_PATH ]]; then
11+
echo "Environment variable \$KAYOBE_PATH is not defined"
12+
exit 2
13+
fi
14+
15+
if [[ ! $KAYOBE_CONFIG_PATH ]]; then
16+
echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined"
17+
exit 2
18+
fi
19+
20+
if [[ ! $ANSIBLE_ROLES_PATH ]]; then
21+
set -x
22+
export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles
23+
set +x
24+
else
25+
set -x
26+
export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles
27+
set +x
28+
fi
29+
30+
set -x
31+
32+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=jammy --limit $1
33+
34+
kayobe infra vm host configure --limit $1 -e os_release=jammy

tools/ubuntu-upgrade-overcloud.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#! /usr/bin/bash
2+
3+
set -e
4+
5+
if [[ ! $1 ]]; then
6+
echo "Usage: overcloud-ubuntu-upgrade.sh <overcloud-hostname>"
7+
exit 2
8+
fi
9+
10+
if [[ ! $KAYOBE_PATH ]]; then
11+
echo "Environment variable \$KAYOBE_PATH is not defined"
12+
exit 2
13+
fi
14+
15+
if [[ ! $KAYOBE_CONFIG_PATH ]]; then
16+
echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined"
17+
exit 2
18+
fi
19+
20+
if [[ ! $ANSIBLE_ROLES_PATH ]]; then
21+
set -x
22+
export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles
23+
set +x
24+
else
25+
set -x
26+
export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles
27+
set +x
28+
fi
29+
30+
set -x
31+
32+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=jammy --limit $1
33+
34+
kayobe overcloud host configure --limit $1 --kolla-limit $1 -e os_release=jammy
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#! /usr/bin/bash
2+
3+
set -e
4+
5+
if [[ ! $KAYOBE_PATH ]]; then
6+
echo "Environment variable \$KAYOBE_PATH is not defined"
7+
exit 2
8+
fi
9+
10+
if [[ ! $KAYOBE_CONFIG_PATH ]]; then
11+
echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined"
12+
exit 2
13+
fi
14+
15+
if [[ ! $ANSIBLE_ROLES_PATH ]]; then
16+
set -x
17+
export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles
18+
set +x
19+
else
20+
set -x
21+
export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles
22+
set +x
23+
fi
24+
25+
set -x
26+
27+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=jammy --limit seed-hypervisor
28+
29+
kayobe seed hypervisor host configure

tools/ubuntu-upgrade-seed.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#! /usr/bin/bash
2+
3+
set -e
4+
5+
if [[ ! $KAYOBE_PATH ]]; then
6+
echo "Environment variable \$KAYOBE_PATH is not defined"
7+
exit 2
8+
fi
9+
10+
if [[ ! $KAYOBE_CONFIG_PATH ]]; then
11+
echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined"
12+
exit 2
13+
fi
14+
15+
if [[ ! $ANSIBLE_ROLES_PATH ]]; then
16+
set -x
17+
export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles
18+
set +x
19+
else
20+
set -x
21+
export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles
22+
set +x
23+
fi
24+
25+
set -x
26+
27+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=jammy --limit seed
28+
29+
kayobe seed host configure

0 commit comments

Comments
 (0)