Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions etc/kayobe/ansible/ubuntu-upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
# To prevent Ansible role dependency errors, this playbook requires that environment variable
# ANSIBLE_ROLES_PATH is defined and includes '$KAYOBE_PATH/ansible/roles' on the Ansible control host.
- name: Migrate hosts from Ubuntu Focal 20.04 to Jammy 22.04
hosts: overcloud:infra-vms:seed:seed-hypervisor
vars:
ansible_python_interpreter: /usr/bin/python3
tasks:
- name: Assert that hosts are running Ubuntu Focal
assert:
that:
- ansible_facts.distribution == 'Ubuntu'
- ansible_facts.distribution_major_version == '20'
- ansible_facts.distribution_release == 'focal'
- os_distribution == 'ubuntu'
fail_msg: >-
This playbook is only designed for Ubuntu Focal 20.04 hosts. Ensure
that you are limiting it to only run on Focal hosts and
os_distribution is set to ubuntu.

- name: Ensure apt packages are up to date
apt:
update_cache: true
upgrade: yes
become: true

- name: Ensure do-release-upgrade is installed
package:
name: ubuntu-release-upgrader-core
state: latest
become: true

- name: Check whether a reboot is required
stat:
path: /var/run/reboot-required
register: file_status

- name: Reboot to apply updates
reboot:
reboot_timeout: 1200
connect_timeout: 600
become: true
when: file_status.stat.exists

# NOTE: We cannot use apt_repository here because definitions must exist within the standard repos.list
- name: Ensure Jammy repo definitions exist in sources.list
blockinfile:
path: /etc/apt/sources.list
block: |
deb {{ stackhpc_repo_ubuntu_jammy_url }} jammy main restricted universe multiverse
deb {{ stackhpc_repo_ubuntu_jammy_url }} jammy-updates main restricted universe multiverse
deb {{ stackhpc_repo_ubuntu_jammy_url }} jammy-backports main restricted universe multiverse
deb {{ stackhpc_repo_ubuntu_jammy_security_url }} jammy-security main restricted universe multiverse
become: true

- name: Do release upgrade
command: do-release-upgrade -f DistUpgradeViewNonInteractive
become: true

- name: Ensure old venvs do not exist
file:
path: "/opt/kayobe/venvs/{{ item }}"
state: absent
loop:
- kayobe
- kolla-ansible
become: true

- name: Update Python and current user facts before re-creating Kayobe venv
ansible.builtin.setup:
filter: "{{ kayobe_ansible_setup_filter }}"
gather_subset: "{{ kayobe_ansible_setup_gather_subset }}"

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

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

- name: Reboot and confirm the host is upgraded to Jammy 22.04
hosts: overcloud:infra-vms:seed:seed-hypervisor
vars:
ansible_python_interpreter: /usr/bin/python3
tasks:
- name: Ensure Jammy repo definitions do not exist in sources.list
blockinfile:
path: /etc/apt/sources.list
state: absent
become: true

- name: Reboot and wait
reboot:
reboot_timeout: 1200
connect_timeout: 600
become: true

- name: Update distribution facts
ansible.builtin.setup:
filter: "{{ kayobe_ansible_setup_filter }}"
gather_subset: "{{ kayobe_ansible_setup_gather_subset }}"

- name: Assert that hosts are now using Ubuntu 22
assert:
that:
- ansible_facts.distribution_major_version == '22'
- ansible_facts.distribution_release == 'jammy'

- name: Run the OVN chassis priority fix playbook
import_playbook: "{{ lookup('ansible.builtin.env', 'KAYOBE_CONFIG_PATH') }}/ansible/ovn-fix-chassis-priorities.yml"
when: kolla_enable_ovn
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
features:
- |
Add support for automated Ubuntu Focal to Jammy migration.
34 changes: 34 additions & 0 deletions tools/ubuntu-upgrade-infra-vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#! /usr/bin/bash

set -e

if [[ ! $1 ]]; then
echo "Usage: infra-vm-ubuntu-upgrade.sh <infra-vm-hostname>"
exit 2
fi

if [[ ! $KAYOBE_PATH ]]; then
echo "Environment variable \$KAYOBE_PATH is not defined"
exit 2
fi

if [[ ! $KAYOBE_CONFIG_PATH ]]; then
echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined"
exit 2
fi

if [[ ! $ANSIBLE_ROLES_PATH ]]; then
set -x
export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles
set +x
else
set -x
export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles
set +x
fi

set -x

kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=jammy --limit $1

kayobe infra vm host configure --limit $1 -e os_release=jammy
34 changes: 34 additions & 0 deletions tools/ubuntu-upgrade-overcloud.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#! /usr/bin/bash

set -e

if [[ ! $1 ]]; then
echo "Usage: overcloud-ubuntu-upgrade.sh <overcloud-hostname>"
exit 2
fi

if [[ ! $KAYOBE_PATH ]]; then
echo "Environment variable \$KAYOBE_PATH is not defined"
exit 2
fi

if [[ ! $KAYOBE_CONFIG_PATH ]]; then
echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined"
exit 2
fi

if [[ ! $ANSIBLE_ROLES_PATH ]]; then
set -x
export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles
set +x
else
set -x
export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles
set +x
fi

set -x

kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=jammy --limit $1

kayobe overcloud host configure --limit $1 --kolla-limit $1 -e os_release=jammy
29 changes: 29 additions & 0 deletions tools/ubuntu-upgrade-seed-hypervisor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! /usr/bin/bash

set -e

if [[ ! $KAYOBE_PATH ]]; then
echo "Environment variable \$KAYOBE_PATH is not defined"
exit 2
fi

if [[ ! $KAYOBE_CONFIG_PATH ]]; then
echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined"
exit 2
fi

if [[ ! $ANSIBLE_ROLES_PATH ]]; then
set -x
export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles
set +x
else
set -x
export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles
set +x
fi

set -x

kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=jammy --limit seed-hypervisor

kayobe seed hypervisor host configure
29 changes: 29 additions & 0 deletions tools/ubuntu-upgrade-seed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! /usr/bin/bash

set -e

if [[ ! $KAYOBE_PATH ]]; then
echo "Environment variable \$KAYOBE_PATH is not defined"
exit 2
fi

if [[ ! $KAYOBE_CONFIG_PATH ]]; then
echo "Environment variable \$KAYOBE_CONFIG_PATH is not defined"
exit 2
fi

if [[ ! $ANSIBLE_ROLES_PATH ]]; then
set -x
export ANSIBLE_ROLES_PATH=$KAYOBE_PATH/ansible/roles
set +x
else
set -x
export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$KAYOBE_PATH/ansible/roles
set +x
fi

set -x

kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/ubuntu-upgrade.yml -e os_release=jammy --limit seed

kayobe seed host configure