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 ###########################################################
8 # DO NOT FORGET TO UPDATE POSTGRESQL.CONF - CLUSTER PATHS #
9 ###########################################################
10 # YOU WILL KILL THE LIVE-CLUSTER OTHERWISE! #
11 #############################################
13 - name: install postgresql
17 - postgresql-15-postgis-3
24 ignore_errors: "{{ignore_online_errors | bool}}"
27 - name: copy postgresql.conf
30 dest: "/etc/postgresql/15/main/postgresql.conf"
35 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/postgresql.conf"
36 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/postgresql.conf"
37 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/postgresql.conf"
38 - "default/postgresql.conf"
39 notify: restart postgresql.service
42 - name: copy pg_hba.conf
45 dest: "/etc/postgresql/15/main/pg_hba.conf"
50 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/pg_hba.conf"
51 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/pg_hba.conf"
52 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/pg_hba.conf"
53 - "default/pg_hba.conf"
54 notify: restart postgresql.service
57 - name: create logrotate entry for postgresql
60 dest: "/etc/logrotate.d/postgresql-common"
65 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/postgresql-common.logrotate"
66 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/postgresql-common.logrotate"
67 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/postgresql-common.logrotate"
68 - "default/postgresql-common.logrotate"
71 - name: enable and start postgresql.service
72 include_role: name="base/systemd/enable-and-start"
74 service_name: postgresql.service
77 - name: set superuser password
81 password: "{{postgresql_postgres_pw}}"
84 when: postgresql_postgres_pw != ""
87 - name: ensure group grp_spectator exists and grant necessary privs on db postgres
91 role_attr_flags: "NOLOGIN,NOSUPERUSER,INHERIT,NOCREATEDB,NOCREATEROLE,NOREPLICATION"
93 priv: CONNECT,TEMPORARY
96 - name: revoke unnecessary privs for PUBLIC on db postgres
106 - name: grant necessary privs for PUBLIC on db postgres
107 become_user: postgres
110 privs: CONNECT,TEMPORARY
115 - name: revoke ALL privs for PUBLIC on schema "postgres.public"
116 become_user: postgres