vmbuilder-deploy-ansible/roles/pg/tasks/Rocky-9.yml
2025-01-28 23:30:14 +03:00

54 lines
1.5 KiB
YAML

- name: Install postgresql-server package
package:
name: [
postgresql-server,
python3-psycopg2
]
state: present
- name: initialize postgresql
command: postgresql-setup initdb
args:
creates: /var/lib/pgsql/data/pg_hba.conf
notify:
- reload postgresql
- name: configure pg_hba.conf
copy:
dest: /var/lib/pgsql/data/pg_hba.conf
content: |
local nativecloud nativecloud trust
local all postgres peer
# IPv6 local connections:
host nativecloud nativecloud ::1/128 trust
mode: preserve
notify:
- reload postgresql
- name: disable TCP/IP for postgres
lineinfile:
dest: /var/lib/pgsql/data/postgresql.conf
regexp: '^#listen_addresses'
line: "listen_addresses = '*'"
notify:
- reload postgresql
# Note: this is not in the upstream documentation. It's still under discussion
# upstream, see
# https://lists.fedorahosted.org/archives/list/koji-devel@lists.fedorahosted.org/thread/NMDIDYS7CZWB3SMPT6UO2P5WGZXKIZVW/
- name: increase number of max connections
lineinfile:
dest: /var/lib/pgsql/data/postgresql.conf
regexp: '^max_connections'
line: "max_connections = 500"
notify:
- reload postgresql
when:
- ansible_os_family == "RedHat" and ansible_distribution_major_version|int > 7
# - ansible_os_family == "RedHat" and ansible_distribution_major_version|int > 7
- name: start postgresql
service:
name: postgresql
state: started
enabled: true