Ansible defaults to executing all modules via /usr/bin/python.  This is
controlled by the ansible_python_interpreter variable.

You can read more about that variable at:

http://docs.ansible.com/ansible/latest/python_3_support.html#testing-python-3-module-support
http://docs.ansible.com/ansible/latest/faq.html#how-do-i-handle-python-pathing-not-having-a-python-2-x-in-usr-bin-python-on-a-remote-machine

On Tue, Oct 10, 2017 at 10:27 AM, John Zucker <zuckerj...@gmail.com> wrote:

> Hi -
>
> I am trying to work out on an experimental basis how to take forward some
> existing py3 code and line up with my usual practice of running
> ansible-playbook under python3 to invoke some stuff including aws modules,
> esp cloudformation.py.
>
> Would much appreciate feedback on the way to go, even if I need to modify
> some modules, to be roughly in line with the team's thinking.
>
> Currently, I am baffled.
>
> 1. Installation is
>
> $ pip show ansible
>
> Name: ansible
>
> Version: 2.4.0.0
>
> ....
>
> Location: /usr/local/lib/python3.6/site-packages
>
>
> 2. Pythons are
>
> /usr/bin/python --version
>
> Python 2.7.10
>
> /usr/local/bin/python --version
>
> Python 3.6.2
>
> with python3 pointing to the latter.
>
> python3 --version
>
> Python 3.6.2
>
>
> 3. I set
>
> $ echo $PYTHONPATH
>
> /usr/local/lib/python3.6/site-packages/
>
> because they are definitely the right ones.
>
>
> 4. So I carefully invoke ansible-playbook from python3. To my surprise it
> starts off under py3 but manages to invoke p2.
>
>
> $ python3 /usr/local/bin/ansible-playbook -i inventory/test/hosts.ini
> create.yml -vvv
>
> ansible-playbook 2.4.0.0
>
>   config file = /Users/devopszucker/REPO-AnsibleJiraCfn/mel-vpc-
> infrastructure/ansible/ansible.cfg
>
>   configured module search path = 
> ['/Users/devopszucker/.ansible/plugins/modules',
> '/usr/share/ansible/plugins/modules']
>
>   ansible python module location = /usr/local/lib/python3.6/site-
> packages/ansible
>
>   executable location = /usr/local/bin/ansible-playbook
>
>   python version = 3.6.2 (default, Jul 17 2017, 16:44:45) [GCC 4.2.1
> Compatible Apple LLVM 8.1.0 (clang-802.0.42)]
>
> Using /Users/devopszucker/REPO-AnsibleJiraCfn/mel-vpc-
> infrastructure/ansible/ansible.cfg as config file
>
> Parsed /Users/devopszucker/REPO-AnsibleJiraCfn/mel-vpc-
> infrastructure/ansible/inventory/test/hosts.ini inventory source with ini
> plugin
>
> [DEPRECATION WARNING]: The use of 'include' for tasks has been deprecated.
> Use 'import_tasks' for static inclusions or 'include_tasks' for dynamic
> inclusions. This feature will be removed in a future
>
> release. Deprecation warnings can be disabled by setting
> deprecation_warnings=False in ansible.cfg.
>
> [DEPRECATION WARNING]: include is kept for backwards compatibility but
> usage is discouraged. The module documentation details page may explain
> more about this rationale.. This feature will be removed in
>
>  a future release. Deprecation warnings can be disabled by setting
> deprecation_warnings=False in ansible.cfg.
>
> statically imported: /Users/devopszucker/REPO-AnsibleJiraCfn/mel-vpc-
> infrastructure/ansible/roles/network/tasks/create.yml
>
> statically imported: /Users/devopszucker/REPO-AnsibleJiraCfn/mel-vpc-
> infrastructure/ansible/roles/network/tasks/destroy.yml
>
>
> PLAYBOOK: create.yml ******************************
> ************************************************************
> ************************************************************
> ********************************
>
> 1 plays in create.yml
>
>
> PLAY [create environment VPC stack for csp] ******************************
> ************************************************************
> *********************************************************************
>
>
> TASK [Gathering Facts] ******************************
> ************************************************************
> ************************************************************
> ******************************
>
> Using module file /usr/local/lib/python3.6/site-packages/ansible/modules/
> system/setup.py
>
> <localhost> ESTABLISH LOCAL CONNECTION FOR USER: devopszucker
>
> <localhost> EXEC /bin/sh -c 'echo ~ && sleep 0'
>
> <localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo
> /Users/devopszucker/.ansible/tmp/ansible-tmp-1507649127.8217468-231361911445889
> `" && echo ansible-tmp-1507649127.8217468-231361911445889="` echo
> /Users/devopszucker/.ansible/tmp/ansible-tmp-1507649127.8217468-231361911445889
> `" ) && sleep 0'
>
> <localhost> PUT /var/folders/d8/wqxz1nsj6337y5bwfrtppmxm0000gn/T/tmpt5ae9u54
> TO /Users/devopszucker/.ansible/tmp/ansible-tmp-1507649127.
> 8217468-231361911445889/setup.py
>
> <localhost> EXEC /bin/sh -c 'chmod u+x /Users/devopszucker/.ansible/
> tmp/ansible-tmp-1507649127.8217468-231361911445889/
> /Users/devopszucker/.ansible/tmp/ansible-tmp-1507649127.
> 8217468-231361911445889/setup.py && sleep 0'
>
> <localhost> EXEC /bin/sh -c '/usr/bin/python /Users/devopszucker/.ansible/
> tmp/ansible-tmp-1507649127.8217468-231361911445889/setup.py; rm -rf
> "/Users/devopszucker/.ansible/tmp/ansible-tmp-1507649127.8217468-231361911445889/"
> > /dev/null 2>&1 && sleep 0'
>
> fatal: [localhost]: FAILED! => {
>
>     "changed": false,
>
>     "failed": true,
>
>     "module_stderr": "Your PYTHONPATH points to a site-packages dir for
> Python 3.x but you are running Python 2.x!\n     PYTHONPATH is currently:
> \"/usr/local/lib/python3.6/site-packages/\"\n     You should `unset
> PYTHONPATH` to fix this.\n",
>
>     "module_stdout": "",
>
>     "msg": "MODULE FAILURE",
>
>     "rc": 0
>
> }
>
> to retry, use: --limit @/Users/devopszucker/REPO-AnsibleJiraCfn/mel-vpc-
> infrastructure/ansible/create.retry
>
>
> PLAY RECAP ************************************************************
> ********
>
>
> 5. As an experiment I have ensured that all system, network and cloud
> modules in site-packages specify python3.
>
> It makes no difference.
>
>
> Where does the /bin/sh of /usr/bin/python come from?
>
> What workaround are you recommending?
>
>
> Thanks a bundle for any hints,
>
> zuckerj...@gmail.com
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/e9982f30-67d7-45f1-bf09-7af5d9bfceb8%40googlegroups.
> com
> <https://groups.google.com/d/msgid/ansible-project/e9982f30-67d7-45f1-bf09-7af5d9bfceb8%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Matt Martz
@sivel
sivel.net

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v_0YOzvCWvSDTsm7sAwmr4aq7icB%3Dx00yLOxLT4%3DPvrKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to