postgres_user usage

46 views
Skip to first unread message

Jakub Veverka

unread,
Jan 21, 2015, 9:57:29 AM1/21/15
to ansible...@googlegroups.com
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 <module>
    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

Brian Coca

unread,
Jan 21, 2015, 10:07:18 AM1/21/15
to ansible...@googlegroups.com
i have very similar setup, except the role_attr_flags="'REPLICATION
LOGIN" and it works correctly.



--
Brian Coca

Jakub Veverka

unread,
Jan 21, 2015, 10:26:06 AM1/21/15
to ansible...@googlegroups.com
Thanks for info, its my bad probably, because postgres 9.0 doesn't have  REPLICATION role ... 

Brian Coca

unread,
Jan 21, 2015, 10:46:07 AM1/21/15
to ansible...@googlegroups.com
ah, yes, i use 9.3 and 9.4



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages