# postgres\_user usage

**URL:** <https://forum.ansible.com/t/postgres-user-usage/17339>\
**Category:** Ansible Project\
**Created:** [January 21, 2015, 2:57pm UTC](https://forum.ansible.com/t/postgres-user-usage/17339 "2015-01-21T14:57:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwerak](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jwerak/32/3731_2.png) [@jwerak](https://forum.ansible.com/u/jwerak)\
**Post date:** [January 21, 2015, 2:57pm UTC](https://forum.ansible.com/t/postgres-user-usage/17339/1 "2015-01-21T14:57:29Z")

</div>

Hi,

I am trying to create replication user with following task:

- name: Create replication db user  
postgresql\_user:  
name: ‘replication’  
encrypted: yes  
role\_attr\_flags: REPLICATION  
password: “{{ python\_hash\_test.stdout }}”  
sudo\_user: “{{ postgresql\_user\_name }}”  
when: postgresql\_cluster\_role == ‘primary’

I am getting following error:

failed: [db-replication-test-01] =\> {“failed”: true, “parsed”: false}  
SUDO-SUCCESS-qmsyqdbxruptclggdkkagqprjjttrgad  
Traceback (most recent call last):  
File “/tmp/ansible-tmp-1421851833.88-118514931929145/postgresql\_user”, line 2253, in   
main()  
File “/tmp/ansible-tmp-1421851833.88-118514931929145/postgresql\_user”, line 520, in main  
changed = user\_alter(cursor, module, user, password, role\_attr\_flags, encrypted, expires)  
File “/tmp/ansible-tmp-1421851833.88-118514931929145/postgresql\_user”, line 232, in user\_alter  
cursor.execute(’ ‘.join(alter), query\_password\_data)  
psycopg2.ProgrammingError: syntax error at or near “REPLICATION”  
LINE 1: …D PASSWORD E’md5xxxxxxxxxxxxxxxxxxxxxxxx’ REPLICATIO…

I have no trouble when creating user without param role\_attr\_flags

- name: Create replication db user  
postgresql\_user:  
name: ‘replication’  
encrypted: yes  
password: “{{ python\_hash\_test.stdout }}”

sudo\_user: “{{ postgresql\_user\_name }}”  
when: postgresql\_cluster\_role == ‘primary’

On server I am using

- Python 2.6.6

- PostgreSQL 9.0.18 on x86\_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4), 64-bit

- python-psycopg2-2.4.6-1.rhel6.x86\_64

Does anyone have experience with this module?

Thanks,  
Jakub

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 21, 2015, 3:07pm UTC](https://forum.ansible.com/t/postgres-user-usage/17339/2 "2015-01-21T15:07:14Z")

</div>

i have very similar setup, except the role\_attr\_flags="'REPLICATION  
LOGIN" and it works correctly.

---

<div class="post-metadata">

**Author:** ![jwerak](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jwerak/32/3731_2.png) [@jwerak](https://forum.ansible.com/u/jwerak)\
**Post date:** [January 21, 2015, 3:26pm UTC](https://forum.ansible.com/t/postgres-user-usage/17339/3 "2015-01-21T15:26:05Z")

</div>

Thanks for info, its my bad probably, because postgres 9.0 doesn’t have REPLICATION role …

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 21, 2015, 3:46pm UTC](https://forum.ansible.com/t/postgres-user-usage/17339/4 "2015-01-21T15:46:03Z")

</div>

ah, yes, i use 9.3 and 9.4
