diff --git a/tasks/main.yml b/tasks/main.yml index 68d013a..a407a54 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -60,3 +60,9 @@ tags: - postgres - postgres-pgupgrades + +- include: postgres-zabbix-grants.yml + when: postgres_monitoring is true + tags: + - postgres + - postgres_grant diff --git a/tasks/postgres-zabbix-grants.yml b/tasks/postgres-zabbix-grants.yml new file mode 100644 index 0000000..800ba01 --- /dev/null +++ b/tasks/postgres-zabbix-grants.yml @@ -0,0 +1,24 @@ +--- +- name: Create list of grants + vars: + users_grants: "{{ item.1.grants }}" + set_fact: + all_users_grants: "{{ all_users_grants | default([]) + [users_grants] }}" + loop: "{{ q('subelements', postgres_clusters, 'users', {'skip_missing': True}) }}" + when: item.1.grants is defined + +#- name: Show result +# debug: +# var: all_users_grants + +- name: Add GRANTs for users + become: yes + become_user: postgres + postgresql_privs: + db: "{{ item.db }}" + privs: "{{ item.privs }}" + type: "{{ item.type }}" + objs: "{{ item.objs }}" + schema: "{{ item.schema }}" + role: "{{ item.role }}" + with_items: "{{ all_users_grants }}"