I'm trying to add database and user in an existing pgsql database (on a centOS 7.1 server). I'm using postgresql_user and postgresql_db modules (Ansible 2.2) to do it but I get the error :
fatal: [XXXXXXXXXXXXXX]: FAILED! => {"changed": false, "failed": true, "msg": "unable to connect to database: could not connect to server: No such file or directory\n\tIs the server running locally and accepting\n\tconnections on Unix domain socket \"/var/run/postgresql/.s.PGSQL.6543\"?\n"}
I'm using the following task for database creation
- name: Create database
postgresql_db: name=db port=6543
become: true
become_user: postgres
For now, I have done this which is working fine but is not idempotent :
- name: Create database
command: {{ PGBIN }}/bin/createdb db -p 6543 -w
become: true
become_user: postgres
I have installed as required the psycopg2 package. For information the database is not installed in the standard directory and is not using standard port 5432.