From a15fdd5b9ab850ff1ddbee9cc3b93e8c2133e19c Mon Sep 17 00:00:00 2001 From: Bohdan Dobrelia Date: Tue, 12 Sep 2023 16:31:03 +0200 Subject: [PATCH] Filter by mariadb services cluster IPs instead Filtered pod IP may change, if pod restarts. Use the service cluster IP which never changes. Signed-off-by: Bohdan Dobrelia --- docs/openstack/mariadb_copy.md | 4 ++-- tests/roles/mariadb_copy/tasks/main.yaml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/openstack/mariadb_copy.md b/docs/openstack/mariadb_copy.md index c33da6601..daf251d68 100644 --- a/docs/openstack/mariadb_copy.md +++ b/docs/openstack/mariadb_copy.md @@ -37,8 +37,8 @@ just illustrative, use values that are correct for your environment: ``` MARIADB_IMAGE=quay.io/podified-antelope-centos9/openstack-mariadb:current-podified -PODIFIED_MARIADB_IP=$(oc get -o yaml pod mariadb-openstack | grep podIP: | awk '{ print $2; }') -PODIFIED_CELL1_MARIADB_IP=$(oc get -o yaml pod mariadb-openstack-cell1 | grep podIP: | awk '{ print $2; }') +PODIFIED_MARIADB_IP=$(oc get svc --selector "cr=mariadb-openstack" -ojsonpath='{.items[0].spec.clusterIP}') +PODIFIED_CELL1_MARIADB_IP=$(oc get svc --selector "cr=mariadb-openstack-cell1" -ojsonpath='{.items[0].spec.clusterIP}') PODIFIED_DB_ROOT_PASSWORD=$(oc get -o json secret/osp-secret | jq -r .data.DbRootPassword | base64 -d) # Replace with your environment's MariaDB IP: diff --git a/tests/roles/mariadb_copy/tasks/main.yaml b/tests/roles/mariadb_copy/tasks/main.yaml index e7422bea7..65f81c609 100644 --- a/tests/roles/mariadb_copy/tasks/main.yaml +++ b/tests/roles/mariadb_copy/tasks/main.yaml @@ -1,15 +1,15 @@ -- name: get podified MariaDB IP +- name: get podified MariaDB service cluster IP ansible.builtin.shell: | {{ shell_header }} {{ oc_header }} - oc get -o yaml pod mariadb-openstack | grep podIP: | awk '{ print $2; }' + oc get svc --selector "cr=mariadb-openstack" -ojsonpath='{.items[0].spec.clusterIP}' register: podified_mariadb_ip_result - name: get podified cell1 MariaDB IP ansible.builtin.shell: | {{ shell_header }} {{ oc_header }} - oc get -o yaml pod mariadb-openstack-cell1 | grep podIP: | awk '{ print $2; }' + oc get svc --selector "cr=mariadb-openstack-cell1" -ojsonpath='{.items[0].spec.clusterIP}' register: podified_cell1_mariadb_ip_result - name: set MariaDB copy shell vars @@ -51,4 +51,4 @@ no_log: "{{ use_no_log }}" ansible.builtin.shell: cmd: "{{ lookup('ansible.builtin.template', 'post_checks.bash') }}" - \ No newline at end of file +