2015-10-04 20:18:44 +02:00
|
|
|
include:
|
|
|
|
- postgresql-server
|
|
|
|
|
|
|
|
gnuviechadmin-database:
|
|
|
|
postgres_user.present:
|
2016-01-29 18:34:40 +01:00
|
|
|
- name: {{ salt['pillar.get']('gnuviechadmin:database:owner:user') }}
|
2015-10-04 20:18:44 +02:00
|
|
|
- user: postgres
|
2016-01-29 18:34:40 +01:00
|
|
|
- password: {{ salt['pillar.get']('gnuviechadmin:database:owner:password') }}
|
2015-10-04 20:18:44 +02:00
|
|
|
- login: True
|
2015-10-11 15:28:23 +02:00
|
|
|
- createdb: {% if salt['pillar.get']('gnuviechadmin:deploymenttype', 'production') == 'local' %}True
|
|
|
|
{%- else %}False
|
|
|
|
{%- endif %}
|
2015-10-04 20:18:44 +02:00
|
|
|
- require:
|
|
|
|
- service: postgresql
|
|
|
|
postgres_database.present:
|
2016-01-29 18:34:40 +01:00
|
|
|
- name: {{ salt['pillar.get']('gnuviechadmin:database:name') }}
|
2015-10-04 20:18:44 +02:00
|
|
|
- user: postgres
|
2016-01-29 18:34:40 +01:00
|
|
|
- owner: {{ salt['pillar.get']('gnuviechadmin:database:owner:user') }}
|
2015-10-04 20:18:44 +02:00
|
|
|
- encoding: UTF8
|
|
|
|
- template: template0
|
|
|
|
- require:
|
|
|
|
- service: postgresql
|
2016-01-29 18:34:40 +01:00
|
|
|
- postgres_user: {{ salt['pillar.get']('gnuviechadmin:database:owner:user') }}
|
2015-10-04 20:18:44 +02:00
|
|
|
|
2016-01-29 18:34:40 +01:00
|
|
|
{% for gnuviechadmin_db_role in salt['pillar.get']('gnuviechadmin:database:users') %}
|
2015-10-04 20:18:44 +02:00
|
|
|
gnuviechadmin-dbuser-{{ gnuviechadmin_db_role }}:
|
|
|
|
postgres_user.present:
|
2016-01-29 18:34:40 +01:00
|
|
|
- name: {{ salt['pillar.get']('gnuviechadmin:database:users:%s:user' % gnuviechadmin_db_role) }}
|
|
|
|
- password: {{ salt['pillar.get']('gnuviechadmin:database:users:%s:password' % gnuviechadmin_db_role) }}
|
2015-10-04 20:18:44 +02:00
|
|
|
- login: True
|
|
|
|
- require:
|
|
|
|
- service: postgresql
|
|
|
|
{% endfor %}
|