I'd be interested to know how that character is getting in there and what you expect it to be. u'\x99' seems to be a c1 control character so it's probably not something that jinja should be expected to handle. But the character might originally be a byte in an encoding that was unexpected that was mangled in the decoding process. Need more information about what is being returned as your tags to figure this out.
-Toshio On Fri, May 29, 2015 at 6:05 AM, Andres Silva <[email protected]> wrote: > Im running some Ansible playbooks on ec2 instances created by OpsWorks. Part > of the automation reads the ec2 tags from the instance. here is the code for > that > > - 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 > > Using that information I then do a group by using one of the tags. The main > reason to do this is to leverage group_vars and do automation that > configures settings differently for environments. In this case the tag name > is environment. Code below > > - group_by: key={{ allTags.tags.environment }} > > All this worked perfectly in Ansible 1.7. But after 1.8 the playbook fails > with the following error. Is intersting to note that the automation works > fine with instances that are not spun up by OpsWorks. OpsWorks does add some > special tags to the instance. My suspicion is that some of those tags have > special characters that are causing some sort of unicode issue. > > TASK: [group_by key={{ allTags.tags.environment }}] > *************************** > fatal: [localhost] => template error while templating string: unexpected > char u'\x99' at 2600 > > I've tried using quotes in the group_by like this but with the same result > > - group_by: key="{{ allTags.tags.environment }}" > > I also tried using a different way of referencing the dictionary value like > this > > - group_by: key={{ allTags['tags']['environment'] }} > > But had the same results > > I tried the recommendation on this thread > https://groups.google.com/forum/#!msg/ansible-project/mLgdORSFspo/PXfO76QNfMMJ > but still the same issue. > > From what I've read there are some changes in Jinja that cause this > behaviour but I have not been able to figure out the issue. Anyone has seen > this issue or has some recommendations? Thanks in advance > > > -- > 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/1c943a6b-e424-4443-8d17-eb1f954e97f9%40googlegroups.com. > 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/CAG9juEooeKUca%3De8njCNgL60fkiOdPHs21LDJjDJAugU5D9B%2Bw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
