Hello!
I've found a weird issue, which makes a playbook fail 'sometimes' in a
way that's entirely related to the local Ansible code. It looks like
this:
...
tasks:
- name: get a unique ID for an EC2 cluster
local_action: >
command date "+%N"
register: timestamp
- name: launch ec2 instances
local_action: >
ec2 key_name={{ ssh_key_name }}
group={{ security_group }}
instance_type={{ instance_type }}
image={{ image }}
region={{ region }}
count={{ num_hosts }}
wait=true
instance_tags='{ "cluster_id" : {{ timestamp.stdout }} }'
register: ec2results
...
Have a look at the "instance_tags". As you can see here, I would like to
tag all EC2 hosts with a 'cluster_id' key, which consists of a
timestamp. Ever now and then, maybe 50% of the time, when I run this
playbook, I get this error here:
PLAY [create the cluster hosts] ***********************************************
TASK: [get unique ID for cluster] *********************************************
changed: [localhost]
TASK: [launch ec2 instances] **************************************************
failed: [localhost] => {"failed": true}
msg: unable to evaluate dictionary for instance_tags
FATAL: all hosts have already failed -- aborting
I can start the playbook immediately again, and usually, it works just
fine then. It's almost as if sometimes the timestamp doesn't really
become immediately available, or some similar issue.
Is there any reason for this? Am I doing something wrong? Should this
not work as I'm expecting?
Juergen