{"action":"opened","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/11817","labels_url":"https://api.github.com/repos/ansible/ansible/issues/11817/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/11817/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/11817/events","html_url":"https://github.com/ansible/ansible/issues/11817","id":98407352,"number":11817,"title":"module_utils cwd double change?","user":{"login":"mjschultz","id":90788,"avatar_url":"https://avatars.githubusercontent.com/u/90788?v=3","gravatar_id":"","url":"https://api.github.com/users/mjschultz","html_url":"https://github.com/mjschultz","followers_url":"https://api.github.com/users/mjschultz/followers","following_url":"https://api.github.com/users/mjschultz/following{/other_user}","gists_url":"https://api.github.com/users/mjschultz/gists{/gist_id}","starred_url":"https://api.github.com/users/mjschultz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjschultz/subscriptions","organizations_url":"https://api.github.com/users/mjschultz/orgs","repos_url":"https://api.github.com/users/mjschultz/repos","events_url":"https://api.github.com/users/mjschultz/events{/privacy}","received_events_url":"https://api.github.com/users/mjschultz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-31T14:52:40Z","updated_at":"2015-07-31T14:52:40Z","closed_at":null,"body":"It looks like the AnsibleModule's `run_command` method tries to change the cwd twice:\r\n1. Through an [`os.chdir`](https://github.com/ansible/ansible/blob/stable-1.9/lib/ansible/module_utils/basic.py#L1519-1524) prior to running `subprocess`\r\n2. Through the [`subprocess` call](https://github.com/ansible/ansible/blob/stable-1.9/lib/ansible/module_utils/basic.py#L1527) itself (via setting [`cwd` in the `kwargs`](https://github.com/ansible/ansible/blob/stable-1.9/lib/ansible/module_utils/basic.py#L1513-1514))\r\n\r\nThis would not be evident if the specified dir is an absolute path, but does happen if it is a relative path.\r\n\r\nPerhaps ansible only expects absolute paths and I missed that bit of documentation?"}}