Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ postgresql_env:
LC_ALL: "{{ postgresql_locale }}"
LC_LCTYPE: "{{ postgresql_locale }}"

postgresql_linux_admin_user: '"/^(root|postgres)$"'
postgresql_admin_user: "postgres"
postgresql_default_auth_method: "peer"
postgresql_default_auth_method_hosts: "{{ 'scram-sha-256' if postgresql_version is version_compare('14', '>=') else 'md5' }}" # (>=14.0 scram-sha-256 is default value)

# The description that will use to customize process or service description
postgresql_service_description: "PostgreSQL RDBMS"

# The user/group that will run postgresql process or service
postgresql_service_user: "{{ postgresql_admin_user }}"
postgresql_service_user_pgsql_profile: false
Expand Down Expand Up @@ -79,10 +83,10 @@ postgresql_user_privileges: []

# pg_hba.conf
postgresql_pg_hba_default:
- { type: local, database: all, user: all, address: "", method: "{{ postgresql_default_auth_method }}", comment: '"local" is for Unix domain socket connections only' }
- { type: host, database: all, user: all, address: "127.0.0.1/32", method: "{{ postgresql_default_auth_method_hosts }}", comment: "IPv4 local connections:" }
- { type: host, database: all, user: all, address: "::1/128", method: "{{ postgresql_default_auth_method_hosts }}", comment: "IPv6 local connections:" }
- { type: local, database: all, user: "{{ postgresql_admin_user }}", address: "", method: "peer map=root_as_{{ postgresql_admin_user }}", comment: "Local root Unix user, passwordless access" }
- { type: local, database: all, user: all, address: "", method: "{{ postgresql_default_auth_method }}", comment: '"local" is for Unix domain socket connections only' }

postgresql_pg_hba_md5_hosts: []
postgresql_pg_hba_passwd_hosts: []
Expand All @@ -93,7 +97,7 @@ postgresql_pg_hba_custom: []
postgresql_pg_ident:
- comment: "root is allowed to login as {{ postgresql_admin_user }}"
mapname: "root_as_{{ postgresql_admin_user }}"
system_username: "{{ postgresql_admin_user }}"
system_username: "{{ postgresql_linux_admin_user }}"
pg_username: "{{ postgresql_admin_user }}"

# postgresql.conf
Expand Down
2 changes: 1 addition & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
state: restarted
enabled: yes

- name: Reload systemd daemon
- name: reload service daemon
ansible.builtin.command: systemctl daemon-reload
become: true
10 changes: 10 additions & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,16 @@
register: postgresql_systemd_custom_conf
notify: restart postgresql

- name: PostgreSQL | Use the conf directory when starting the Postgres service | Debian
template:
src: etc_systemd_system_postgresql.service.d_custom.conf_Debian.j2
dest: "/lib/systemd/system/postgresql.service"
when: ansible_os_family == "Debian"
register: postgresql_systemd_custom_conf
notify:
- reload service daemon
- restart postgresql

- name: PostgreSQL | Ensure the pid directory for PostgreSQL exists
file:
name: "{{ postgresql_pid_directory }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# {{ ansible_managed }}
# Systemd unit file override to specify user/group as well as separate config
# and data directories.

[Unit]
Description={{ postgresql_service_description }}

[Service]
User={{ postgresql_service_user }}
Group={{ postgresql_service_group }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# {{ ansible_managed }}
# Systemd unit file override to specify user/group as well as separate config
# and data directories.

[Unit]
Description={{ postgresql_service_description }}

[Service]
Type=oneshot
ExecStart=/bin/true
ExecReload=/bin/true
RemainAfterExit=on

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion vars/Debian_22.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

postgresql_service_name: "postgresql"

postgresql_apt_repository: "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main {{ postgresql_version }}"
postgresql_apt_repository: "deb http://apt.postgresql.org/pub/repos/apt {{ ansible_distribution_release }}-pgdg main"
Loading