# postgresql\_user module help

**URL:** <https://forum.ansible.com/t/postgresql-user-module-help/23678>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [February 7, 2017, 10:46pm UTC](https://forum.ansible.com/t/postgresql-user-module-help/23678 "2017-02-07T22:46:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shyam\_Yenna](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@Shyam\_Yenna](https://forum.ansible.com/u/Shyam_Yenna)\
**Post date:** [February 7, 2017, 10:46pm UTC](https://forum.ansible.com/t/postgresql-user-module-help/23678/1 "2017-02-07T22:46:21Z")

</div>

I am getting below error while trying to use module postgresql\_user. I want to create a new user account in postgresql. but i am unable to create user account with become\_user postgres or commenting that line is failing to get authenticate. i have seen a Bug report #4225 but trying to see workaround solution.

my playbook contains below code

- name: Configure Database server ami instance  
hosts: database  
gather\_facts: true  
become: true  
become\_method: sudo  
vars:  
ansible\_user: ubuntu  
vars\_files:
- [vars/local\_vars.yml]  
roles:
- postgres

postgres role main.yml

- include: bootstrap.yml

- include: users.yml

# users.yml file task

- name: Create new Administrator User  
postgresql\_user:  
name: “adminuser”  
password: “adminpwd”  
encrypted: yes  
state: present  
role\_attr\_flags: SUPERUSER,CREATEROLE,CREATEUSER,CREATEDB,LOGIN,REPLICATION  
become\_user: postgres

“module\_stderr”: “Traceback (most recent call last):\n File "/tmp/ansible\_PIv0G9/ansible\_module\_postgresql\_user.py", line 666, in \n main()\n File "/tmp/ansible\_PIv0G9/ansible\_module\_postgresql\_user.py", line 627, in main\n changed = user\_add(cursor, user, password, role\_attr\_flags, encrypted, expires)\n File "/tmp/ansible\_PIv0G9/ansible\_module\_postgresql\_user.py", line 220, in user\_add\n cursor.execute(query, query\_password\_data)\n File "/usr/lib/python2.7/dist-packages/psycopg2/extras.py", line 123, in execute\n return \_cursor.execute(self, query, vars)\npsycopg2.ProgrammingError: conflicting or redundant options\n\n”,  
“module\_stdout”: “”,  
“msg”: “MODULE FAILURE”

Thanks  
Shyam

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [February 8, 2017, 8:25am UTC](https://forum.ansible.com/t/postgresql-user-module-help/23678/2 "2017-02-08T08:25:42Z")

</div>

What happens if you put the become\_user statement into this block  
instead of into the user.yml file?

What happens if you do not include the user.yml, but put its contents  
directly into the playbook (just for debugging)?

Johannes

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [February 8, 2017, 8:28am UTC](https://forum.ansible.com/t/postgresql-user-module-help/23678/3 "2017-02-08T08:28:06Z")

</div>

Addition to my first mail:

As ansible does not allow chaining sudo (become root and then become  
postgres), does sudo allow your user to become postgres directly?  
Although I think your error is due to the become\_user statements  
syntax or placement, not in the authentication logic. But once you get  
the ansible play to work, you might run into authentication issues...

Johannes
