Hi
I have a simple playbook that should create an instance on GCP (versions of
which) I have used before to create VMs but which is now failing
with ResourceNotFoundError.
$ ansible-playbook --flush-cache -i am.ini ./auto-managed-vm.yaml
FLUSHING FACT CACHE
***********************************************************
PLAY [Create Compute Engine instances]
****************************************
TASK: [Launch instances]
******************************************************
failed: [localhost -> 127.0.0.1] => {"failed": true, "parsed": false}
Request: /zones/europe-west1-d/instances/auto-managed-1
Traceback (most recent call last):
File
"/Users/rcorfield/.ansible/tmp/ansible-tmp-1446743117.58-165976684615221/gce"
, line 2210, in <module>
main()
File
"/Users/rcorfield/.ansible/tmp/ansible-tmp-1446743117.58-165976684615221/gce"
, line 497, in main
module, gce, inames)
File
"/Users/rcorfield/.ansible/tmp/ansible-tmp-1446743117.58-165976684615221/gce"
, line 359, in create_instances
inst = gce.ex_get_node(name, lc_zone)
File "/Library/Python/2.7/site-packages/libcloud/compute/drivers/gce.py",
line 3917, in ex_get_node
response = self.connection.request(request, method='GET').object
File "/Library/Python/2.7/site-packages/libcloud/common/google.py", line
684, in request
*args, **kwargs)
File "/Library/Python/2.7/site-packages/libcloud/common/base.py", line 736
, in request
response = responseCls(**kwargs)
File "/Library/Python/2.7/site-packages/libcloud/common/base.py", line 119
, in __init__
self.object = self.parse_body()
File "/Library/Python/2.7/site-packages/libcloud/common/google.py", line
259, in parse_body
raise ResourceNotFoundError(message, self.status, code)
libcloud.common.google.ResourceNotFoundError: {u'domain': u'global', u
'message': u"The resource
'projects/<PROJECT>/zones/europe-west1-d/instances/auto-managed-1' was not
found", u'reason': u'notFound'}
FATAL: all hosts have already failed -- aborting
When I captured the temporary file:
Users/rcorfield/.ansible/tmp/ansible-tmp-1446743117.58-165976684615221/gce
... I could see that it was executing code under the impression that the
current state of the machine was either in state 'active' or 'present'
which explains why I'm getting Resource Not Found Error, because it's
looking for a machine that it thinks is active which in fact doesn't exist
... because I'm trying to create it.
Can anyone give me some possible hints has to what I'm doing wrong here?
Thanks in advance.
Richard
Playbook (with sensitive information removed) follows:
- name: Create Compute Engine instances
hosts: local
gather_facts: no
vars:
names: auto-managed-1
machine_type: f1-micro
image: rdc-test-image
zone: europe-west1-d
pid: <...>
email: <...>
pem: <...>
tasks:
- name: Launch instances
local_action: gce instance_names="{{ names }}"
machine_type="{{ machine_type }}"
disk_auto_delete=false
image="{{ image }}" zone="{{ zone }}"
project_id="{{ pid }}" pem_file="{{ pem }}"
service_account_email="{{ email }}"
register: gce
- name: Wait for SSH to come up
local_action: wait_for host="{{ item.public_ip }}" port=22 delay=10
timeout=60 state=started
with_items: gce.instance_data
- add_host: name="{{ item.public_ip }}" groups=created
with_items: gce.instance_data
- name: Install required packages
hosts: created
sudo: True
tasks:
- name: Install Java
apt: pkg={{ item }} update_cache=yes cache_valid_time=3600
with_items: openjdk-7-jdk
--
Follow us on: <https://plus.google.com/+Appsbroker/>
<https://twitter.com/appsbroker>
<http://www.linkedin.com/company/appsbroker-consulting-limited/careers?trk=top_nav_careers>
Appsbroker Consulting Limited, Registered office: Appsbroker House, The
Square, Swindon,
SN1 3EB, Company Number: 5702796, VAT Number: GB 876 3533 92, Company
registered in England and Wales.
________________________________________
PLEASE NOTE AS RECIPIENT OF THIS EMAIL: Any views or opinions presented are
solely those of the author and do not represent those of Appsbroker
Consulting Limited. This e-mail is confidential and intended solely for the
addressee. If you are not the intended recipient, be advised that you have
received this mail in error and that any use, dissemination, forwarding,
printing or copying of this e-mail is strictly prohibited. Furthermore, if
you are not the intended recipient, please email it back to the sender and
then immediately permanently delete it.
--
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/2a0f571a-9540-4384-9bef-82dae265870c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.