If you are trying to manage ec2 roles based on tag, it would be much more idiomatic to use the EC2 dynamic inventory source and just target the tag group with the "hosts" spec.
What you have in the above is rather weird because you have the roles attached to the play configuring localhost, and I doubt you want to configure localhost. On Thu, Sep 25, 2014 at 2:49 PM, Andres Silva <[email protected]> wrote: > I have the following playbook. As you can see Im reading the ec2 tags and > then attempt to run a role based on a condition. But the condition is never > met and it always skips the role. As you can see Im printing the value of > the variable with debug and I can see the value matches. But in the code > the evaluation fails and the condition is never met. I tried different > variant for the allTags.tags.role like adding quotes and brackets. Nothing > worked. I finally decided to abandon the role based on conditional idea and > went with group_by. But I would like to understand what I was doing wrong > here. Any help would be greatly appreciated. > > --- - hosts: localhost sudo: true tasks: - name: gather ec2 facts > action: ec2_facts - name: get environment tag action: > ec2_tag resource={{ ansible_ec2_instance_id }} region={{ > ansible_ec2_placement_region }} state=list register: allTags - > debug: var=allTags.tags.role roles: - { role: storm-configure, when: > allTags.tags.role == 'storm' } - { role: nimbus, when: allTags.tags.role > == 'nimbus' } > > -- > 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/c9a9d771-af36-45dd-8ce9-371457dbe80f%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/c9a9d771-af36-45dd-8ce9-371457dbe80f%40googlegroups.com?utm_medium=email&utm_source=footer> > . > 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/CA%2BnsWgzbbqKNYm%3DNmouXuMRGohZ7rj4yPmM3yAcT0LDUweeVTA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
