postgres_user usage

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

i have very similar setup, except the role_attr_flags="'REPLICATION
LOGIN" and it works correctly.

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

ah, yes, i use 9.3 and 9.4