Already got this on github, yes, but the problem is the 'environment'
variable in Ansible is reserved.

The "environment" keyword stores variables here.

We may consider changing this to ansible_environment as this occasionally
happens.



On Thu, Jun 19, 2014 at 8:40 AM, Michael Peters <michael00pet...@gmail.com>
wrote:

> I've filed it as 2 separate issues since they could be related but
> different (one completing but with the wrong results and the other
> failing with the traceback):
>
> https://github.com/ansible/ansible/issues/7833
> https://github.com/ansible/ansible/issues/7835
>
> But I'm still a bit confused about the why the first attempt I
> mentioned is failing. It's not throwing the traceback, it's just
> giving weird results. Is this still a YAML error? Can I write my YAML
> in a way that doesn't trigger this problem? Or is there a limit on
> which values can be templated?
>
> Thanks,
>
> On Thu, Jun 19, 2014 at 1:18 AM, James Cammarata <jcammar...@ansible.com>
> wrote:
> >  This is definitely the same YAML parsing error, but because it's
> happening
> > in the complex args it doesn't seem to be triggering the same error
> > detection/handling code. Could you please open a github issue for this as
> > well?
> >
> > Thanks!
> >
> >
> > On Wed, Jun 18, 2014 at 3:09 PM, Michael Peters <
> michael00pet...@gmail.com>
> > wrote:
> >>
> >> I'm trying to create a VPC with certain tags which are derived from
> >> variables. I feel like I can't find the right YAML/Jinja/whatever
> >> syntax to make it work though.
> >>
> >> At first I tried setting them in the resource_tags directly when using
> >> the ec2_vpc module like so:
> >>
> >>    - name: Create VPC for new environment
> >>       local_action:
> >>         module: ec2_vpc
> >>         state: present
> >>         cidr_block: 10.0.0.0/16
> >>         resource_tags: { "Name": "marketplace-{{ environment }}" }
> >>         region: "{{ aws_region }}"
> >>         dns_hostnames: true
> >>         dns_support: true
> >>         internet_gateway: true
> >>         validate_certs: true
> >>         instance_tenancy: default
> >>         wait: true
> >>         subnets: []
> >>         route_tables: []
> >>       register: new_vpc
> >>
> >> While this executes without errors it results in a VPC with the Name
> >> tag of "marketplace-{}" which is obviously not what I want.
> >>
> >> And if my Name tag starts out with a "{" like "{{ environment
> >> }}-marketplace" then I get this error:
> >>
> >> failed: [localhost] => {"failed": true, "parsed": false}
> >> invalid output was: Traceback (most recent call last):
> >>   File
> >>
> "/home/mpeters/.ansible/tmp/ansible-tmp-1403121708.45-114116167152383/ec2_vpc",
> >> line 2001, in <module>
> >>     main()
> >>   File
> >>
> "/home/mpeters/.ansible/tmp/ansible-tmp-1403121708.45-114116167152383/ec2_vpc",
> >> line 599, in main
> >>     (vpc_dict, new_vpc_id, subnets_changed, changed) =
> >> create_vpc(module, vpc_conn)
> >>   File
> >>
> "/home/mpeters/.ansible/tmp/ansible-tmp-1403121708.45-114116167152383/ec2_vpc",
> >> line 278, in create_vpc
> >>     previous_vpc = find_vpc(module, vpc_conn, id, cidr_block)
> >>   File
> >>
> "/home/mpeters/.ansible/tmp/ansible-tmp-1403121708.45-114116167152383/ec2_vpc",
> >> line 240, in find_vpc
> >>     if resource_tags and
> >> set(resource_tags.items()).issubset(set(vpc_tags.items())):
> >> TypeError: unhashable type: 'dict'
> >>
> >> So I though, maybe ec2_vpc does run the Jinja templating on the values
> >> in the resource_tags dictionary. So I then tried to create the VPC
> >> with a dummy name tag, save it's vpc_id and then use ec2_tag to add
> >> the tags in a separate task:
> >>
> >>     - name: Tag the new VPC
> >>       local_action: ec2_tag resource={{ new_vpc.vpc_id }} region={{
> >> aws_region }} state=present
> >>       args:
> >>         tags:
> >>           Name: "marketplace-{{ environment }}"
> >>
> >> But this results in the same thing (vpc with a Name tag of
> >> "marketplace-{}" instead of something like "marketplace-branch-XYZ".
> >>
> >> Am I confused about the YAML/Jinja syntax to accomplish what I want or
> >> is using variables in EC2 tags not supported? And if it's not
> >> supported would pull requests to add it be something folks would like?
> >>
> >> Thanks
> >>
> >> --
> >> 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 ansible-project+unsubscr...@googlegroups.com.
> >> To post to this group, send email to ansible-project@googlegroups.com.
> >> To view this discussion on the web visit
> >>
> https://groups.google.com/d/msgid/ansible-project/CAJQqANdT3ZGVdMHTosC9WQm23qk%3DmSLTJED8v51edgb8gV-dWQ%40mail.gmail.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 ansible-project+unsubscr...@googlegroups.com.
> > To post to this group, send email to ansible-project@googlegroups.com.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/CAMFyvFgHWZdOgc%3DazoSZO5tzWA-W%3DoCBMJRBL7nYeFFH%2BQ%2BOWg%40mail.gmail.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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAJQqANdesB%3D2mTKuSR%2BXZahBcwSiz_PEkoZ_Pid7%3D3Stru%3DxPg%40mail.gmail.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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgyggXCq0j-Qq%2B-X3SScf%3D0D4zbGgs8EkU0ER1JMekogDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to