vpc.yml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ---
  2. - name: Create AWS VPC
  3. ec2_vpc_net:
  4. state: present
  5. cidr_block: "{{ openshift_aws_vpc.cidr }}"
  6. dns_support: True
  7. dns_hostnames: True
  8. region: "{{ openshift_aws_region }}"
  9. name: "{{ openshift_aws_clusterid }}"
  10. tags: "{{ openshift_aws_vpc_tags }}"
  11. register: vpc
  12. - name: Sleep to avoid a race condition when creating the vpc
  13. pause:
  14. seconds: 5
  15. when: vpc.changed
  16. - name: assign the vpc igw
  17. ec2_vpc_igw:
  18. region: "{{ openshift_aws_region }}"
  19. vpc_id: "{{ vpc.vpc.id }}"
  20. register: igw
  21. - name: assign the vpc subnets
  22. ec2_vpc_subnet:
  23. region: "{{ openshift_aws_region }}"
  24. vpc_id: "{{ vpc.vpc.id }}"
  25. cidr: "{{ item.cidr }}"
  26. az: "{{ item.az }}"
  27. resource_tags:
  28. Name: "{{ item.az }}"
  29. with_items: "{{ openshift_aws_vpc.subnets[openshift_aws_region] }}"
  30. - name: Grab the route tables from our VPC
  31. ec2_vpc_route_table_facts:
  32. region: "{{ openshift_aws_region }}"
  33. filters:
  34. vpc-id: "{{ vpc.vpc.id }}"
  35. register: route_table
  36. - name: update the route table in the vpc
  37. ec2_vpc_route_table:
  38. lookup: id
  39. route_table_id: "{{ route_table.route_tables[0].id }}"
  40. vpc_id: "{{ vpc.vpc.id }}"
  41. region: "{{ openshift_aws_region }}"
  42. tags:
  43. Name: "{{ openshift_aws_vpc_name }}"
  44. routes:
  45. - dest: 0.0.0.0/0
  46. gateway_id: igw
  47. register: route_table_out