# gce module problems

**URL:** <https://forum.ansible.com/t/gce-module-problems/14510>\
**Category:** Ansible Project\
**Created:** [February 6, 2014, 3:45pm UTC](https://forum.ansible.com/t/gce-module-problems/14510 "2014-02-06T15:45:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Warren\_Strange](https://avatars.discourse-cdn.com/v4/letter/w/d78d45/32.png) [@Warren\_Strange](https://forum.ansible.com/u/Warren_Strange)\
**Post date:** [February 6, 2014, 3:45pm UTC](https://forum.ansible.com/t/gce-module-problems/14510/1 "2014-02-06T15:45:16Z")

</div>

I am running into a problem the gce module. I suspect it has something to do with my environment. Any tips to further troubleshoot this would be welcome.

I am running ansible from git (as of a couple of days ago), and using libcloud 0.14.0. I know there was an issue with the beta3 of libcloud - but I think this version is newer (and the error I get is different anyways…). I have followed the thread on how to set up secrets.py, set GCE\_PARAMS, etc. I think I have that part correct - but the error shows up no matter the contents of secrets.py - making me think it doesnt even get to that point.

My playbook looks like (ignore extra line breaks - that is an artifact of cut n paste)

- name: Create a sandbox instance

hosts: localhost

connection: local

vars:

names: foo,bar

machine\_type: f1-micro

image: centos-6-v20131120

zone: us-central1-a

tasks:

- name: Launch instances

local\_action: gce machine\_type={{machine\_type}} image={{image}} zone={{zone}}

The error I get is “AttributeError: ‘exceptions.ValueError’ object has no attribute ‘http\_code’”

The full output is below:

PLAY [Create a sandbox instance] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

REMOTE\_MODULE setup

\<127.0.0.1\> REMOTE\_MODULE setup

EXEC [‘/bin/sh’, ‘-c’, ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1391701320.38-99585849597022 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1391701320.38-99585849597022 && echo $HOME/.ansible/tmp/ansible-tmp-1391701320.38-99585849597022’]

\<127.0.0.1\> EXEC [‘/bin/sh’, ‘-c’, ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1391701320.39-156688493018489 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1391701320.39-156688493018489 && echo $HOME/.ansible/tmp/ansible-tmp-1391701320.39-156688493018489’]

PUT /var/folders/j6/q\_tyq95n1zzf\_v68908mpxy40000gn/T/tmpZVDeOO TO /Users/warren/.ansible/tmp/ansible-tmp-1391701320.38-99585849597022/setup

EXEC [‘/bin/sh’, ‘-c’, ‘/usr/bin/python /Users/warren/.ansible/tmp/ansible-tmp-1391701320.38-99585849597022/setup; rm -rf /Users/warren/.ansible/tmp/ansible-tmp-1391701320.38-99585849597022/ \>/dev/null 2\>&1’]

\<127.0.0.1\> PUT /var/folders/j6/q\_tyq95n1zzf\_v68908mpxy40000gn/T/tmp6yDJfN TO /Users/warren/.ansible/tmp/ansible-tmp-1391701320.39-156688493018489/setup

\<127.0.0.1\> EXEC [‘/bin/sh’, ‘-c’, ‘/usr/bin/python /Users/warren/.ansible/tmp/ansible-tmp-1391701320.39-156688493018489/setup; rm -rf /Users/warren/.ansible/tmp/ansible-tmp-1391701320.39-156688493018489/ \>/dev/null 2\>&1’]

ok: [127.0.0.1]

ok: [localhost]

TASK: [Launch instances] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

\<127.0.0.1\> REMOTE\_MODULE gce machine\_type=f1-micro image=centos-6-v20131120 zone=us-central1-a

\<127.0.0.1\> REMOTE\_MODULE gce machine\_type=f1-micro image=centos-6-v20131120 zone=us-central1-a

\<127.0.0.1\> EXEC [‘/bin/sh’, ‘-c’, ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1391701320.97-214772578621431 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1391701320.97-214772578621431 && echo $HOME/.ansible/tmp/ansible-tmp-1391701320.97-214772578621431’]

\<127.0.0.1\> EXEC [‘/bin/sh’, ‘-c’, ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1391701320.97-169496415593167 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1391701320.97-169496415593167 && echo $HOME/.ansible/tmp/ansible-tmp-1391701320.97-169496415593167’]

\<127.0.0.1\> PUT /var/folders/j6/q\_tyq95n1zzf\_v68908mpxy40000gn/T/tmpskK1WM TO /Users/warren/.ansible/tmp/ansible-tmp-1391701320.97-169496415593167/gce

\<127.0.0.1\> PUT /var/folders/j6/q\_tyq95n1zzf\_v68908mpxy40000gn/T/tmp1KTB82 TO /Users/warren/.ansible/tmp/ansible-tmp-1391701320.97-214772578621431/gce

\<127.0.0.1\> EXEC [‘/bin/sh’, ‘-c’, ‘/usr/bin/python /Users/warren/.ansible/tmp/ansible-tmp-1391701320.97-169496415593167/gce; rm -rf /Users/warren/.ansible/tmp/ansible-tmp-1391701320.97-169496415593167/ \>/dev/null 2\>&1’]

\<127.0.0.1\> EXEC [‘/bin/sh’, ‘-c’, ‘/usr/bin/python /Users/warren/.ansible/tmp/ansible-tmp-1391701320.97-214772578621431/gce; rm -rf /Users/warren/.ansible/tmp/ansible-tmp-1391701320.97-214772578621431/ \>/dev/null 2\>&1’]

failed: [127.0.0.1] =\> {“failed”: true, “parsed”: false}

invalid output was: Traceback (most recent call last):

File “/Users/warren/.ansible/tmp/ansible-tmp-1391701320.97-214772578621431/gce”, line 1462, in

main()

File “/Users/warren/.ansible/tmp/ansible-tmp-1391701320.97-214772578621431/gce”, line 376, in main

module.fail\_json(msg=unexpected\_error\_msg(e), changed=False)

File “/Users/warren/.ansible/tmp/ansible-tmp-1391701320.97-214772578621431/gce”, line 191, in unexpected\_error\_msg

error.http\_code, error.code, str(error.value))

AttributeError: ‘exceptions.ValueError’ object has no attribute ‘http\_code’

failed: [localhost] =\> {“failed”: true, “parsed”: false}

invalid output was: Traceback (most recent call last):

File “/Users/warren/.ansible/tmp/ansible-tmp-1391701320.97-169496415593167/gce”, line 1462, in

main()

File “/Users/warren/.ansible/tmp/ansible-tmp-1391701320.97-169496415593167/gce”, line 376, in main

module.fail\_json(msg=unexpected\_error\_msg(e), changed=False)

File “/Users/warren/.ansible/tmp/ansible-tmp-1391701320.97-169496415593167/gce”, line 191, in unexpected\_error\_msg

error.http\_code, error.code, str(error.value))

AttributeError: ‘exceptions.ValueError’ object has no attribute ‘http\_code’

FATAL: all hosts have already failed – aborting

---

<div class="post-metadata">

**Author:** ![Warren\_Strange](https://avatars.discourse-cdn.com/v4/letter/w/d78d45/32.png) [@Warren\_Strange](https://forum.ansible.com/u/Warren_Strange)\
**Post date:** [February 6, 2014, 3:54pm UTC](https://forum.ansible.com/t/gce-module-problems/14510/2 "2014-02-06T15:54:59Z")

</div>

As a follow up this looks like: [https://github.com/ansible/ansible/issues/5583](https://github.com/ansible/ansible/issues/5583)

This is what I used to create my .pem key

openssl pkcs12 -in 968bebd2b23ddd47d1dbead594f0536ee98b9670-privatekey.p12 -passin pass:notasecret -nodes -nocerts | openssl rsa -out gce.pem

---

<div class="post-metadata">

**Author:** ![Eric\_Johnson](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@Eric\_Johnson](https://forum.ansible.com/u/Eric_Johnson)\
**Post date:** [February 6, 2014, 10:50pm UTC](https://forum.ansible.com/t/gce-module-problems/14510/3 "2014-02-06T22:50:50Z")

</div>

That may be related, but your openssl commands look good so I suspect there’s something else wrong. Unfortunately, I’m (poorly) masking the real error but my guess is that it’s related to authentication. The best bet to get to the root of the problem would be to hack up the gce module (line 191) to print out the real error message. Perhaps you’re not using the correct email address to match the key or something like that.

Unrelated (I think), but your playbook looks like it’s missing an “instance\_names” parameter to pull in the values of your “names” vars.

---

<div class="post-metadata">

**Author:** ![Warren\_Strange](https://avatars.discourse-cdn.com/v4/letter/w/d78d45/32.png) [@Warren\_Strange](https://forum.ansible.com/u/Warren_Strange)\
**Post date:** [February 7, 2014, 3:16pm UTC](https://forum.ansible.com/t/gce-module-problems/14510/4 "2014-02-07T15:16:58Z")

</div>

Thanks Eric

After fixing up the error logging I am now seeing:

msg: No CA Certificates were found in CA\_CERTS\_PATH. For information on how to get required certificate files, please visit [https://libcloud.readthedocs.org/en/latest/other/ssl-certificate-validation.html](https://libcloud.readthedocs.org/en/latest/other/ssl-certificate-validation.html) -

So it looks I have some issue with the certificate.

---

<div class="post-metadata">

**Author:** ![Warren\_Strange](https://avatars.discourse-cdn.com/v4/letter/w/d78d45/32.png) [@Warren\_Strange](https://forum.ansible.com/u/Warren_Strange)\
**Post date:** [February 7, 2014, 3:31pm UTC](https://forum.ansible.com/t/gce-module-problems/14510/5 "2014-02-07T15:31:15Z")

</div>

OK - Got it working

For those on Mac OS X, libcloud needs access to a CA cert chain. You can download one at  
[http://curl.haxx.se/docs/caextract.html](http://curl.haxx.se/docs/caextract.html)

Then set the SSL\_CERT\_FILE to the path of cert.pem downloaded from above.

---

<div class="post-metadata">

**Author:** ![Eric\_Johnson](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@Eric\_Johnson](https://forum.ansible.com/u/Eric_Johnson)\
**Post date:** [February 7, 2014, 3:34pm UTC](https://forum.ansible.com/t/gce-module-problems/14510/6 "2014-02-07T15:34:41Z")

</div>

Awesome! Glad to hear you’ve got it working.

I’ll try not to mask out those errors in my next pull-request.

---

<div class="post-metadata">

**Author:** ![Drew\_Michel](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@Drew\_Michel](https://forum.ansible.com/u/Drew_Michel)\
**Post date:** [March 18, 2014, 2:46am UTC](https://forum.ansible.com/t/gce-module-problems/14510/7 "2014-03-18T02:46:06Z")

</div>

If you are on a mac you can also use brew to install a CA bundle. “brew install curl-ca-bundle”

Drew
