I created the attached plabooks to create a new database auth in my Postgresql server. I use the become_user: postgres to not need the pass how say de documentation " * To avoid “Peer authentication failed for user postgres” error, use postgres user as a become_user."
But when I run the playbook, I get the follow error: “msg”: “unable to connect to database: connection to the server failed on socket «/run/postgresql/.s.PGSQL.5432»: fe_sendauth: no password supplied\n”
- my code!
- name: Postgresql configuration and service management
hosts: "{{ HOSTS }}"
remote_user: "{{ remote_user | default('root') }}"
become: true
vars:
auth_db_name: "auth"
auth_db_user: "{{ auth_db_user }}"
auth_db_password: "{{ auth_db_password }}"
tasks:
- name: Utility present
ansible.builtin.package:
name: python3-psycopg2
state: present
- name: Create 'auth' database
become: true
become_user: postgres
community.postgresql.postgresql_db:
name: "{{ auth_db_name }}"
state: present