summaryrefslogtreecommitdiffstats
path: root/roles/openshift_aws_vpc/tasks/main.yml
blob: cfe08dae54228d23f5a54781abf94b99f51ab296 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
- name: Create AWS VPC
  ec2_vpc_net:
    state: present
    cidr_block: "{{ r_openshift_aws_vpc_cidr }}"
    dns_support: True
    dns_hostnames: True
    region: "{{ r_openshift_aws_vpc_region }}"
    name: "{{ r_openshift_aws_vpc_clusterid }}"
    tags:
      Name: "{{ r_openshift_aws_vpc_clusterid }}"
  register: vpc

- name: Sleep to avoid a race condition when creating the vpc
  pause:
    seconds: 5
  when: vpc.changed

- name: assign the vpc igw
  ec2_vpc_igw:
    region: "{{ r_openshift_aws_vpc_region }}"
    vpc_id: "{{ vpc.vpc.id }}"
  register: igw

- name: assign the vpc subnets
  ec2_vpc_subnet:
    region: "{{ r_openshift_aws_vpc_region }}"
    vpc_id: "{{ vpc.vpc.id }}"
    cidr: "{{ item.cidr }}"
    az: "{{ item.az }}"
    resource_tags:
      Name: "{{ item.az }}"
  with_items: "{{ r_openshift_aws_vpc_subnets[r_openshift_aws_vpc_region] }}"

- name: Grab the route tables from our VPC
  ec2_vpc_route_table_facts:
    region: "{{ r_openshift_aws_vpc_region }}"
    filters:
      vpc-id: "{{ vpc.vpc.id }}"
  register: route_table

- name: update the route table in the vpc
  ec2_vpc_route_table:
    lookup: id
    route_table_id: "{{ route_table.route_tables[0].id }}"
    vpc_id: "{{ vpc.vpc.id }}"
    region: "{{ r_openshift_aws_vpc_region }}"
    tags:
      Name: "{{ r_openshift_aws_vpc_name }}"
    routes:
    - dest: 0.0.0.0/0
      gateway_id: igw
  register: route_table_out