You have an indentation error here for starters:
- name: Create security group
ec2_group:
name: "some-name"
description: "some description"
vpc_id: "vpc-blahblah"
region: "eu-north-4"
rules:
- proto: tcp
from_port: 443
to_port: 443
cidr_ip: "{{ item }}"
with_items:
- addr1/32
- addr2/32
- etc/32
with_items should be at the same level as "ec2_group".
On Mon, Aug 4, 2014 at 2:45 PM, Chuzzy <[email protected]> wrote:
> Ansible 1.7
>
> I am trying to use either with_items or with_nested (if including a list
> of ports as well) to traverse a list of cidr addresses and create sec group
> rules from that ..
>
> Basically, this is failing repeatedly .. and I guess its down to confusion
> around the correct scope to apply the with_items keyword ..
>
> I have something like this ..
>
> - name: Create security group
> ec2_group:
> name: "some-name"
> description: "some description"
> vpc_id: "vpc-blahblah"
> region: "eu-north-4"
> rules:
> - proto: tcp
> from_port: 443
> to_port: 443
> cidr_ip: "{{ item }}"
> with_items:
> - addr1/32
> - addr2/32
> - etc/32
>
>
> In the above scope of usage, ansible is not able to see the variable ..
> it's exactly the same below when the with_items is nested in-line with and
> the following also does not work ..
>
> - name: Create security group
> ec2_group:
> name: "some-name"
> description: "some description"
> vpc_id: "vpc-blahblah"
> region: "eu-north-4"
> rules:
> - proto: tcp
> from_port: 443
> to_port: 443
> cidr_ip: "{{ item }}"
> with_items:
> - addr1/32
> - addr2/32
> - etc/32
>
> The only variant that works is when it's aligned with the ec2group line
> (see immediately below) .. but it does not iterate and create several
> security groups .. it iteratively, replaces a single entry with the latest
> value in the loop ..
>
>
> - name: Create security group
> ec2_group:
> name: "some-name"
> description: "some description"
> vpc_id: "vpc-blahblah"
> region: "eu-north-4"
> rules:
> - proto: tcp
> from_port: 443
> to_port: 443
> cidr_ip: "{{ item }}"
> with_items:
> - addr1/32
> - addr2/32
> - etc/32
>
>
> I have looked at the docs for both ec2group and with_items, and it's not
> obvious how this is supposed to be used .. I suspect I may be making some
> basic mistake/omission .. Any suggestions? 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/abab1cf3-c1f6-4966-bad4-2520239c729d%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/abab1cf3-c1f6-4966-bad4-2520239c729d%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%2BnsWgztaTbpBFTXE_RH12mLY3wgvdXqA3ue%3DTZrMiRG%2BBDQXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.