-
Notifications
You must be signed in to change notification settings - Fork 253
/
Copy pathbuild_aws.yml
70 lines (64 loc) · 2.13 KB
/
build_aws.yml
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
- name: Build the Cloud Environment
hosts: localhost
connection: local
gather_facts: False
tasks:
- name: Create the VPC
ec2_vpc_net:
region: "{{ cloud_config.region }}"
cidr_block: "{{ cloud_config.vpc_cidr }}"
name: "{{ cloud_config.vpc_name }}"
state: present
register: cluster_vpc
tags: always
- name: Create the Subnet
ec2_vpc_subnet:
region: "{{ cloud_config.region }}"
az: "{{ cloud_config.zone }}"
vpc_id: "{{ cluster_vpc.vpc.id }}"
cidr: "{{ cloud_config.subnet_cidr }}"
resource_tags:
Name: "{{ cloud_config.subnet_name }}"
state: present
register: cluster_subnet
- name: Add an Internet Gateway to the VPC
ec2_vpc_igw:
region: "{{ cloud_config.region }}"
vpc_id: "{{ cluster_vpc.vpc.id }}"
state: present
when: cloud_config.internet_gateway
register: cluster_igw
- name: Set up the public subnet route table for the Internet Gateway
ec2_vpc_route_table:
region: "{{ cloud_config.region }}"
vpc_id: "{{ cluster_vpc.vpc.id }}"
subnets: "{{ cluster_subnet.subnet.id }}"
routes:
- dest: 0.0.0.0/0
gateway_id: "{{ cluster_igw.gateway_id }}"
state: present
when: cluster_igw.gateway_id is defined
- name: Create Security Groups
ec2_group:
region: "{{ cloud_config.region }}"
name: "{{ item.name }}"
vpc_id: "{{ cluster_vpc.vpc.id }}"
description: "{{ item.description }}"
purge_rules: false
purge_rules_egress: false
rules: "{{ item.rules }}"
with_items: "{{ cloud_config.security_groups }}"
register: cluster_security_groups
tags: security_groups
- name: Upload the SSH Key
ec2_key:
region: "{{ cloud_config.region }}"
name: "{{ cloud_config.ssh.keyname }}"
key_material: "{{ lookup('file', cloud_config.ssh.publickey) }}"
state: present
wait: yes
- name: Build AWS Nodes
include_tasks: build_aws_nodes.yml
when: item.count > 0
with_items: "{{ nodes }}"