Yay, 2 year old thread :).

The way you solve this is by modifying your inventory for localhost with 
the proper setting:

#inventory file
localhost ansible_python_interpreter="/usr/bin/env python"


This will automatically pick up the active virtualenv's python interpreter 
and modules that you've installed there, including boto.  You don't need to 
run any tasks to discover the path to the python interpreter.


On Friday, August 28, 2015 at 6:02:39 PM UTC-5, Justin Phelps wrote:
>
> I managed to fix this with these two tasks:
>
>   - name: Find the path to the python interpreter
>     command: which python
>     register: pythonpath
>     when: lookup('env', 'CI') == "true"
>
>   - name: Set python interpreter path when in CI
>     set_fact: ansible_python_interpreter={{ pythonpath.stdout }}
>     when: lookup('env', 'CI') == "true"
>
> You would take out the when statements as they are specific to my testing 
> environment.
>
> On Friday, August 2, 2013 at 9:52:32 AM UTC-5, Dan McKean wrote:
>>
>> I've been considering Ansible for creating our EC2 instances, and have 
>> run into a problem with ansible not finding boto from either the command 
>> line or a playbook.
>>
>> Here's the command line and response; the playbook is similar:
>>
>> ansible localhost -m ec2 -a "image=ami-0358ce33 instance_type=t1.micro 
>> keypair=myKeypairName group=default wait=true"
>>
>> localhost | FAILED >> {
>>     "failed": true,
>>     "msg": "boto required for this module"
>> }
>>
>>
>> I'm running Ansible from an activated virtualenv.  Ansible was installed 
>> with pip install ansible, and boto's installed as well in the venv (as well 
>> as globally).
>>
>> If I activate the venv and open a command prompt, I can import boto 
>> without any problem, and a boto.connect_ec2() succeeds (there is a ~/.boto 
>> config file present).  Importing ansible and creating a Runner works 
>> succeeds as well.  I'm running this on Mac OS X.
>>
>> Any suggestions on how to fix this?   Thanks!
>>
>> -- Dan
>>
>>
>>

-- 
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/10e039cc-c274-4013-afcc-a9a6beb70b38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to