{"action":"created","issue":{"url":"https://api.github.com/repos/saltstack/salt/issues/11821","labels_url":"https://api.github.com/repos/saltstack/salt/issues/11821/labels{/name}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/11821/comments","events_url":"https://api.github.com/repos/saltstack/salt/issues/11821/events","html_url":"https://github.com/saltstack/salt/issues/11821","id":31020813,"number":11821,"title":"Salt Wants To Create postgres User That Exists","user":{"login":"knine","id":1676503,"avatar_url":"https://avatars.githubusercontent.com/u/1676503?v=3","gravatar_id":"","url":"https://api.github.com/users/knine","html_url":"https://github.com/knine","followers_url":"https://api.github.com/users/knine/followers","following_url":"https://api.github.com/users/knine/following{/other_user}","gists_url":"https://api.github.com/users/knine/gists{/gist_id}","starred_url":"https://api.github.com/users/knine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knine/subscriptions","organizations_url":"https://api.github.com/users/knine/orgs","repos_url":"https://api.github.com/users/knine/repos","events_url":"https://api.github.com/users/knine/events{/privacy}","received_events_url":"https://api.github.com/users/knine/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/saltstack/salt/labels/Bug","name":"Bug","color":"e11d21"},{"url":"https://api.github.com/repos/saltstack/salt/labels/Execution+Module","name":"Execution Module","color":"bfe5bf"},{"url":"https://api.github.com/repos/saltstack/salt/labels/Low-Hanging+Fruit","name":"Low-Hanging Fruit","color":"f7c6c7"},{"url":"https://api.github.com/repos/saltstack/salt/labels/Medium+Severity","name":"Medium Severity","color":"fad8c7"},{"url":"https://api.github.com/repos/saltstack/salt/labels/Pending+Discussion","name":"Pending Discussion","color":"bfdadc"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/saltstack/salt/milestones/13","labels_url":"https://api.github.com/repos/saltstack/salt/milestones/13/labels","id":9265,"number":13,"title":"Approved","description":"All issues that are ready to be worked on, both bugs and features.","creator":{"login":"thatch45","id":507599,"avatar_url":"https://avatars.githubusercontent.com/u/507599?v=3","gravatar_id":"","url":"https://api.github.com/users/thatch45","html_url":"https://github.com/thatch45","followers_url":"https://api.github.com/users/thatch45/followers","following_url":"https://api.github.com/users/thatch45/following{/other_user}","gists_url":"https://api.github.com/users/thatch45/gists{/gist_id}","starred_url":"https://api.github.com/users/thatch45/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thatch45/subscriptions","organizations_url":"https://api.github.com/users/thatch45/orgs","repos_url":"https://api.github.com/users/thatch45/repos","events_url":"https://api.github.com/users/thatch45/events{/privacy}","received_events_url":"https://api.github.com/users/thatch45/received_events","type":"User","site_admin":false},"open_issues":1831,"closed_issues":1418,"state":"open","created_at":"2011-05-14T04:00:56Z","updated_at":"2015-01-18T14:51:21Z","due_on":null,"closed_at":null},"comments":26,"created_at":"2014-04-07T20:49:33Z","updated_at":"2015-01-19T19:07:00Z","closed_at":"2014-05-19T20:14:34Z","body":"A possible issue with 2014.1.1-1 on CentOS 6.5 using the EPEL RPMs.\r\n\r\nI have a postgres user that was created just fine in the 0.17 series and before.  I updated this server to 2014.1.1 and now Salt wants to create the postgres user that already exists:\r\n\r\n```\r\n----------\r\n          ID: postgresql\r\n    Function: postgres_user.present\r\n        Name: samhain\r\n      Result: None\r\n     Comment: User samhain is set to be created\r\n\r\nWhich of course if I try it without test=True fails:\r\n\r\n          ID: postgresql\r\n    Function: postgres_user.present\r\n        Name: samhain\r\n      Result: False\r\n     Comment: Failed to create user samhain\r\n     Changes:\r\n```\r\n\r\nSome debug with test=True enabled:\r\n\r\n```\r\n[INFO    ] Executing state postgres_user.present for samhain\r\n[INFO    ] Executing command '/usr/bin/psql --no-align --no-readline --dbname \r\npostgres -c \\'SELECT setting FROM pg_catalog.pg_settings WHERE name = \r\n\\'\"\\'\"\\'server_version\\'\"\\'\"\\'\\' -t' as user 'postgres' in directory \r\n'/var/lib/pgsql'\r\n[INFO    ] stdout: 8.4.20\r\n[INFO    ] Executing command '/usr/bin/psql --no-align --no-readline --dbname \r\npostgres -v datestyle=ISO,MDY -c \\'COPY (SELECT pg_roles.rolname as \r\n\"name\",pg_roles.rolsuper as \"superuser\", pg_roles.rolinherit as \"inherits \r\nprivileges\", pg_roles.rolcreaterole as \"can create roles\", \r\npg_roles.rolcreatedb as \"can create databases\", pg_roles.rolcatupdate as \"can \r\nupdate system catalogs\", pg_roles.rolcanlogin as \"can login\", pg_roles.NULL as \r\n\"replication\", pg_roles.rolconnlimit as \"connections\", \r\npg_roles.rolvaliduntil::timestamp(0) as \"expiry time\", pg_roles.rolconfig  as \r\n\"defaults variables\", COALESCE(pg_shadow.passwd, pg_authid.rolpassword) as \r\n\"password\" FROM pg_roles LEFT JOIN pg_authid ON pg_roles.oid = pg_authid.oid \r\nLEFT JOIN pg_shadow ON pg_roles.oid = pg_shadow.usesysid) TO STDOUT WITH CSV \r\nHEADER\\'' as user 'postgres' in directory '/var/lib/pgsql'\r\n[ERROR   ] Command '/usr/bin/psql --no-align --no-readline --dbname postgres -\r\nv datestyle=ISO,MDY -c \\'COPY (SELECT pg_roles.rolname as \r\n\"name\",pg_roles.rolsuper as \"superuser\", pg_roles.rolinherit as \"inherits \r\nprivileges\", pg_roles.rolcreaterole as \"can create roles\", \r\npg_roles.rolcreatedb as \"can create databases\", pg_roles.rolcatupdate as \"can \r\nupdate system catalogs\", pg_roles.rolcanlogin as \"can login\", pg_roles.NULL as \r\n\"replication\", pg_roles.rolconnlimit as \"connections\", \r\npg_roles.rolvaliduntil::timestamp(0) as \"expiry time\", pg_roles.rolconfig  as \r\n\"defaults variables\", COALESCE(pg_shadow.passwd, pg_authid.rolpassword) as \r\n\"password\" FROM pg_roles LEFT JOIN pg_authid ON pg_roles.oid = pg_authid.oid \r\nLEFT JOIN pg_shadow ON pg_roles.oid = pg_shadow.usesysid) TO STDOUT WITH CSV \r\nHEADER\\'' failed with return code: 1\r\n[ERROR   ] stderr: ERROR:  column pg_roles.null does not exist\r\nLINE 1: ...m catalogs\", pg_roles.rolcanlogin as \"can login\", pg_roles.N...\r\n                                                             ^\r\n[INFO    ] User samhain is set to be created\r\n[INFO    ] Completed state [samhain] at time 16:48:30.441627\r\n```\r\n\r\nSome debug when I don't run test=True, it does see that the user exists.\r\n\r\n```\r\n[INFO    ] Executing command '/usr/bin/psql --no-align --no-readline --dbname \r\npostgres -c \\'CREATE ROLE \"samhain\" WITH  INHERIT NOCREATEDB NOSUPERUSER LOGIN \r\nENCRYPTED PASSWORD \\'\"\\'\"\\'<SNIP>\\'\"\\'\"\\'\\'' as user 'postgres' in directory \r\n'/var/lib/pgsql'\r\n[ERROR   ] Command '/usr/bin/psql --no-align --no-readline --dbname postgres -\r\nc \\'CREATE ROLE \"samhain\" WITH  INHERIT NOCREATEDB NOSUPERUSER LOGIN ENCRYPTED \r\nPASSWORD \\'\"\\'\"\\'<SNIP>\\'\"\\'\"\\'\\'' failed with return code: 1\r\n[ERROR   ] stderr: ERROR:  role \"samhain\" already exists\r\n[ERROR   ] Failed to create user samhain\r\n```\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/saltstack/salt/issues/comments/70544190","html_url":"https://github.com/saltstack/salt/issues/11821#issuecomment-70544190","issue_url":"https://api.github.com/repos/saltstack/salt/issues/11821","id":70544190,"user":{"login":"knine","id":1676503,"avatar_url":"https://avatars.githubusercontent.com/u/1676503?v=3","gravatar_id":"","url":"https://api.github.com/users/knine","html_url":"https://github.com/knine","followers_url":"https://api.github.com/users/knine/followers","following_url":"https://api.github.com/users/knine/following{/other_user}","gists_url":"https://api.github.com/users/knine/gists{/gist_id}","starred_url":"https://api.github.com/users/knine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knine/subscriptions","organizations_url":"https://api.github.com/users/knine/orgs","repos_url":"https://api.github.com/users/knine/repos","events_url":"https://api.github.com/users/knine/events{/privacy}","received_events_url":"https://api.github.com/users/knine/received_events","type":"User","site_admin":false},"created_at":"2015-01-19T19:07:00Z","updated_at":"2015-01-19T19:07:00Z","body":"It disappeared for me when I installed Helium, so I presume it was fixed."}}