Fixed problems with per database extensions and schemas

This commit is contained in:
Jerzy Drozdz 2018-06-14 23:46:58 +02:00
parent d9c071a547
commit b20a8e77b4

View file

@ -44,7 +44,25 @@ postgres-reload-modules:
# Database states
{%- 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) }}
{%- if 'owner' in db or 'tablespace' in db %}
- require:
@ -55,7 +73,6 @@ postgres-reload-modules:
{%- if 'tablespace' in db %}
- postgres_tablespace: postgres_tablespace-{{ db.tablespace }}
{%- endif %}
{%- endfor %}
# Schema states
@ -63,8 +80,9 @@ postgres-reload-modules:
{%- for name, schema in postgres.schemas|dictsort() %}
{{ format_state(name, 'postgres_schema', schema) }}
{%- if 'owner' in schema %}
- require:
- postgres_database-{{ dbname }}
{%- if 'owner' in schema %}
- postgres_user: postgres_user-{{ schema.owner }}
{%- endif %}