diff --git a/roles/postgres/defaults/main.yml b/roles/postgres/defaults/main.yml index 79bb6e5..6066e7d 100644 --- a/roles/postgres/defaults/main.yml +++ b/roles/postgres/defaults/main.yml @@ -1,2 +1,6 @@ --- postgres__hba: [] + +postgres__config: + - key: listen_addresses + value: '*' diff --git a/roles/postgres/tasks/main.yml b/roles/postgres/tasks/main.yml index 677b85e..385e5a6 100644 --- a/roles/postgres/tasks/main.yml +++ b/roles/postgres/tasks/main.yml @@ -12,3 +12,12 @@ owner: postgres group: postgres notify: Restart Postgres + +- name: Change config + lineinfile: + dest: '/etc/postgresql/12/main/postgresql.conf' + regexp: '^#?{{ item.key }}(( |=).*)?$' + line: "{{ item.key }} = '{{ item.value }}'" + state: "{{ item.state | default('present') }}" + with_items: '{{ postgres__config }}' + notify: Restart Postgres