Add database name into ID of init queries
This change allow execute queries, defined in separate
configuration files between different DBs
Change-Id: I32158f8c8f73edb1a107adaff7fdae77547c3dc4
diff --git a/postgresql/_database.sls b/postgresql/_database.sls
index 0fe6fe6..7771878 100644
--- a/postgresql/_database.sls
+++ b/postgresql/_database.sls
@@ -48,16 +48,16 @@
{%- if database.init is defined %}
{%- for query in database.init.get('queries', []) %}
{% set maintenance_db = database.init.get('maintenance_db', database_name) %}
-postgresql_database_{{ svr_name|default('localhost') }}_{{ maintenance_db }}_{{ loop.index }}:
+postgresql_database_{{ svr_name|default('localhost') }}_{{ database_name }}_{{ maintenance_db }}_{{ loop.index }}:
cmd.run:
- name: "psql -h {{ admin.get('host', 'localhost') }} \
-U {{ admin.get('user', 'root') }} \
-d {{ maintenance_db }} \
-c \"{{ query }} \" "
- env:
+ env:
PGPASSWORD: {{ admin.get('password', '') }}
{%- if not database.init.get('force', false) == true %}
- onchanges:
+ onchanges:
- postgres_database: postgresql_database_{{ svr_name|default('localhost') }}_{{ maintenance_db }}
{%- endif %}
require:
@@ -69,7 +69,7 @@
postgresql_database_{{ svr_name|default('localhost') }}_{{ database_name }}_{{ name }}:
{%- if extension.get('enabled', true) %}
postgres_extension.present:
- - schema: {{ extension.get('schema', 'public') }}
+ - schema: {{ extension.get('schema', 'public') }}
{%- else %}
postgres_extension.absent:
{%- endif %}