|
| 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 |
0 commit comments