{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/6345","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/6345/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/6345/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/6345/events","html_url":"https://github.com/ansible/ansible/issues/6345","id":29028267,"number":6345,"title":"Introduce ANSIBLE_PYTHON_INTERPRETER env variable.","user":{"login":"alimony","id":331091,"avatar_url":"https://avatars.githubusercontent.com/u/331091?v=3","gravatar_id":"","url":"https://api.github.com/users/alimony","html_url":"https://github.com/alimony","followers_url":"https://api.github.com/users/alimony/followers","following_url":"https://api.github.com/users/alimony/following{/other_user}","gists_url":"https://api.github.com/users/alimony/gists{/gist_id}","starred_url":"https://api.github.com/users/alimony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alimony/subscriptions","organizations_url":"https://api.github.com/users/alimony/orgs","repos_url":"https://api.github.com/users/alimony/repos","events_url":"https://api.github.com/users/alimony/events{/privacy}","received_events_url":"https://api.github.com/users/alimony/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2014-03-08T19:35:10Z","updated_at":"2016-02-09T17:57:14Z","closed_at":"2014-03-09T00:30:52Z","body":"##### Issue Type:\r\n\r\nFeature Idea\r\n\r\n##### Ansible Version:\r\n\r\nansible 1.6 (devel da2126eda5) last updated 2014/03/04 20:54:15 (GMT +200)\r\n\r\n##### Environment:\r\n\r\nN/A\r\n\r\n##### Summary:\r\n\r\nAt the moment, there is no env variable equivalent of the `ansible_python_interpreter` setting.\r\n\r\nIf I use a python at some other path than `/usr/bin/python` I need to set this config variable.\r\n\r\nBut if I already have an `ansible.cfg` under source control, I can't do it in there, since people will share that file and they may need some other python path than me.\r\n\r\nAnd combining several config files is not supported.\r\n\r\nSo, how would I solve this?\r\n\r\nHaving a corresponding env variable (as with many other settings) would solve this nicely, but from what I gather from a bit of googling, that env variable is deliberately not available. How come?\r\n\r\n##### Steps To Reproduce:\r\n\r\nI would ideally want to do this:\r\n\r\n    export ANSIBLE_PYTHON_INTERPRETER=/some/special/python\r\n\r\n##### Expected Results:\r\n\r\nThat the `ansible_python_interpreter` setting is available as an env var setting as well.\r\n\r\n##### Actual Results:\r\n\r\nIt is not :)"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/181981760","html_url":"https://github.com/ansible/ansible/issues/6345#issuecomment-181981760","issue_url":"https://api.github.com/repos/ansible/ansible/issues/6345","id":181981760,"user":{"login":"abadger","id":209242,"avatar_url":"https://avatars.githubusercontent.com/u/209242?v=3","gravatar_id":"","url":"https://api.github.com/users/abadger","html_url":"https://github.com/abadger","followers_url":"https://api.github.com/users/abadger/followers","following_url":"https://api.github.com/users/abadger/following{/other_user}","gists_url":"https://api.github.com/users/abadger/gists{/gist_id}","starred_url":"https://api.github.com/users/abadger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abadger/subscriptions","organizations_url":"https://api.github.com/users/abadger/orgs","repos_url":"https://api.github.com/users/abadger/repos","events_url":"https://api.github.com/users/abadger/events{/privacy}","received_events_url":"https://api.github.com/users/abadger/received_events","type":"User","site_admin":false},"created_at":"2016-02-09T17:57:14Z","updated_at":"2016-02-09T17:57:14Z","body":"There will not be an environment variable for python interpreter added to ansible.  There are ways to enable all the use cases that people are asking for by setting ```ansible_python_interpreter``` in one manner or another.\r\n\r\n@dominikborkowski Your issue with docker sounds like it is the primary use case for ansible_python_interpreter.  On the docker containers, python is installed into /usr/local/bin/ instead of into /usr/bin/ because of that, for your docker containers you need to tell ansible that the python executable resides somewhere other than /usr/bin/python.  You do this using ansible_python_interpreter in an inventory file:\r\n\r\n```\r\n[docker_python_hosts]\r\ndocker1\r\ndocker2\r\n\r\n[docker_python_hosts:vars]\r\nansible_python_interpreter=/usr/local/bin/python\r\n```\r\n\r\nFor everyone who wants to have multiple python interpreters on the same host with different users using different ones there's various methods which may suit your needs in various ways.  The one closest to setting an env var is to set ansible_python_interpreter on the command line as bcoca mentioned: https://github.com/ansible/ansible/issues/6345#issuecomment-37113104\r\n```\r\n$ ansible docker1 -m ping -e 'ansible_python_interpreter=/usr/local/bin/python'\r\n```\r\n\r\nIf you want to set that in a shell login file so that it applies to all of your hosts (like setting an environment variable in a shell login file would do) use alias to always add that to the ansible and ansible-playbook commands:\r\n```\r\nalias ansible='ansible -e \"ansible_python_interpreter=/usr/local/bin/python\"'\r\nalias ansible-playbook='ansible-playbook -e \"ansible_python_interpreter=/usr/local/bin/python\"'\r\n```\r\n\r\nSomething similar can also be done in inventory with inventory names per-user like this:\r\n```\r\n[user_host_aliases]\r\nabadger-shared ansible_host=shared1 ansible_python_interpreter=/home/badger/bin/python\r\ntoshio-shared ansible_host=shared1 ansible_python_interpreter=/home/toshio/bin/python\r\n```\r\n\r\nI'm going to be locking this issue as the environment variable is probably never going to happen.  If you need help getting an alternative to work, feel free to stop by the mailing list or IRC and someone will be happy to try and get an example working for you.  I'll paste the mailing list information below.\r\n\r\nList Information\r\n================\r\n\r\nHi!\r\n\r\nThanks very much for your interest in Ansible.  It sincerely means a lot to us. \r\n\r\nThis appears to be a user question, and we'd like to direct these kinds of things to either the mailing list or the IRC channel.\r\n\r\n   * IRC: #ansible on irc.freenode.net   \r\n   * mailing list: https://groups.google.com/forum/#!forum/ansible-project\r\n\r\nIf you can stop by there, we'd appreciate it.  This allows us to keep the issue tracker for bugs, pull requests, RFEs and the like.\r\n\r\nThank you once again and we look forward to seeing you on the list or IRC.  Thanks!\r\n\r\n\r\n"}}