2015-05-28 11:32:57 +02:00
|
|
|
---
|
|
|
|
- name: Add a user for the postgresql DBs
|
2016-01-25 18:11:43 +01:00
|
|
|
become: True
|
|
|
|
become_user: postgres
|
2016-09-13 16:34:08 +02:00
|
|
|
postgresql_user: user={{ item.user }} password={{ item.pwd }} role_attr_flags={{ item.roles }} port={{ psql_db_port }} state={{ item.userstate | default('present') }}
|
2016-10-05 17:54:14 +02:00
|
|
|
with_items: '{{ psql_db_data | default(omit) }}'
|
2016-06-09 16:47:45 +02:00
|
|
|
when: item.roles is defined
|
2016-01-25 18:11:43 +01:00
|
|
|
tags: [ 'postgresql', 'postgres', 'pg_db' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
2016-09-13 16:34:08 +02:00
|
|
|
- name: Add the databases with the correct owner. Or remove them, if not used anymore
|
2016-01-25 18:11:43 +01:00
|
|
|
become: True
|
|
|
|
become_user: postgres
|
2016-09-13 16:34:08 +02:00
|
|
|
postgresql_db: db={{ item.name }} port={{ psql_db_port }} encoding={{ item.encoding }} owner={{ item.user }} template=template0 state={{ item.state | default('present') }}
|
2016-10-05 17:54:14 +02:00
|
|
|
with_items: '{{ psql_db_data | default(omit) }}'
|
2016-10-20 17:10:17 +02:00
|
|
|
when: item.managedb | default(True)
|
2016-06-09 16:47:45 +02:00
|
|
|
tags: [ 'postgresql', 'postgres', 'pg_db' ]
|
|
|
|
|
2017-12-08 11:25:48 +01:00
|
|
|
- name: Add schemas to a database.
|
|
|
|
become: True
|
|
|
|
become_user: postgres
|
|
|
|
postgresql_schema: database={{ item.0.name }} port={{ psql_db_port }} name={{ item.1 }} owner={{ item.0.user }} state={{ item.0.schemastate | default('present') }}
|
|
|
|
with_subelements:
|
|
|
|
- '{{ psql_db_data | default([]) }}'
|
|
|
|
- schema
|
|
|
|
when: item.manageschema | default(False)
|
|
|
|
tags: [ 'postgresql', 'postgres', 'pg_db', 'pg_schema' ]
|
|
|
|
|
2016-11-28 19:40:00 +01:00
|
|
|
- name: Define a user with password, with no associated DBs
|
2016-06-09 16:47:45 +02:00
|
|
|
become: True
|
|
|
|
become_user: postgres
|
|
|
|
postgresql_user: user={{ item.user }} password={{ item.pwd }} port={{ psql_db_port }}
|
2016-10-05 17:54:14 +02:00
|
|
|
with_items: '{{ psql_db_data | default(omit) }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
when:
|
2016-06-09 16:47:45 +02:00
|
|
|
- item.pwd is defined
|
|
|
|
- item.roles is not defined
|
2016-01-25 18:11:43 +01:00
|
|
|
tags: [ 'postgresql', 'postgres', 'pg_db' ]
|
2016-03-07 17:43:37 +01:00
|
|
|
|