Have you looked at the Ansible 2.0 modules for deploying a VPC and subnets?
It may simplify the setting of facts. I don't have time to give you an
example at the moment but have found the new modules a lot easier to use.

http://docs.ansible.com/ansible/ec2_vpc_net_module.html

On 16 March 2016 at 07:16, Michael Baydoun <[email protected]> wrote:

> - name: create all vpc's for all accounts and regions
>   ec2_vpc:
>     state: "{{ item.internet_gateway | default('no') }}"
>     region: "{{ item.region }}"
>     state: "{{ item.state | default('present') }}"
>     cidr_block: "{{ item.cidr_block }}"
>     resource_tags: "{{ item.resource_tags }}"
>     subnets: "{{ item.subnets }}"
>     wait: yes
>   when: item.controlEnvironment == env
>   with_items: "{{ vpcList }}"
>   register: vpcOut
>
> - set_fact:
>     mainVpcId: "{{ item.vpc_id }}"
>   with_items: vpcOut.results
>   when:
>     - not item | skipped
>     - item.item.resource_tags.WhichRegion == 'mainRegion'
>
> - set_fact:
>     mainSubnet0: "{{ item.subnets.0.id }}"
>   with_items: vpcOut.results
>   when:
>     - not item | skipped
>     - item.item.resource_tags.WhichRegion == 'mainRegion'
>
> - set_fact:
>     mainSubnet1: "{{ item.subnets.1.id }}"
>   with_items: vpcOut.results
>   when:
>     - not item | skipped
>     - item.item.resource_tags.WhichRegion == 'mainRegion'
>
> - set_fact:
>     mainSubnet2: "{{ item.subnets.2.id }}"
>   with_items: vpcOut.results
>   when:
>     - not item | skipped
>     - item.item.resource_tags.WhichRegion == 'mainRegion'
>
> --
> 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/75e5da0c-8212-4b06-aa9b-c07d7462699a%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/75e5da0c-8212-4b06-aa9b-c07d7462699a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Steve

-- 
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%2BemtqucmjkAZXTLEYxrMy8mmKqSPHzituC54st%3Da9LtyePxFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to