Change pg_hba.conf & postgresql.conf

493 views
Skip to first unread message

Sagan

unread,
Aug 26, 2022, 8:44:27 AM8/26/22
to Ansible Project
Hello,

I'm trying to automatize the editing of these files. I have made a playbook to install PostgreSQL in a controlled node. However, I need to change these 2 files to accept remote connections so I can access the PostgreSQL databases with my PGadmin4.

However, I can't seem to find how to change the configuration on these files. Is there a module for this? It seems weird that no module can do it. So I'm sure I've missed something.

Any advice would be greatly welcomed!

ajay garad

unread,
Aug 26, 2022, 11:03:11 AM8/26/22
to ansible...@googlegroups.com
Hello ,

I also checked  below code 

        - name: Replace postgresql configuration file to allow remote connection
          ansible.builtin.lineinfile:
             path: "{{ postgresql_conf_file }}"
             line: '{{ item }}'
             owner: postgres
             group: postgres
             mode: '0644'
          with_items:
              - "listen_addresses = '*'"
              - "port = 5432"
          become: yes
          become_user: root


        - name: "Allow md5 connection for the db user"
          postgresql_pg_hba:
            dest: "{{ pg_hba_file}}"
            contype: host
            databases: all
            source: "0.0.0.0/0"
            method: md5
            users: "all"
            create: true
          become: yes
          become_user: root


I hope it will help you..!


Regards,
Ajay 



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/26d962cf-e8e2-436f-b06d-97e290103354n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages