forked from ISTI-ansible-roles/ansible-roles
28 lines
1.0 KiB
YAML
28 lines
1.0 KiB
YAML
---
|
|
- name: Add a user for the postgresql DBs
|
|
become: True
|
|
become_user: postgres
|
|
postgresql_user: user={{ item.user }} password={{ item.pwd }} role_attr_flags={{ item.roles }} port={{ psql_db_port }}
|
|
with_items: '{{ psql_db_data }}'
|
|
when: item.roles is defined
|
|
tags: [ 'postgresql', 'postgres', 'pg_db' ]
|
|
|
|
- name: Add the databases with the correct owner
|
|
become: True
|
|
become_user: postgres
|
|
postgresql_db: db={{ item.name }} port={{ psql_db_port }} encoding={{ item.encoding }} owner={{ item.user }} template=template0 state=present
|
|
with_items: '{{ psql_db_data }}'
|
|
when: ( item.createdb is not defined or item.createdb )
|
|
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 }}
|
|
with_items: '{{ psql_db_data }}'
|
|
when:
|
|
- item.pwd is defined
|
|
- item.roles is not defined
|
|
tags: [ 'postgresql', 'postgres', 'pg_db' ]
|
|
|