gce module problems

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

As a follow up this looks like: 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

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.

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 -

So it looks I have some issue with the certificate.

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

Then set the SSL_CERT_FILE to the path of cert.pem downloaded from above.

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

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

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

Drew