mirror of
https://github.com/saltstack-formulas/postgres-formula.git
synced 2025-04-16 01:30:25 +00:00
Merge pull request #223 from jdsieci/fix_per_database_extensions_schemas
Fixed problems with per database extensions and schemas #140
This commit is contained in:
commit
8dfba2abdc
2 changed files with 28 additions and 2 deletions
|
@ -12,7 +12,9 @@
|
|||
|
||||
{%- macro format_state(name, state, kwarg) %}
|
||||
|
||||
{%- if 'name' not in kwarg %}
|
||||
{%- do kwarg.update({'name': name}) %}
|
||||
{%- endif %}
|
||||
{%- if 'ensure' in kwarg %}
|
||||
{%- set ensure = kwarg.pop('ensure') %}
|
||||
{%- endif %}
|
||||
|
|
|
@ -44,6 +44,29 @@ 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({'name': ext_name, '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({'name': schema_name, 'dbname': name }) %}
|
||||
|
||||
{{ format_state( name + '-' + 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 %}
|
||||
|
@ -63,8 +86,9 @@ postgres-reload-modules:
|
|||
{%- for name, schema in postgres.schemas|dictsort() %}
|
||||
|
||||
{{ format_state(name, 'postgres_schema', schema) }}
|
||||
{%- if 'owner' in schema %}
|
||||
- require:
|
||||
- postgres_database-{{ schema.dbname }}
|
||||
{%- if 'owner' in schema %}
|
||||
- postgres_user: postgres_user-{{ schema.owner }}
|
||||
{%- endif %}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue