Last active
January 29, 2021 09:19
-
-
Save jfrancoa/2cf943e925b6061f4df0eda0e1fb14dc to your computer and use it in GitHub Desktop.
Ansible playbook to apply a hotfix for a determined container in the Undercloud
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
vars: | |
# working_dir: The home directory from where the script is being triggered, usually the Undercloud's /home/stack | |
working_dir: "/home/stack" | |
# rc_file: RC file for the undercloud | |
rc_file: "stackrc" | |
# hotfix_tag: Tag used to identify the built image for the hotfix, this tag will be appended to the existing container tag | |
hotfix_tag: "hotfix_bz1911653" | |
# hotfix_rpm_dir: Location for the RPMS required for the hoftix | |
hotfix_rpm_dir: "/home/stack/hotfix_bz1911653" | |
# hotfix_rpm_url: List with the URL for all the RPMs to be dowloaded in hotfix_rpm_dir | |
hotfix_rpm_url: | |
- "http://download.eng.bos.redhat.com/brewroot/vol/rhel-8/packages/openstack-tripleo-common/11.4.1/1.20200917023446.bz1911653.el8ost/noarch/openstack-tripleo-common-11.4.1-1.20200917023446.bz1911653.el8ost.noarch.rpm" | |
- "http://download.eng.bos.redhat.com/brewroot/vol/rhel-8/packages/openstack-tripleo-common/11.4.1/1.20200917023446.bz1911653.el8ost/noarch/openstack-tripleo-common-container-base-11.4.1-1.20200917023446.bz1911653.el8ost.noarch.rpm" | |
- "http://download.eng.bos.redhat.com/brewroot/vol/rhel-8/packages/openstack-tripleo-common/11.4.1/1.20200917023446.bz1911653.el8ost/noarch/openstack-tripleo-common-containers-11.4.1-1.20200917023446.bz1911653.el8ost.noarch.rpm" | |
- "http://download.eng.bos.redhat.com/brewroot/vol/rhel-8/packages/openstack-tripleo-common/11.4.1/1.20200917023446.bz1911653.el8ost/noarch/openstack-tripleo-common-devtools-11.4.1-1.20200917023446.bz1911653.el8ost.noarch.rpm" | |
- "http://download.eng.bos.redhat.com/brewroot/vol/rhel-8/packages/openstack-tripleo-common/11.4.1/1.20200917023446.bz1911653.el8ost/noarch/python3-tripleo-common-11.4.1-1.20200917023446.bz1911653.el8ost.noarch.rpm" | |
# container: Name of the container to be patched | |
container: "mistral_executor" | |
# container_param: Name of the Heat parameter used to identify the image. This name corresponds to the container | |
# image name joined (removing underscore) and with the first letter of each word in capital letters: | |
# Ex: mistral_executor -> MistralExecutor, heat_api -> HeatApi, nova_compute -> NovaCompute | |
container_param: "MistralExecutor" | |
tasks: | |
- name: Make sure directory to store the rpms exists | |
file: | |
path: "{{ hotfix_rpm_dir }}" | |
state: directory | |
mode: '0755' | |
tags: always | |
- name: Retrieve full container fqdn | |
become: true | |
command: "podman inspect --format \\{\\{.ImageName\\}\\} {{ container }}" | |
register: container_fqdn | |
tags: always | |
- block: | |
- name: Download hotfix rpms | |
get_url: | |
url: "{{ item }}" | |
dest: "{{ hotfix_rpm_dir }}/{{ item | basename }}" | |
loop: "{{ hotfix_rpm_url }}" | |
tags: rpm_download | |
- name: Execute hotfix command | |
shell: | | |
set -o pipefail | |
source {{ working_dir }}/{{ rc_file }} | |
openstack tripleo container image hotfix --image {{ container_fqdn.stdout }} \ | |
--rpms-path {{ hotfix_rpm_dir }} --tag {{ hotfix_tag }} | |
- name: Check if the new image is available | |
become: true | |
shell: "buildah images | grep {{ hotfix_tag }}" | |
- name: Push image to the registry | |
become: true | |
shell: | | |
set -o pipefail | |
source {{ working_dir}}/{{ rc_file }} | |
openstack tripleo container image push --local --registry-url {{ container_fqdn.stdout.split('/') | first }} \ | |
{{ container_fqdn.stdout }}-{{ hotfix_tag }} | |
tags: build_image | |
- name: Create parameters file | |
shell: | | |
cat <<EOF > {{ working_dir }}/{{ hotfix_tag }}.yaml | |
parameter_defaults: | |
Container{{ container_param }}Image: {{ container_fqdn.stdout }}-{{ hotfix_tag }} | |
EOF | |
tags: config_hotfix | |
- name: Add parameter to undercloud.conf | |
ini_file: | |
path: "{{ working_dir }}/undercloud.conf" | |
backup: true | |
section: DEFAULT | |
option: custom_env_files | |
value: "{{ working_dir }}/{{ hotfix_tag }}.yaml" | |
tags: config_hotfix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment