From efe59fad32031b48e936041d48334ea44801f311 Mon Sep 17 00:00:00 2001 From: Andrei Zakabluk Date: Tue, 26 Oct 2021 15:03:11 +0200 Subject: [PATCH 1/4] devops-2525 added opportunity make GRANT --- tasks/postgres-zabbix-grants.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tasks/postgres-zabbix-grants.yml diff --git a/tasks/postgres-zabbix-grants.yml b/tasks/postgres-zabbix-grants.yml new file mode 100644 index 0000000..9e77545 --- /dev/null +++ b/tasks/postgres-zabbix-grants.yml @@ -0,0 +1,13 @@ +--- +- name: Add GRANT + become: yes + become_user: postgres + postgresql_privs: + db: "{{ item.1.db }}" + privs: "{{ item.1.privs }}" + type: "{{ item.1.type }}" + objs: "{{ item.1.objs }}" + schema: "{{ item.1.schema }}" + role: "{{ item.1.role }}" + loop: "{{ q('subelements', postgres_clusters, 'user_grants', {'skip_missing': True}) }}" + From 6bd8a440b11f9f0b97b44a8a3e74efc47dfa36f4 Mon Sep 17 00:00:00 2001 From: Andrei Zakabluk Date: Tue, 26 Oct 2021 15:03:11 +0200 Subject: [PATCH 2/4] devops-2525 added opportunity make GRANT --- tasks/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) 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 From 28cf380c52f81e783f9636a86c2a8a9e3279c281 Mon Sep 17 00:00:00 2001 From: Andrei Zakabluk Date: Thu, 28 Oct 2021 12:30:10 +0200 Subject: [PATCH 3/4] devops-2525 added opportunity make GRANT --- tasks/postgres-zabbix-grants.yml | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/tasks/postgres-zabbix-grants.yml b/tasks/postgres-zabbix-grants.yml index 9e77545..0ad7171 100644 --- a/tasks/postgres-zabbix-grants.yml +++ b/tasks/postgres-zabbix-grants.yml @@ -1,13 +1,24 @@ --- -- name: Add GRANT +- 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.1.db }}" - privs: "{{ item.1.privs }}" - type: "{{ item.1.type }}" - objs: "{{ item.1.objs }}" - schema: "{{ item.1.schema }}" - role: "{{ item.1.role }}" - loop: "{{ q('subelements', postgres_clusters, 'user_grants', {'skip_missing': True}) }}" - + db: "{{ item.db }}" + privs: "{{ item.privs }}" + type: "{{ item.type }}" + objs: "{{ item.objs }}" + schema: "{{ item.schema }}" + role: "{{ item.role }}" + with_items: "{{ users_with_pass }}" From 1df12d084c635eae5aed070914cf06047a44bb31 Mon Sep 17 00:00:00 2001 From: Andrei Zakabluk Date: Thu, 28 Oct 2021 12:37:43 +0200 Subject: [PATCH 4/4] devops-2525 added opportunity make GRANT --- tasks/postgres-zabbix-grants.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/postgres-zabbix-grants.yml b/tasks/postgres-zabbix-grants.yml index 0ad7171..800ba01 100644 --- a/tasks/postgres-zabbix-grants.yml +++ b/tasks/postgres-zabbix-grants.yml @@ -21,4 +21,4 @@ objs: "{{ item.objs }}" schema: "{{ item.schema }}" role: "{{ item.role }}" - with_items: "{{ users_with_pass }}" + with_items: "{{ all_users_grants }}"