From 8edafaf7a4f9ebd0fe43134c952a11b8955d84c5 Mon Sep 17 00:00:00 2001 From: Roman Inflianskas Date: Mon, 2 Nov 2015 09:41:41 +0300 Subject: [PATCH 1/2] support schemas --- pillar.example | 3 +++ postgres/init.sls | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/pillar.example b/pillar.example index f3bdd05..8250e12 100644 --- a/pillar.example +++ b/pillar.example @@ -52,6 +52,9 @@ postgres: lc_ctype: 'C.UTF-8' lc_collate: 'C.UTF-8' # optional extensions to enable on database + schemas: + uuid_ossp: + owner: localUser extensions: - uuid-ossp db2: diff --git a/postgres/init.sls b/postgres/init.sls index c8577b9..a560774 100644 --- a/postgres/init.sls +++ b/postgres/init.sls @@ -118,6 +118,20 @@ postgres-db-{{ name }}: - postgres_user: postgres-user-{{ db.get('user') }} {% endif %} +{% if db.schemas is defined %} +{% for schema, schema_args in db.schemas.items() %} +postgres-schema-{{ schema }}-for-db-{{ name }}: + postgres_schema.present: + - name: {{ schema }} + - dbname: {{ name }} +{% if schema_args is not none %} +{% for arg, value in schema_args.items() %} + - {{ arg }}: {{ value }} +{% endfor %} +{% endif %} +{% endfor %} +{% endif %} + {% if db.extensions is defined %} {% for ext in db.extensions %} postgres-ext-{{ ext }}-for-db-{{ name }}: From 220473399098e2cb727f5920add68c27124892f1 Mon Sep 17 00:00:00 2001 From: Roman Inflianskas Date: Mon, 2 Nov 2015 09:41:41 +0300 Subject: [PATCH 2/2] support options in extensions --- pillar.example | 8 +++++--- postgres/init.sls | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pillar.example b/pillar.example index 8250e12..3cb072d 100644 --- a/pillar.example +++ b/pillar.example @@ -51,12 +51,14 @@ postgres: template: 'template0' lc_ctype: 'C.UTF-8' lc_collate: 'C.UTF-8' - # optional extensions to enable on database + # optional schemas to enable on database schemas: uuid_ossp: owner: localUser + # optional extensions to enable on database extensions: - - uuid-ossp + uuid-ossp: + schema: uuid_ossp db2: owner: 'localUser' user: 'remoteUser' @@ -65,7 +67,7 @@ postgres: lc_collate: 'C.UTF-8' # optional extensions to enable on database extensions: - - postgis + postgis: # This section will append your configuration to postgresql.conf. postgresconf: | listen_addresses = 'localhost,*' diff --git a/postgres/init.sls b/postgres/init.sls index a560774..e8559b3 100644 --- a/postgres/init.sls +++ b/postgres/init.sls @@ -133,12 +133,17 @@ postgres-schema-{{ schema }}-for-db-{{ name }}: {% endif %} {% if db.extensions is defined %} -{% for ext in db.extensions %} +{% for ext, ext_args in db.extensions.items() %} postgres-ext-{{ ext }}-for-db-{{ name }}: postgres_extension.present: - name: {{ ext }} - user: {{ db.get('runas', 'postgres') }} - maintenance_db: {{ name }} +{% if ext_args is not none %} +{% for arg, value in ext_args.items() %} + - {{ arg }}: {{ value }} +{% endfor %} +{% endif %} {% endfor %} {% endif %} {% endfor%}