postgresql: add a task to manage user privileges.

This commit is contained in:
Andrea Dell'Amico 2017-12-18 18:44:17 +01:00
parent 100219e8d9
commit 6bc7abf963
1 changed files with 9 additions and 1 deletions

View File

@ -5,7 +5,7 @@
postgresql_user: user={{ item.user }} password={{ item.pwd }} role_attr_flags={{ item.roles }} port={{ psql_db_port }} state={{ item.userstate | default('present') }}
with_items: '{{ psql_db_data | default(omit) }}'
when: item.roles is defined
tags: [ 'postgresql', 'postgres', 'pg_db' ]
tags: [ 'postgresql', 'postgres', 'pg_db', 'pg_user' ]
- name: Add the databases with the correct owner. Or remove them, if not used anymore
become: True
@ -15,6 +15,14 @@
when: item.managedb | default(True)
tags: [ 'postgresql', 'postgres', 'pg_db' ]
- name: Manage users privileges
become: True
become_user: postgres
postgresql_privs: db={{ item.name }} privs={{ item.privs }} type=database roles={{ item.roles }} port={{ psql_db_port }} state={{ item.userstate | default('present') }}
with_items: '{{ psql_db_privs | default(omit) }}'
when: psql_db_privs is defined
tags: [ 'postgresql', 'postgres', 'pg_db', 'pg_user' ]
# - name: Add schemas to a database.
# become: True
# become_user: postgres