psycopg2.ProgrammingError: conflicting or redundant options

ansible 1.6.6

This stanza in my playbook:

  • name: Create database user
    postgresql_user: name={{rc_db_user}}
    password={{rc_db_pass}}
    role_attr_flags=NOSUPERUSER,NOCREATEROLE,NOCREATEUSER,NOCREATEDB
    login_user={{pg_user}}
    login_password={{pg_pass}}

Results in:

TASK: [Create database user] **************************************************
failed: [jedis-test] => {“failed”: true, “parsed”: false}
invalid output was: SUDO-SUCCESS-cgtcsjketcpyopmfjrlmiidxvqxogoai
Traceback (most recent call last):
File “/home/joliver/.ansible/tmp/ansible-tmp-1406221646.88-85343250424775/postgresql_user”, line 1743, in
main()
File “/home/joliver/.ansible/tmp/ansible-tmp-1406221646.88-85343250424775/postgresql_user”, line 499, in main
changed = user_add(cursor, user, password, role_attr_flags, encrypted, expires)
File “/home/joliver/.ansible/tmp/ansible-tmp-1406221646.88-85343250424775/postgresql_user”, line 181, in user_add
cursor.execute(query, query_password_data)
psycopg2.ProgrammingError: conflicting or redundant options

I used ANSIBLE_KEEP_REMOTE_FILES=1 to look at those lines, but I’m no python or postgresql guru.

OK, I’m going to answer my own question :slight_smile: I got the “conflicting or redundant options” when I used a command: It turns out that NOSUPERUSER is sufficient, and psycopg just throws a fit instead of accepting the “redundant” permissions.

Yeah we should totally catch the Exception and make it look friendly in output regardless, can you file a github ticket on that?

We like to treat python tracebacks as bugs even if they are informing someone of an error condition.

Thanks!