Initial commit
This commit is contained in:
35
roles/configure_postgres/tasks/main.yml
Normal file
35
roles/configure_postgres/tasks/main.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
- name: Initiate postgres
|
||||
ansible.builtin.command: |
|
||||
initdb --locale=C.UTF-8 --encoding=UTF8 -D /var/lib/postgres/data
|
||||
args:
|
||||
creates: /var/lib/postgres/data
|
||||
become: true
|
||||
become_user: postgres
|
||||
- name: Start and enable postgres
|
||||
ansible.builtin.systemd_service:
|
||||
name: postgresql.service
|
||||
state: started
|
||||
enabled: true
|
||||
- name: Configure postgres
|
||||
notify: Restart postgresql
|
||||
block:
|
||||
- name: Modify client authentication config
|
||||
community.postgresql.postgresql_pg_hba:
|
||||
dest: /var/lib/postgres/data/pg_hba.conf
|
||||
overwrite: true
|
||||
rules_behavior: combine
|
||||
databases: all
|
||||
rules:
|
||||
- contype: local
|
||||
users: postgres
|
||||
method: peer
|
||||
- contype: host
|
||||
users: all
|
||||
method: scram-sha-256
|
||||
address: all
|
||||
- name: Edit listen addresses
|
||||
ansible.builtin.lineinfile:
|
||||
path: /var/lib/postgres/data/postgresql.conf
|
||||
regexp: '^#listen_addresses'
|
||||
line: "listen_addresses = '*'"
|
||||
Reference in New Issue
Block a user