python - GCE module in Ansible cannot find apache-libcloud although gce.py works -
i installed ansible, apache-libcloud pip. also, can use gcloud cli , ansible works non-gce-related playbooks.
when using gce module task create instances in ansible playbook, following error occurs:
task: [launch instances] ****************************************************** <127.0.0.1> remote_module gce instance_names=mm2 machine_type=f1-micro image=ubuntu-1204-precise-v20150625 zone=europe-west1-d service_account_email= pem_file=../pkey.pem project_id=fancystuff-11 <127.0.0.1> exec ['/bin/sh', '-c', 'mkdir -p $home/.ansible/tmp/ansible-tmp-1437669562.03-233461447935889 && chmod a+rx $home/.ansible/tmp/ansible-tmp-1437669562.03-233461447935889 && echo $home/.ansible/tmp/ansible-tmp-1437669562.03-233461447935889'] <127.0.0.1> put /var/folders/v4/ll0_f8lj7yl7yghb645h95q9ckfc19/t/tmpydopt9 /users/d046179/.ansible/tmp/ansible-tmp-1437669562.03-233461447935889/gce <127.0.0.1> exec ['/bin/sh', '-c', u'lang=en_us.utf-8 lc_ctype=en_us.utf-8 /usr/bin/python /users/d046179/.ansible/tmp/ansible-tmp-1437669562.03-233461447935889/gce; rm -rf /users/d046179/.ansible/tmp/ansible-tmp-1437669562.03-233461447935889/ >/dev/null 2>&1'] failed: [localhost -> 127.0.0.1] => {"failed": true, "parsed": false} failed=true msg='libcloud gce support (0.13.3+) required module' fatal: hosts have failed -- aborting
and site.yml of playbook wrote:
name: create sandbox instance hosts: localhost vars: names: mm2 machine_type: f1-micro image: ubuntu-1204-precise-v20150625 zone: europe-west1-d service_account_email: xxx@developer.gserviceaccount.com pem_file: ../pkey.pem project_id: fancystuff-11 tasks: - name: launch instances local_action: gce instance_names={{names}} machine_type={{machine_type}} image={{image}} zone={{zone}} service_account_email={{ service_account_email }} pem_file={{ pem_file }} project_id={{ project_id }} register: gce
the gce cloud module fails error message "ibcloud gce support (0.13.3+) required module". however, running gce.py ansible github repo works. python script finds apache-libcloud library , prints json running instances. besides, pip install apache-libcloud states installed properly.
is there missing environment variable points python libraries (pythonpath)?
update 1:
i included following task before gce task:
- name: install libcloud pip: name=apache-libcloud
this not affect behavior nor prevents error messages.
update 2:
i added following task inspect available pythonpath:
- name: getting pythonpath local_action: shell python -c 'import sys; print(":".join(sys.path))' register: pythonpath - debug: msg: "pythonpath: {{ pythonpath.stdout }}"
the following returned:
pythonpath: :/usr/local/lib/python2.7/site-packages/setuptools-17.1.1-py2.7.egg:/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg:/usr/local/lib/python2.7/site-packages:/usr/local/cellar/python/2.7.10/frameworks/python.framework/versions/2.7/lib/python27.zip:/usr/local/cellar/python/2.7.10/frameworks/python.framework/versions/2.7/lib/python2.7:/usr/local/cellar/python/2.7.10/frameworks/python.framework/versions/2.7/lib/python2.7/plat-darwin:/usr/local/cellar/python/2.7.10/frameworks/python.framework/versions/2.7/lib/python2.7/plat-mac:/usr/local/cellar/python/2.7.10/frameworks/python.framework/versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages:/usr/local/cellar/python/2.7.10/frameworks/python.framework/versions/2.7/lib/python2.7/lib-tk:/usr/local/cellar/python/2.7.10/frameworks/python.framework/versions/2.7/lib/python2.7/lib-old:/usr/local/cellar/python/2.7.10/frameworks/python.framework/versions/2.7/lib/python2.7/lib-dynload:/usr/local/lib/python2.7/site-packages:/library/python/2.7/site-packages
update 3:
i introduced own test.py script task executes same apache-libcloud imports gce ansible module. script imports fine!!!
setting pythonpath fixes issue. example:
$ export pythonpath=/usr/local/lib/python2.7/site-packages/
Comments
Post a Comment