Reputation: 3
I'm trying to create a user on Postgres with ansible, but I have no password defined on user Postgres DB.
name: Connect to postgres database, create toto user, and grant access SUPERUSER, INHERIT When PGversion > 10
postgresql_user:
login_host: 127.0.0.1
db: postgres
name: toto
password: "{{toto}}"
role_attr_flags: SUPERUSER,INHERIT
login_user: postgres
login_password: "toto"
port: "{{port_postgres}}"
When I launch without a password, I have this error message in my playbook.
fe_sendauth: no password supplied
If I put a password "toto" to the user on Postgres and in my playbook, it's ok!
Does somebody have an idea?
Upvotes: 0
Views: 638
Reputation: 7907
The easiest way is to use passwordless psql from sudo -u postgres
, which is translates to Ansible's:
- name: Add user
become: true
become_user: postgres
postgresql_user:
db: postgres
name: ...
Upvotes: 1