{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/18227","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/18227/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/18227/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/18227/events","html_url":"https://github.com/ansible/ansible/issues/18227","id":185799884,"number":18227,"title":"ansible_python_interpreter is not set properly for connection: local (affects virtualenv)","user":{"login":"alxnov","id":680802,"avatar_url":"https://avatars.githubusercontent.com/u/680802?v=3","gravatar_id":"","url":"https://api.github.com/users/alxnov","html_url":"https://github.com/alxnov","followers_url":"https://api.github.com/users/alxnov/followers","following_url":"https://api.github.com/users/alxnov/following{/other_user}","gists_url":"https://api.github.com/users/alxnov/gists{/gist_id}","starred_url":"https://api.github.com/users/alxnov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alxnov/subscriptions","organizations_url":"https://api.github.com/users/alxnov/orgs","repos_url":"https://api.github.com/users/alxnov/repos","events_url":"https://api.github.com/users/alxnov/events{/privacy}","received_events_url":"https://api.github.com/users/alxnov/received_events","type":"User","site_admin":false},"labels":[{"id":437720635,"url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.1","name":"affects_2.1","color":"5319e7","default":false},{"id":48276055,"url":"https://api.github.com/repos/ansible/ansible/labels/bug_report","name":"bug_report","color":"fbca04","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-27T22:52:09Z","updated_at":"2016-10-31T19:15:26Z","closed_at":"2016-10-28T16:11:25Z","body":"##### ISSUE TYPE\n- Bug Report\n##### COMPONENT NAME\n\nansible\n##### ANSIBLE VERSION\n\n```\nansible-playbook 2.1.2.0\n  config file = \n  configured module search path = Default w/o overrides\n```\n##### CONFIGURATION\n\nN/A\n##### OS / ENVIRONMENT\n\nMac OS X, virtualenv\n##### SUMMARY\n\n`hostvars['localhost']['ansible_python_interpreter']` contain the right virtualenv path\nhowever, when `- hosts:` target some server group with `connection: local`, ansible-playbook is using `/usr/bin/python` instead of the virtualenv python.\n##### STEPS TO REPRODUCE\n\nLook for execution trace lines like\n\n```\nEXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /Users/alxnov/.ansible/tmp/ansible-tmp-1477608159.39-205252643575457/stat; rm -rf \"/Users/alxnov/.ansible/tmp/ansible-tmp-1477608159.39-205252643575457/\n```\n\n```\n✗ echo ${VIRTUAL_ENV} \n/Users/alxnov/.venv\n✗ cat inv.yml \n[barbazega]\nfuka\nbuka\n✗ cat foo.yml \n- hosts: localhost\n  gather_facts: no\n  connection: local\n  tasks:\n    - stat: path=/tmp\n\n- hosts: barbazega\n  gather_facts: no\n  connection: local\n  tasks:\n    - debug:\n        msg: \"{{ hostvars['localhost']['ansible_python_interpreter'] }}\"\n    - stat: path=/tmp\n✗ ansible-playbook -i inv.yml foo.yml -vvvv\nNo config file found; using defaults\nLoaded callback default of type stdout, v2.0\n\nPLAYBOOK: foo.yml **************************************************************\n2 plays in foo.yml\n\nPLAY [localhost] ***************************************************************\n\nTASK [stat] ********************************************************************\ntask path: /Users/alxnov/Workspace/firewalkwithme/playbooks/fluffy/foo.yml:5\n<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: alxnov\n<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p \"` echo $HOME/.ansible/tmp/ansible-tmp-1477608483.23-237005658482214 `\" && echo ansible-tmp-1477608483.23-237005658482214=\"` echo $HOME/.ansible/tmp/ansible-tmp-1477608483.23-237005658482214 `\" ) && sleep 0'\n<127.0.0.1> PUT /var/folders/rs/rf66zygj1tqgx6whbtstr38w0000gp/T/tmpcXPBoI TO /Users/alxnov/.ansible/tmp/ansible-tmp-1477608483.23-237005658482214/stat\n<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /Users/alxnov/.ansible/tmp/ansible-tmp-1477608483.23-237005658482214/ /Users/alxnov/.ansible/tmp/ansible-tmp-1477608483.23-237005658482214/stat && sleep 0'\n<127.0.0.1> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /Users/alxnov/.venv/bin/python /Users/alxnov/.ansible/tmp/ansible-tmp-1477608483.23-237005658482214/stat; rm -rf \"/Users/alxnov/.ansible/tmp/ansible-tmp-1477608483.23-237005658482214/\" > /dev/null 2>&1 && sleep 0'\nok: [localhost] => {\"changed\": false, \"invocation\": {\"module_args\": {\"checksum_algorithm\": \"sha1\", \"follow\": false, \"get_checksum\": true, \"get_md5\": true, \"mime\": false, \"path\": \"/tmp\"}, \"module_name\": \"stat\"}, \"stat\": {\"atime\": 1468940709.0, \"ctime\": 1468940867.0, \"dev\": 16777220, \"exists\": true, \"gid\": 0, \"gr_name\": \"wheel\", \"inode\": 854316, \"isblk\": false, \"ischr\": false, \"isdir\": false, \"isfifo\": false, \"isgid\": false, \"islnk\": true, \"isreg\": false, \"issock\": false, \"isuid\": false, \"lnk_source\": \"/private/tmp\", \"mode\": \"0755\", \"mtime\": 1468940709.0, \"nlink\": 1, \"path\": \"/tmp\", \"pw_name\": \"root\", \"rgrp\": true, \"roth\": true, \"rusr\": true, \"size\": 11, \"uid\": 0, \"wgrp\": false, \"woth\": false, \"wusr\": true, \"xgrp\": true, \"xoth\": true, \"xusr\": true}}\n\nPLAY [barbazega] ***************************************************************\n\nTASK [debug] *******************************************************************\ntask path: /Users/alxnov/Workspace/firewalkwithme/playbooks/fluffy/foo.yml:11\nok: [fuka] => {\n    \"msg\": \"/Users/alxnov/.venv/bin/python\"\n}\nok: [buka] => {\n    \"msg\": \"/Users/alxnov/.venv/bin/python\"\n}\n\nTASK [stat] ********************************************************************\ntask path: /Users/alxnov/Workspace/firewalkwithme/playbooks/fluffy/foo.yml:13\n<fuka> ESTABLISH LOCAL CONNECTION FOR USER: alxnov\n<fuka> EXEC /bin/sh -c '( umask 77 && mkdir -p \"` echo $HOME/.ansible/tmp/ansible-tmp-1477608483.45-52390816024610 `\" && echo ansible-tmp-1477608483.45-52390816024610=\"` echo $HOME/.ansible/tmp/ansible-tmp-1477608483.45-52390816024610 `\" ) && sleep 0'\n<buka> ESTABLISH LOCAL CONNECTION FOR USER: alxnov\n<buka> EXEC /bin/sh -c '( umask 77 && mkdir -p \"` echo $HOME/.ansible/tmp/ansible-tmp-1477608483.45-46251620220388 `\" && echo ansible-tmp-1477608483.45-46251620220388=\"` echo $HOME/.ansible/tmp/ansible-tmp-1477608483.45-46251620220388 `\" ) && sleep 0'\n<fuka> PUT /var/folders/rs/rf66zygj1tqgx6whbtstr38w0000gp/T/tmpFgtMNQ TO /Users/alxnov/.ansible/tmp/ansible-tmp-1477608483.45-52390816024610/stat\n<buka> PUT /var/folders/rs/rf66zygj1tqgx6whbtstr38w0000gp/T/tmpMhkgTS TO /Users/alxnov/.ansible/tmp/ansible-tmp-1477608483.45-46251620220388/stat\n<fuka> EXEC /bin/sh -c 'chmod u+x /Users/alxnov/.ansible/tmp/ansible-tmp-1477608483.45-52390816024610/ /Users/alxnov/.ansible/tmp/ansible-tmp-1477608483.45-52390816024610/stat && sleep 0'\n<buka> EXEC /bin/sh -c 'chmod u+x /Users/alxnov/.ansible/tmp/ansible-tmp-1477608483.45-46251620220388/ /Users/alxnov/.ansible/tmp/ansible-tmp-1477608483.45-46251620220388/stat && sleep 0'\n<buka> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /Users/alxnov/.ansible/tmp/ansible-tmp-1477608483.45-46251620220388/stat; rm -rf \"/Users/alxnov/.ansible/tmp/ansible-tmp-1477608483.45-46251620220388/\" > /dev/null 2>&1 && sleep 0'\n<fuka> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /Users/alxnov/.ansible/tmp/ansible-tmp-1477608483.45-52390816024610/stat; rm -rf \"/Users/alxnov/.ansible/tmp/ansible-tmp-1477608483.45-52390816024610/\" > /dev/null 2>&1 && sleep 0'\nok: [fuka] => {\"changed\": false, \"invocation\": {\"module_args\": {\"checksum_algorithm\": \"sha1\", \"follow\": false, \"get_checksum\": true, \"get_md5\": true, \"mime\": false, \"path\": \"/tmp\"}, \"module_name\": \"stat\"}, \"stat\": {\"atime\": 1468940709.0, \"ctime\": 1468940867.0, \"dev\": 16777220, \"exists\": true, \"gid\": 0, \"gr_name\": \"wheel\", \"inode\": 854316, \"isblk\": false, \"ischr\": false, \"isdir\": false, \"isfifo\": false, \"isgid\": false, \"islnk\": true, \"isreg\": false, \"issock\": false, \"isuid\": false, \"lnk_source\": \"/private/tmp\", \"mode\": \"0755\", \"mtime\": 1468940709.0, \"nlink\": 1, \"path\": \"/tmp\", \"pw_name\": \"root\", \"rgrp\": true, \"roth\": true, \"rusr\": true, \"size\": 11, \"uid\": 0, \"wgrp\": false, \"woth\": false, \"wusr\": true, \"xgrp\": true, \"xoth\": true, \"xusr\": true}}\nok: [buka] => {\"changed\": false, \"invocation\": {\"module_args\": {\"checksum_algorithm\": \"sha1\", \"follow\": false, \"get_checksum\": true, \"get_md5\": true, \"mime\": false, \"path\": \"/tmp\"}, \"module_name\": \"stat\"}, \"stat\": {\"atime\": 1468940709.0, \"ctime\": 1468940867.0, \"dev\": 16777220, \"exists\": true, \"gid\": 0, \"gr_name\": \"wheel\", \"inode\": 854316, \"isblk\": false, \"ischr\": false, \"isdir\": false, \"isfifo\": false, \"isgid\": false, \"islnk\": true, \"isreg\": false, \"issock\": false, \"isuid\": false, \"lnk_source\": \"/private/tmp\", \"mode\": \"0755\", \"mtime\": 1468940709.0, \"nlink\": 1, \"path\": \"/tmp\", \"pw_name\": \"root\", \"rgrp\": true, \"roth\": true, \"rusr\": true, \"size\": 11, \"uid\": 0, \"wgrp\": false, \"woth\": false, \"wusr\": true, \"xgrp\": true, \"xoth\": true, \"xusr\": true}}\n\nPLAY RECAP *********************************************************************\nbuka                       : ok=2    changed=0    unreachable=0    failed=0   \nfuka                       : ok=2    changed=0    unreachable=0    failed=0   \nlocalhost                  : ok=1    changed=0    unreachable=0    failed=0   \n```\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/257391621","html_url":"https://github.com/ansible/ansible/issues/18227#issuecomment-257391621","issue_url":"https://api.github.com/repos/ansible/ansible/issues/18227","id":257391621,"user":{"login":"alxnov","id":680802,"avatar_url":"https://avatars.githubusercontent.com/u/680802?v=3","gravatar_id":"","url":"https://api.github.com/users/alxnov","html_url":"https://github.com/alxnov","followers_url":"https://api.github.com/users/alxnov/followers","following_url":"https://api.github.com/users/alxnov/following{/other_user}","gists_url":"https://api.github.com/users/alxnov/gists{/gist_id}","starred_url":"https://api.github.com/users/alxnov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alxnov/subscriptions","organizations_url":"https://api.github.com/users/alxnov/orgs","repos_url":"https://api.github.com/users/alxnov/repos","events_url":"https://api.github.com/users/alxnov/events{/privacy}","received_events_url":"https://api.github.com/users/alxnov/received_events","type":"User","site_admin":false},"created_at":"2016-10-31T19:15:26Z","updated_at":"2016-10-31T19:15:26Z","body":"@Shaps @abadger but what about the `connection: local` case, which is my case?\r\n\r\nWhat you're saying right now sounds like that even for modules executed under `connection: local` they are expected to use `ansible_python_interpreter` specified for remote host? I would expect consistency in running code locally, irrespective of the conceptual blueprint host modules are executed for."}}
{"actor":{"display_login":"alxnov"}}