mysql: refactor upgrade tasks to work without paunch
We are removing Paunch, and also Podman is the only container cli supported when it comes to upgrades, so this patch simplifies a bit how we deal with the upgrade of MySQL container. This submission also adds the path for the ansible modules installed from tripleo-ansible in the tht-check job. Change-Id: I8b01ac05bae6544119769e50501bf705b22081f3
This commit is contained in:
parent
c93fd13fef
commit
a4de1eac9d
@ -262,27 +262,14 @@ outputs:
|
||||
- name: Stop MySQL server and ensure redo log is cleaned up before upgrade
|
||||
when: step|int == 2
|
||||
block:
|
||||
- name: Retrieve mysql container configuration from paunch
|
||||
shell:
|
||||
str_replace:
|
||||
# Use a Jinja template below to force str_replace
|
||||
# to quote the resulting string
|
||||
template: &mysql_template '{{ "paunch" }} list --default-runtime RUNTIME -f json -c container -c image | jq -r ''.[] | select(.container=="mysql") + {"cli":"RUNTIME"}'''
|
||||
params:
|
||||
RUNTIME: "{{ container_cli }}"
|
||||
register: mysql_paunch
|
||||
- name: Retrieve mysql container configuration from paunch (docker)
|
||||
shell:
|
||||
str_replace:
|
||||
template: *mysql_template
|
||||
params:
|
||||
RUNTIME: "docker"
|
||||
register: mysql_paunch_docker
|
||||
when: '"mysql" not in mysql_paunch.stdout'
|
||||
- name: Mysql container facts
|
||||
- name: Get Mysql container image name before upgrade
|
||||
podman_container_info:
|
||||
name: mysql
|
||||
register: mysql_infos
|
||||
- name: Set fact for Mysql container image before upgrade
|
||||
set_fact:
|
||||
mysql_json: "{{ mysql_paunch_docker.stdout if mysql_paunch_docker.changed else mysql_paunch.stdout | from_json }}"
|
||||
- name: Mysql container image after upgrade
|
||||
pre_upgrade_mysql_image: "{{ mysql_infos.containers.0.ImageName }}"
|
||||
- name: Set fact for Mysql container image after upgrade
|
||||
set_fact:
|
||||
post_upgrade_mysql_image: {get_param: ContainerMysqlImage}
|
||||
- name: Redo log clean-up script
|
||||
@ -300,21 +287,21 @@ outputs:
|
||||
set_fact:
|
||||
mysql_clean_up_volumes: *mysql_volumes
|
||||
- name: Stop the current mysql container
|
||||
shell: |
|
||||
{{ mysql_json.cli }} update --restart=unless-stopped mysql
|
||||
{{ mysql_json.cli }} stop mysql
|
||||
when: mysql_json.image is defined and mysql_json.image != post_upgrade_mysql_image
|
||||
systemd:
|
||||
state: stopped
|
||||
name: tripleo_mysql
|
||||
when: pre_upgrade_mysql_image != post_upgrade_mysql_image
|
||||
- name: Clean up redo log by running a transient mysql server
|
||||
shell:
|
||||
str_replace:
|
||||
template:
|
||||
"{{ mysql_json.cli }} run --rm -u root --net=host ENV VOLUMES \"IMAGE\" /bin/bash -ecx \"SCRIPT\""
|
||||
"{{ container_cli }} run --rm -u root --net=host ENV VOLUMES \"IMAGE\" /bin/bash -ecx \"SCRIPT\""
|
||||
params:
|
||||
ENV: '-e "KOLLA_CONFIG_STRATEGY=COPY_ALWAYS"'
|
||||
IMAGE: "{{ mysql_json.image }}"
|
||||
IMAGE: "{{ pre_upgrade_mysql_image }}"
|
||||
VOLUMES: "-v {{ mysql_clean_up_volumes | join(' -v ') }}"
|
||||
SCRIPT: "{{ mysql_clean_up_script }}"
|
||||
when: mysql_json.image is defined and mysql_json.image != post_upgrade_mysql_image
|
||||
when: pre_upgrade_mysql_image != post_upgrade_mysql_image
|
||||
post_upgrade_tasks:
|
||||
- name: Check and upgrade Mysql database after major version upgrade
|
||||
command: "{{ container_cli }} exec -u root mysql mysql_upgrade"
|
||||
|
@ -21,10 +21,13 @@ def test_tht_ansible_syntax(pytestconfig):
|
||||
tht_root = str(pytestconfig.invocation_params.dir)
|
||||
role_path = os.path.join(tht_root,
|
||||
"tripleo_heat_templates/tests/roles/tripleo-ansible/tripleo-ansible/tripleo_ansible/roles")
|
||||
mod_path = os.path.join(tht_root,
|
||||
"tripleo_heat_templates/tests/roles/tripleo-ansible/tripleo-ansible/tripleo_ansible/ansible_plugins/modules")
|
||||
play_path = os.path.join(tht_root,
|
||||
"tripleo_heat_templates/tests/test_tht_ansible_syntax.yml")
|
||||
|
||||
os.environ["ANSIBLE_ROLES_PATH"] = role_path
|
||||
os.environ["ANSIBLE_LIBRARY"] = mod_path
|
||||
|
||||
run = ansible_runner.run(
|
||||
playbook=play_path,
|
||||
|
Loading…
x
Reference in New Issue
Block a user