{"action":"created","issue":{"url":"https://api.github.com/repos/Stouts/Stouts.mongodb/issues/23","labels_url":"https://api.github.com/repos/Stouts/Stouts.mongodb/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/Stouts/Stouts.mongodb/issues/23/comments","events_url":"https://api.github.com/repos/Stouts/Stouts.mongodb/issues/23/events","html_url":"https://github.com/Stouts/Stouts.mongodb/issues/23","id":126796820,"number":23,"title":"mongoshell commands are executed before the server is started","user":{"login":"morxa","id":4573064,"avatar_url":"https://avatars.githubusercontent.com/u/4573064?v=3","gravatar_id":"","url":"https://api.github.com/users/morxa","html_url":"https://github.com/morxa","followers_url":"https://api.github.com/users/morxa/followers","following_url":"https://api.github.com/users/morxa/following{/other_user}","gists_url":"https://api.github.com/users/morxa/gists{/gist_id}","starred_url":"https://api.github.com/users/morxa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/morxa/subscriptions","organizations_url":"https://api.github.com/users/morxa/orgs","repos_url":"https://api.github.com/users/morxa/repos","events_url":"https://api.github.com/users/morxa/events{/privacy}","received_events_url":"https://api.github.com/users/morxa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-15T02:55:36Z","updated_at":"2016-01-15T02:55:39Z","closed_at":null,"body":"If I install mongodb and execute a mongodb shell command in the same play, the play will fail. This is because mongodb is only started after the shell commands are executed.\r\n\r\nAs an example, the following play fails on hosts where mongodb was not installed previously:\r\n\r\n```\r\n- hosts: all\r\n  sudo: yes\r\n  roles:\r\n    - Stouts.mongodb\r\n  vars:\r\n    mongodb_conf_auth: yes\r\n    mongodb_shell:\r\n      admin:\r\n        - 'db.updateUser( \\\"admin\\\", {roles: [ \\\"userAdminAnyDatabase\\\"], pwd: \\\"test\\\" } )'\r\n```\r\n\r\nError message:\r\n```\r\nFailed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused\r\n```\r\n\r\nmongodb is not running:\r\n```\r\n$ sudo service mongod status\r\nmongod stop/waiting\r\n```"},"comment":{"url":"https://api.github.com/repos/Stouts/Stouts.mongodb/issues/comments/171853415","html_url":"https://github.com/Stouts/Stouts.mongodb/issues/23#issuecomment-171853415","issue_url":"https://api.github.com/repos/Stouts/Stouts.mongodb/issues/23","id":171853415,"user":{"login":"morxa","id":4573064,"avatar_url":"https://avatars.githubusercontent.com/u/4573064?v=3","gravatar_id":"","url":"https://api.github.com/users/morxa","html_url":"https://github.com/morxa","followers_url":"https://api.github.com/users/morxa/followers","following_url":"https://api.github.com/users/morxa/following{/other_user}","gists_url":"https://api.github.com/users/morxa/gists{/gist_id}","starred_url":"https://api.github.com/users/morxa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/morxa/subscriptions","organizations_url":"https://api.github.com/users/morxa/orgs","repos_url":"https://api.github.com/users/morxa/repos","events_url":"https://api.github.com/users/morxa/events{/privacy}","received_events_url":"https://api.github.com/users/morxa/received_events","type":"User","site_admin":false},"created_at":"2016-01-15T02:55:39Z","updated_at":"2016-01-15T02:55:39Z","body":"Note that a similar issue appears if the config is changed and the mongodb shell command only works with the new config. Since mongodb is not restarted (yet), the command will fail."}}