- 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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to