Hello,
I am experiencing exactly the same problem with ec2 tags.
I can easily set them up but following steps fails.
If I simply re run the playbook it just works...
Il giorno martedì 15 aprile 2014 22:45:45 UTC+2, Michael DeHaan ha scritto:
>
> Those two steps are in fact executed one before each other so you
> shouldn't see any race condition behavior.
>
> However, this value is in fact JSON, as you have it, so I'm wondering if
> you're occasionally getting a parse error based on what the time is, due to
> a lack of quoting.
>
> The better way to use this module is like so:
>
> ec2_key:
> key_name: "{{ ssh_key_name }}"
> # all of the arguments here...
> instance_tags:
> cluster_id: "{{ timestamp.stdout }}"
>
> Which may help. I'd try it and see.
>
> Using the complex arguments form eliminates the need to have the JSON
> string.
>
>
>
> On Wed, Apr 9, 2014 at 6:41 PM, Juergen Brendel <[email protected]
> <javascript:>> wrote:
>
>>
>>
>> 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
>>
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/1397083306.5876.40.camel%40localhost
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
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/b881faab-fe56-418a-b201-88864a899755%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.