mirror of
https://github.com/saltstack-formulas/postgres-formula.git
synced 2025-04-16 01:30:25 +00:00
Fixed problems with per database extensions and schemas
This commit is contained in:
parent
d9c071a547
commit
b20a8e77b4
1 changed files with 21 additions and 3 deletions
|
@ -44,7 +44,25 @@ postgres-reload-modules:
|
||||||
# Database states
|
# Database states
|
||||||
|
|
||||||
{%- for name, db in postgres.databases|dictsort() %}
|
{%- for name, db in postgres.databases|dictsort() %}
|
||||||
|
{%- if 'extensions' in db %}
|
||||||
|
{%- for ext_name, extension in db.pop('extensions')|dictsort() %}
|
||||||
|
{%- do extension.update({'maintenance_db': name }) %}
|
||||||
|
{{ format_state( name + '-' + ext_name, 'postgres_extension', extension) }}
|
||||||
|
- require:
|
||||||
|
- postgres_database: postgres_database-{{ name }}
|
||||||
|
{%- if 'schema' in extension %}
|
||||||
|
- postgres_schema: postgres_schema-{{ extension.schema }}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- if 'schemas' in db %}
|
||||||
|
{%- for schema_name, schema in db.pop('schemas')|dictsort() %}
|
||||||
|
{%- do schema.update({'dbname': name }) %}
|
||||||
|
{{ format_state( schema_name, 'postgres_schema', schema) }}
|
||||||
|
- require:
|
||||||
|
- postgres_database: postgres_database-{{ name }}
|
||||||
|
{%- endfor %}
|
||||||
|
{%- endif %}
|
||||||
{{ format_state(name, 'postgres_database', db) }}
|
{{ format_state(name, 'postgres_database', db) }}
|
||||||
{%- if 'owner' in db or 'tablespace' in db %}
|
{%- if 'owner' in db or 'tablespace' in db %}
|
||||||
- require:
|
- require:
|
||||||
|
@ -55,7 +73,6 @@ postgres-reload-modules:
|
||||||
{%- if 'tablespace' in db %}
|
{%- if 'tablespace' in db %}
|
||||||
- postgres_tablespace: postgres_tablespace-{{ db.tablespace }}
|
- postgres_tablespace: postgres_tablespace-{{ db.tablespace }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
# Schema states
|
# Schema states
|
||||||
|
@ -63,8 +80,9 @@ postgres-reload-modules:
|
||||||
{%- for name, schema in postgres.schemas|dictsort() %}
|
{%- for name, schema in postgres.schemas|dictsort() %}
|
||||||
|
|
||||||
{{ format_state(name, 'postgres_schema', schema) }}
|
{{ format_state(name, 'postgres_schema', schema) }}
|
||||||
{%- if 'owner' in schema %}
|
|
||||||
- require:
|
- require:
|
||||||
|
- postgres_database-{{ dbname }}
|
||||||
|
{%- if 'owner' in schema %}
|
||||||
- postgres_user: postgres_user-{{ schema.owner }}
|
- postgres_user: postgres_user-{{ schema.owner }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue