{"action":"created","issue":{"url":"https://api.github.com/repos/ANXS/postgresql/issues/459","repository_url":"https://api.github.com/repos/ANXS/postgresql","labels_url":"https://api.github.com/repos/ANXS/postgresql/issues/459/labels{/name}","comments_url":"https://api.github.com/repos/ANXS/postgresql/issues/459/comments","events_url":"https://api.github.com/repos/ANXS/postgresql/issues/459/events","html_url":"https://github.com/ANXS/postgresql/issues/459","id":535143341,"node_id":"MDU6SXNzdWU1MzUxNDMzNDE=","number":459,"title":"Order of execution issue with postgresql_default_auth_method: \"md5\" and user creation","user":{"login":"morgangraphics","id":607594,"node_id":"MDQ6VXNlcjYwNzU5NA==","avatar_url":"https://avatars2.githubusercontent.com/u/607594?v=4","gravatar_id":"","url":"https://api.github.com/users/morgangraphics","html_url":"https://github.com/morgangraphics","followers_url":"https://api.github.com/users/morgangraphics/followers","following_url":"https://api.github.com/users/morgangraphics/following{/other_user}","gists_url":"https://api.github.com/users/morgangraphics/gists{/gist_id}","starred_url":"https://api.github.com/users/morgangraphics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/morgangraphics/subscriptions","organizations_url":"https://api.github.com/users/morgangraphics/orgs","repos_url":"https://api.github.com/users/morgangraphics/repos","events_url":"https://api.github.com/users/morgangraphics/events{/privacy}","received_events_url":"https://api.github.com/users/morgangraphics/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2019-12-09T18:50:58Z","updated_at":"2019-12-10T19:31:36Z","closed_at":null,"author_association":"NONE","body":"Setting the **postgresql_default_auth_method: \"md5\"** on a fresh install tells postgres that the default postgres user requires password authentication without first having set up an initial password before hand. This is a order of execution issue where:\r\n\r\n1. the configuration files are provisioned (essentially requiring passwords)\r\n2. users are attempting to be created but passwords are not set \r\n\r\nIdeally the order should be \r\n1. user creation should happen first\r\n2. the configurations applied afterwards locking up the database access.  \r\n\r\nMinimum test case for generating issue\r\n\r\n```\r\n  - role: ansible-role-postgres\r\n        postgresql_version: 12\r\n        postgresql_default_auth_method: \"md5\"\r\n        postgresql_users:\r\n          - name: postgres\r\n            pass: somegeneratedpassword123\r\n            encrypted: yes\r\n```\r\n\r\n\r\ncurrent work around is to accept the default **postgresql_default_auth_method: \"peer\"**\r\n\r\nand after the posgres role has run,  edit the /etc/postgresql/12/main/pg_hba.conf file \r\n\r\nfrom \r\n```\r\n# local postgres without password\r\nlocal  all  postgres    peer\r\n```\r\n\r\nto\r\n\r\n```\r\n# local postgres without password\r\nlocal  all  postgres    md5\r\n```\r\n\r\nin another task. "},"comment":{"url":"https://api.github.com/repos/ANXS/postgresql/issues/comments/564207382","html_url":"https://github.com/ANXS/postgresql/issues/459#issuecomment-564207382","issue_url":"https://api.github.com/repos/ANXS/postgresql/issues/459","id":564207382,"node_id":"MDEyOklzc3VlQ29tbWVudDU2NDIwNzM4Mg==","user":{"login":"morgangraphics","id":607594,"node_id":"MDQ6VXNlcjYwNzU5NA==","avatar_url":"https://avatars2.githubusercontent.com/u/607594?v=4","gravatar_id":"","url":"https://api.github.com/users/morgangraphics","html_url":"https://github.com/morgangraphics","followers_url":"https://api.github.com/users/morgangraphics/followers","following_url":"https://api.github.com/users/morgangraphics/following{/other_user}","gists_url":"https://api.github.com/users/morgangraphics/gists{/gist_id}","starred_url":"https://api.github.com/users/morgangraphics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/morgangraphics/subscriptions","organizations_url":"https://api.github.com/users/morgangraphics/orgs","repos_url":"https://api.github.com/users/morgangraphics/repos","events_url":"https://api.github.com/users/morgangraphics/events{/privacy}","received_events_url":"https://api.github.com/users/morgangraphics/received_events","type":"User","site_admin":false},"created_at":"2019-12-10T19:31:35Z","updated_at":"2019-12-10T19:31:35Z","author_association":"NONE","body":"In thinking about this further. Perhaps it might be a little easier for the role to have a default `pg_hba.conf`  file added before user creation which allows for unobstructed user creation and then the `pg_hba.conf` configurations are applied after user creation is successful.  "}}
{"actor":{"display_login":"morgangraphics"}}