Files
database/roles/configure_postgres/tasks/main.yml
ytshih 32d815621d
Some checks failed
Ansible Playbook lint & deploy / ansible-lint (push) Successful in 12s
Ansible Playbook lint & deploy / run-ansible-mongo (push) Failing after 6s
Ansible Playbook lint & deploy / run-ansible-postgres (push) Failing after 7s
Initial commit
2024-12-03 00:56:20 +00:00

36 lines
1.0 KiB
YAML

---
- 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 = '*'"