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' ]
|
|
|
|
|
|
|
|
- name: Only set a db user password. Mostly for the postgresql user
|
|
|
|
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
|
|
|
|