Skip to content

Commit

Permalink
add the task that configures host based authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
shtlrs authored and jchristgit committed May 14, 2024
1 parent 74a2f65 commit 0bc31eb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ansible/roles/postgres/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,19 @@
become_user: "{{ postgres_user }}"
tags:
- role::postgres


- name: Set host based authentication rules for all postgres users at once
ansible.builtin.blockinfile:
path: /etc/postgresql/{{ postgres_version }}/main/pg_hba.conf
insertafter: "# Put your actual configuration here"
marker: "# {mark} ANSIBLE MANAGED HBA CONF BLOCK"
block: |
{% for db in postgres_databases %}
host {{ db.name }} {{ db.owner }} all scram-sha-256
{% endfor %}
loop: "{{ postgres_databases }}"
notify:
- Reload the postgres service
tags:
- role::postgres

0 comments on commit 0bc31eb

Please sign in to comment.