Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bug related with repository url and customize service desc #584

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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 @@ -78,10 +82,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 @@ -92,7 +96,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
4 changes: 4 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
name: "{{ postgresql_service_name }}"
state: restarted
enabled: yes

- name: reload service daemon
ansible.builtin.systemd_service:
daemon_reload: true
10 changes: 10 additions & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@
when: ansible_os_family == "RedHat"
register: postgresql_systemd_custom_conf

- 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
4 changes: 3 additions & 1 deletion tasks/install_apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
# validate www.postgresql.org (or probably any other source).
- name: PostgreSQL | Make sure the CA certificates are available | apt
apt:
pkg: ca-certificates
pkg:
- gnupg2
- ca-certificates
state: present

- name: PostgreSQL | Add PostgreSQL repository apt-key | apt
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"