1 #####################################
2 ### someone's ansible provisioner ###
3 #####################################
4 # Part of: https://git.somenet.org/root/pub/somesible.git
5 # 2017-2024 by someone <someone@somenet.org>
7 # You likely want to use the other pg-db role.
8 # pg has a broken permission system -> many take-own needed - or just dont care.
11 - name: ensure pg group "grp_{{pg_data.dbname}}_owner" exists
14 name: "grp_{{pg_data.dbname}}_owner"
15 role_attr_flags: "NOLOGIN,NOSUPERUSER,INHERIT,NOCREATEDB,NOCREATEROLE,NOREPLICATION"
18 - name: create db "{{pg_data.dbname}}"
19 become_user: "postgres"
21 name: "{{pg_data.dbname}}"
22 owner: "grp_{{pg_data.dbname}}_owner"
25 - name: set owner of schema "{{pg_data.dbname}}.public"
26 become_user: "postgres"
28 database: "{{pg_data.dbname}}"
30 owner: "grp_{{pg_data.dbname}}_owner"
33 - name: revoke privs for PUBLIC on db "{{pg_data.dbname}}"
36 db: "{{pg_data.dbname}}"
43 - name: revoke privs for PUBLIC on schema "{{pg_data.dbname}}.public"
46 db: "{{pg_data.dbname}}"
54 - name: ensure group grp_spectator exists and grant necessary privs on db "{{pg_data.dbname}}"
58 role_attr_flags: "NOLOGIN,NOSUPERUSER,INHERIT,NOCREATEDB,NOCREATEROLE,NOREPLICATION"
59 db: "{{pg_data.dbname}}"
60 priv: CONNECT,TEMPORARY
63 - name: ensure pg user "usr_{{pg_data.dbname}}" exists
66 name: "usr_{{pg_data.dbname}}"
67 password: "{{pg_data.pw}}"
68 when: pg_data.dbname != "" and pg_data.pw != ""
71 - name: add user "usr_{{pg_data.dbname}}" to group "grp_{{pg_data.dbname}}_owner"
74 # always use postgres here
76 role: "usr_{{pg_data.dbname}}"
77 objs: "grp_{{pg_data.dbname}}_owner"
79 when: pg_data.dbname != "" and pg_data.pw != ""