Skip to content

Commit

Permalink
🐛 Update pod wait for new name. Use random file for sql dump
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Montleon <jmontleo@redhat.com>
  • Loading branch information
jmontleon committed Jul 23, 2024
1 parent 17fcf94 commit 0d3a49a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ collections:
version: "2.4.0"
- name: cloud.common
version: "2.1.1"
- name: community.general
version: "4.8.11"
12 changes: 8 additions & 4 deletions roles/tackle/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
kind: Pod
namespace: "{{ app_namespace }}"
label_selectors:
- app.kubernetes.io/name = {{ keycloak_database_service_name }}
- app.kubernetes.io/name = {{ keycloak_database_service_name }}-{{ keycloak_database_db_version }}
wait: true
wait_condition:
type: "Ready"
Expand Down Expand Up @@ -263,11 +263,15 @@
until: dst_ping.is_available and dst_ping.server_version.major == 15
delay: 10

- name: Generate keycloak random string
set_fact:
keycloak_random: "{{ lookup('community.general.random_string', special=false) }}"

- name: Dump database
postgresql_db:
state: dump
name: "{{ keycloak_database_db_name }}"
target: /tmp/keycloak.sql
target: /tmp/keycloak_{{ keycloak_random }}.sql
login_host: "{{ keycloak_database_service_k8s_resource_name }}"
login_user: "{{ dbm_user }}"
login_password: "{{ dbm_pass }}"
Expand All @@ -276,15 +280,15 @@
postgresql_db:
state: restore
name: "{{ keycloak_database_db_name }}"
target: /tmp/keycloak.sql
target: /tmp/keycloak_{{ keycloak_random }}.sql
login_host: "{{ keycloak_database_service_k8s_resource_name }}-migration"
login_user: "{{ dbm_user }}"
login_password: "{{ dbm_pass }}"

- name: Clean up database dump file
file:
state: absent
path: /tmp/keycloak.sql
path: /tmp/keycloak_{{ keycloak_random }}.sql

- name: "Remove the temporary migration service"
k8s:
Expand Down

0 comments on commit 0d3a49a

Please sign in to comment.