Ansible postgresql_db and postgresql_user modules
<p>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 :</p>

<pre><code>fatal: [XXXXXXXXXXXXXX]: FAILED! =&gt; {"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"}
</code></pre>

<p>I'm using the following task for database creation</p>

<pre><code>- name: Create database
  postgresql_db: name=db port=6543
  become: true
  become_user: postgres
</code></pre>

<p>For now, I have done this which is working fine but is not idempotent :</p>

<pre><code>- name: Create database
  command: {{ PGBIN }}/bin/createdb db -p 6543 -w
  become: true
  become_user: postgres
</code></pre>

<p>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.</p>