Automate the undercloud leapp upgrade.
This patch covers the automation of the undercloud's operating system upgrade using Leapp. It includes a new option for Infrared --undercloud_os_upgrade that will allow us to run only the specific bits to upgrade the undercloud's OS. The node subscription needs to be done before running this set of tasks, otherwise it will fail. Before running leapp it's needed to clean up all the RHEL7 packages and some other packages which conflict with leapp, like is the case of rhos-release. Once the whole leapp upgrade and reboot has been performed, the undercloud might be unsubscribed if desired by setting the leapp_unregister variable. Due to the incompatibility of the python2 binary interpreter and RHEL8, we also need to set the ansible_python_interpreter variable at playbook level inside infrared-plugin/main.yml. Co-Authored: Natal Ngétal<hobbestigrou@erakis.eu> Change-Id: Ided7f974c571c45ab83a59c6dd35ad522555caa3
This commit is contained in:
parent
9ac1e58fe6
commit
7063b476f8
@ -16,6 +16,7 @@ overcloud_stack_name: "overcloud"
|
||||
upgrade_noop: false
|
||||
update_noop: false
|
||||
undercloud_upgrade: false
|
||||
undercloud_os_upgrade: false
|
||||
containerized_undercloud_upgrade: true
|
||||
overcloud_upgrade: false
|
||||
undercloud_update: false
|
||||
@ -252,3 +253,6 @@ roles_upgrade_order: '__undefined__'
|
||||
|
||||
# Packet loss threshold for a ping test
|
||||
loss_threshold: 1
|
||||
|
||||
# Leapp OS upgrade variables
|
||||
leapp_unregister: true
|
||||
|
@ -6,7 +6,10 @@
|
||||
become: true
|
||||
become_method: sudo
|
||||
become_user: stack
|
||||
|
||||
vars:
|
||||
# Explicit ansible_python_interpreter to allow connecting
|
||||
# to different OS releases (EL7/8) while using delegate_to.
|
||||
ansible_python_interpreter: /usr/libexec/platform-python
|
||||
pre_tasks:
|
||||
|
||||
- name: Set upgrade workload launch
|
||||
@ -44,6 +47,11 @@
|
||||
undercloud_upgrade: true
|
||||
when: install.undercloud.upgrade
|
||||
|
||||
- name: Set undercloud operating system upgrade
|
||||
set_fact:
|
||||
undercloud_os_upgrade: true
|
||||
when: install.undercloud.os.upgrade
|
||||
|
||||
- name: Set undercloud reboot
|
||||
set_fact:
|
||||
undercloud_reboot: true
|
||||
|
@ -14,6 +14,11 @@ subparsers:
|
||||
NOTE: Upgrade require overcloud deployment script to be available in home directory of undercloud
|
||||
user at undercloud node
|
||||
default: false
|
||||
undercloud-os-upgrade:
|
||||
type: Bool
|
||||
help: |
|
||||
Upgrade Undercloud's Operating System
|
||||
default: false
|
||||
undercloud-upgrade:
|
||||
type: Bool
|
||||
help: |
|
||||
|
45
tasks/common/undercloud_reboot.yaml
Normal file
45
tasks/common/undercloud_reboot.yaml
Normal file
@ -0,0 +1,45 @@
|
||||
---
|
||||
- name: reboot the undercloud
|
||||
shell: "sleep 2 && shutdown -r now"
|
||||
async: 1
|
||||
poll: 0
|
||||
ignore_errors: true
|
||||
become: true
|
||||
become_user: root
|
||||
|
||||
- name: wait for node to go down
|
||||
become: false
|
||||
command: ping -c1 {{ ansible_host }}
|
||||
register: node_down
|
||||
until: node_down.rc != 0
|
||||
retries: 60
|
||||
delay: 3
|
||||
ignore_errors: true
|
||||
delegate_to: localhost
|
||||
when: "'hypervisor' not in groups and 'virthost' not in groups"
|
||||
|
||||
- name: wait for node to go down
|
||||
command: ping -c1 {{ ansible_host }}
|
||||
register: node_down
|
||||
until: node_down.rc != 0
|
||||
retries: 60
|
||||
delay: 3
|
||||
ignore_errors: true
|
||||
delegate_to: hypervisor
|
||||
when: "'hypervisor' in groups"
|
||||
|
||||
- name: wait for node to go down
|
||||
command: ping -c1 {{ ansible_host }}
|
||||
register: node_down
|
||||
until: node_down.rc != 0
|
||||
retries: 60
|
||||
delay: 3
|
||||
ignore_errors: true
|
||||
delegate_to: virthost
|
||||
when: "'virthost' in groups"
|
||||
|
||||
- name: waiting for the undercloud to be ssh-able
|
||||
wait_for_connection:
|
||||
connect_timeout: 5
|
||||
sleep: 3
|
||||
timeout: 630
|
@ -22,50 +22,8 @@
|
||||
|
||||
- name: handle undercloud reboot
|
||||
block:
|
||||
- name: reboot the undercloud
|
||||
shell: "sleep 2 && shutdown -r now"
|
||||
async: 1
|
||||
poll: 0
|
||||
ignore_errors: true
|
||||
become: true
|
||||
become_user: root
|
||||
|
||||
- name: wait for node to go down
|
||||
become: false
|
||||
command: ping -c1 {{ ansible_host }}
|
||||
register: node_down
|
||||
until: node_down.rc != 0
|
||||
retries: 60
|
||||
delay: 3
|
||||
ignore_errors: true
|
||||
delegate_to: localhost
|
||||
when: "'hypervisor' not in groups and 'virthost' not in groups"
|
||||
|
||||
- name: wait for node to go down
|
||||
command: ping -c1 {{ ansible_host }}
|
||||
register: node_down
|
||||
until: node_down.rc != 0
|
||||
retries: 60
|
||||
delay: 3
|
||||
ignore_errors: true
|
||||
delegate_to: hypervisor
|
||||
when: "'hypervisor' in groups"
|
||||
|
||||
- name: wait for node to go down
|
||||
command: ping -c1 {{ ansible_host }}
|
||||
register: node_down
|
||||
until: node_down.rc != 0
|
||||
retries: 60
|
||||
delay: 3
|
||||
ignore_errors: true
|
||||
delegate_to: virthost
|
||||
when: "'virthost' in groups"
|
||||
|
||||
- name: waiting for the undercloud to be ssh-able
|
||||
wait_for_connection:
|
||||
connect_timeout: 5
|
||||
sleep: 3
|
||||
timeout: 630
|
||||
- name: Reboot the undercloud
|
||||
import_tasks: undercloud_reboot.yaml
|
||||
|
||||
- name: assert UC services started
|
||||
shell: |
|
||||
|
@ -11,10 +11,20 @@
|
||||
when: workload_launch
|
||||
|
||||
- include: upgrade/main.yml
|
||||
when: upgrade_noop|bool or undercloud_upgrade|bool or overcloud_upgrade|bool
|
||||
when: >
|
||||
upgrade_noop|bool or
|
||||
undercloud_upgrade|bool or
|
||||
undercloud_os_upgrade|bool or
|
||||
overcloud_upgrade|bool
|
||||
|
||||
- include: update/main.yml
|
||||
when: update_noop|bool or undercloud_update|bool or overcloud_update|bool
|
||||
when: >
|
||||
update_noop|bool or
|
||||
undercloud_update|bool or
|
||||
overcloud_update|bool
|
||||
|
||||
- include: fast-forward-upgrade/main.yml
|
||||
when: ffu_noop|bool or ffu_undercloud_upgrade|bool or ffu_overcloud_upgrade|bool
|
||||
when: >
|
||||
ffu_noop|bool or
|
||||
ffu_undercloud_upgrade|bool or
|
||||
ffu_overcloud_upgrade|bool
|
||||
|
@ -12,6 +12,7 @@
|
||||
dest: "{{ working_dir }}/{{ item }}.sh"
|
||||
mode: 0775
|
||||
loop:
|
||||
- 'pre_undercloud_os_upgrade_workarounds'
|
||||
- 'pre_undercloud_upgrade_workarounds'
|
||||
- 'post_undercloud_upgrade_workarounds'
|
||||
when: upgrade_workarounds
|
||||
|
@ -5,7 +5,28 @@
|
||||
apply:
|
||||
tags: create_undercloud_upgrade_scripts
|
||||
tags: create_undercloud_upgrade_scripts
|
||||
when: upgrade_noop|bool or undercloud_upgrade|bool
|
||||
when: >
|
||||
upgrade_noop|bool or
|
||||
undercloud_upgrade|bool or
|
||||
undercloud_os_upgrade|bool
|
||||
|
||||
- block:
|
||||
- name: apply pre undercloud OS upgrade workarounds
|
||||
shell: |
|
||||
set -o pipefail
|
||||
bash {{ working_dir }}/pre_undercloud_os_upgrade_workarounds.sh 2>&1 {{ timestamper_cmd }} > pre_undercloud_os_upgrade_workarounds.log
|
||||
args:
|
||||
chdir: "{{ working_dir }}"
|
||||
when: upgrade_workarounds|bool
|
||||
|
||||
- name: Upgrade operating system
|
||||
become: true
|
||||
become_user: root
|
||||
import_tasks: undercloud_os_upgrade.yaml
|
||||
when: not use_oooq|bool
|
||||
|
||||
when: undercloud_os_upgrade|bool
|
||||
tags: undercloud_os_upgrade
|
||||
|
||||
- block:
|
||||
- name: apply pre undercloud upgrade workarounds
|
||||
|
53
tasks/upgrade/undercloud_os_upgrade.yaml
Normal file
53
tasks/upgrade/undercloud_os_upgrade.yaml
Normal file
@ -0,0 +1,53 @@
|
||||
---
|
||||
- name: Remove old RHEL7 packages
|
||||
shell: |
|
||||
yum -y remove *el7ost* -- \
|
||||
-*openvswitch* \
|
||||
-python2-babel \
|
||||
-python2-dateutil \
|
||||
-python2-ipaddress \
|
||||
-python2-jinja2 \
|
||||
-python2-markupsafe \
|
||||
-python2-jsonpatch \
|
||||
-python2-six \
|
||||
-python-PyMySQL \
|
||||
-python-jsonpointer
|
||||
|
||||
- name: Install leapp
|
||||
package:
|
||||
name: leapp
|
||||
state: latest
|
||||
|
||||
- name: Check if rhos-release is installed
|
||||
package:
|
||||
name: rhos-release
|
||||
state: present
|
||||
check_mode: true
|
||||
failed_when: false
|
||||
register: rhos_release_installed
|
||||
|
||||
- block:
|
||||
- name: Remove rhos-release repos
|
||||
command: rhos-release -x
|
||||
|
||||
- name: Remove conflicting rhos-release package
|
||||
package:
|
||||
name: rhos-release
|
||||
state: absent
|
||||
when:
|
||||
- rhos_release_installed.rc == 0
|
||||
- not rhos_release_installed.changed
|
||||
|
||||
- name: Run leapp upgrade (download packages)
|
||||
shell: |
|
||||
set -o pipefail
|
||||
leapp upgrade --debug 2>&1 | \
|
||||
tee {{ working_dir }}/undercloud_leapp_upgrade.log
|
||||
|
||||
- name: Reboot the undercloud
|
||||
import_tasks: ../common/undercloud_reboot.yaml
|
||||
|
||||
- name: Unregister the node once the OS was upgraded if desired
|
||||
redhat_subscription:
|
||||
state: absent
|
||||
when: leapp_unregister|bool
|
@ -45,6 +45,8 @@ apply_patch {{ value.basedir }} {{ value.id }}
|
||||
{% endif -%}
|
||||
{% endmacro -%}
|
||||
|
||||
{{ render_workarounds(pre_undercloud_os_upgrade_workarounds|default([]),'pre_undercloud_os_upgrade_workarounds') }}
|
||||
{# finish pre_undercloud_os_upgrade_workarounds #}
|
||||
{{ render_workarounds(pre_undercloud_upgrade_workarounds|default([]),'pre_undercloud_upgrade_workarounds') }}
|
||||
{# finish pre_undercloud_upgrade_workarounds #}
|
||||
{{ render_workarounds(post_undercloud_upgrade_workarounds|default([]),'post_undercloud_upgrade_workarounds') }}
|
||||
|
Loading…
Reference in New Issue
Block a user