mirror of
https://github.com/saltstack-formulas/postgres-formula.git
synced 2025-04-17 10:10:31 +00:00
Add support for database extensions.
This commit adds support for database extensions via salt.states.postgres_extension When configuring database pillar data all you need to do is add (optional) extension list with the extensions that you want the state to apply to specific database. Example: db1: owner: 'localUser' user: 'localUser' template: 'template0' lc_ctype: 'C.UTF-8' lc_collate: 'C.UTF-8' extensions: - uuid-ossp This will make sure `uuid-ossp` extension is enabled on `db1` database. Updated pillar.example to include (optional) extensions
This commit is contained in:
parent
c87fa54cbf
commit
d7580104f6
2 changed files with 16 additions and 2 deletions
|
@ -38,14 +38,18 @@ postgres:
|
||||||
template: 'template0'
|
template: 'template0'
|
||||||
lc_ctype: 'C.UTF-8'
|
lc_ctype: 'C.UTF-8'
|
||||||
lc_collate: 'C.UTF-8'
|
lc_collate: 'C.UTF-8'
|
||||||
|
# optional extensions to enable on database
|
||||||
|
extensions:
|
||||||
|
- uuid-ossp
|
||||||
db2:
|
db2:
|
||||||
owner: 'localUser'
|
owner: 'localUser'
|
||||||
user: 'remoteUser'
|
user: 'remoteUser'
|
||||||
template: 'template0'
|
template: 'template0'
|
||||||
lc_ctype: 'C.UTF-8'
|
lc_ctype: 'C.UTF-8'
|
||||||
lc_collate: 'C.UTF-8'
|
lc_collate: 'C.UTF-8'
|
||||||
|
# optional extensions to enable on database
|
||||||
|
extensions:
|
||||||
|
- postgis
|
||||||
# This section will append your configuration to postgresql.conf.
|
# This section will append your configuration to postgresql.conf.
|
||||||
postgresconf: |
|
postgresconf: |
|
||||||
listen_addresses = 'localhost,*'
|
listen_addresses = 'localhost,*'
|
||||||
|
|
|
@ -103,6 +103,16 @@ postgres-db-{{ name }}:
|
||||||
- require:
|
- require:
|
||||||
- postgres_user: postgres-user-{{ db.get('user') }}
|
- postgres_user: postgres-user-{{ db.get('user') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if db.extensions is defined %}
|
||||||
|
{% for ext in db.extensions %}
|
||||||
|
postgres-ext-{{ ext }}-for-db-{{ name }}:
|
||||||
|
postgres_extension.present:
|
||||||
|
- name: {{ ext }}
|
||||||
|
- user: {{ db.get('runas', 'postgres') }}
|
||||||
|
- maintenance_db: {{ name }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
{% endfor%}
|
{% endfor%}
|
||||||
|
|
||||||
{% for name, directory in postgres.tablespaces.items() %}
|
{% for name, directory in postgres.tablespaces.items() %}
|
||||||
|
|
Loading…
Add table
Reference in a new issue