File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -30,4 +30,6 @@ restore_resource_requirements:
3030set_self_labels : true
3131
3232spec_overrides : {}
33+
34+ force_drop_db : false
3335...
Original file line number Diff line number Diff line change 7272- name : Set pg_restore command
7373 set_fact :
7474 pg_restore : >-
75- pg_restore --clean --if-exists --no-owner --no-acl
75+ pg_restore {{ force_drop_db | bool | ternary('', ' --clean --if-exists') }} --no-owner --no-acl
7676 -U {{ eda_postgres_user }}
7777 -h {{ resolvable_db_host }}
7878 -d {{ eda_postgres_database }}
7979 -p {{ eda_postgres_port }}
8080 no_log : " {{ no_log }}"
8181
82+ - name : Grant CREATEDB privilege to database user for force_drop_db
83+ kubernetes.core.k8s_exec :
84+ namespace : " {{ ansible_operator_meta.namespace }}"
85+ pod : " {{ postgres_pod_name }}"
86+ container : postgres
87+ command : >-
88+ psql -c "ALTER USER {{ eda_postgres_user }} CREATEDB;"
89+ when :
90+ - force_drop_db | bool
91+ - eda_postgres_type == 'managed'
92+
8293- name : Force drop and create database if force_drop_db is true
8394 block :
8495 - name : Set drop db command
138149 "
139150 register : data_migration
140151 no_log : " {{ no_log }}"
152+
153+ - name : Revoke CREATEDB privilege from database user
154+ kubernetes.core.k8s_exec :
155+ namespace : " {{ ansible_operator_meta.namespace }}"
156+ pod : " {{ postgres_pod_name }}"
157+ container : postgres
158+ command : >-
159+ psql -c "ALTER USER {{ eda_postgres_user }} NOCREATEDB;"
160+ when :
161+ - force_drop_db | bool
162+ - eda_postgres_type == 'managed'
Original file line number Diff line number Diff line change @@ -8,5 +8,4 @@ _postgres_image_version: latest
88backup_api_version : ' {{ deployment_type }}.ansible.com/v1alpha1'
99backup_kind : ' EDABackup'
1010
11- force_drop_db : false
1211pg_drop_create : ' '
You can’t perform that action at this time.
0 commit comments