On 03/26/14 12:10, Mehul Ved wrote: > Probably I'm failing to understand the internal working and should > spend more time understanding ansible. I was assuming that when > running inside virtualenv, it would use python installation inside > virtualenv only but that doesn't seem to be the case with synchronize > module. I should probably understand how it works internally to > understand why this happens. > > > On Tue, Mar 25, 2014 at 8:41 PM, Petros Moisiadis <[email protected]> wrote: >> On 03/25/2014 04:42 PM, Mehul Ved wrote: >>> On Tue, Mar 25, 2014 at 8:00 PM, Petros Moisiadis <[email protected]> wrote: >>>> The syntax error you get could be caused by a python 3 interpreter being >>>> used at the target machine instead of python 2. This is a common error >>>> when running ansible on target machines running Archlinux because the >>>> default python interpreter (at /usr/bin/python) on Arch is actually the >>>> python3 interpreter. In these cases you should set the >>>> "ansible_python_interpreter" variable for the affected hosts to the >>>> correct path ("/usr/bin/python2" for archlinux). >>> That did fix the problem. I was assuming that isn't required when you >>> install using virtualenv. Everything else has been working fine so >>> far, this was the first thing I ran into an issue with while using >>> ansible from virtualenv. Should this be considered a bug? If so, I'll >>> open a new ticket on github. >>> >>> >> It is not a bug. It is just that some hosts need to be configured so >> that ansible uses the python2 interpreter when running on them. Also, >> running from inside a virtualenv has nothing to do with this. Running >> from outside (not in a virtualenv) would cause the same error. It is an >> error caused on remote host (controlled), not on local host (controller). >> >> -- >> 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 [email protected]. >> To post to this group, send email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/53319C99.4000802%40yahoo.gr. >> For more options, visit https://groups.google.com/d/optout. > > Ansible runs first on the local machine (controller), then opens an ssh connection to the remote machine (target), copies itself and needed modules to the remote machine and invokes itself on the remote machine. So, eventually you will have _two_ processes of ansible: one runs on local machine and the other runs on the remote machine. If you happen to have installed ansible on the local machine inside a virtual environment and you have enabled that virtualenv, then the process running on the local machine will be running in the context of that virtualenv. On the other hand, the process that is running on the remote machine will have been invoked with the python interpreter configured with ansible_python_interpreter (which defaults to '/usr/bin/python').
-- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5332F518.8020308%40yahoo.gr. For more options, visit https://groups.google.com/d/optout.
