This repository has been archived by the owner on Jan 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
aws-swarm-blueprint.yaml
215 lines (185 loc) · 5.86 KB
/
aws-swarm-blueprint.yaml
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
tosca_definitions_version: cloudify_dsl_1_3
description: >
This blueprint creates a Docker Swarm Cluster.
It includes a master and a worker.
imports:
- http://www.getcloudify.org/spec/cloudify/4.0/types.yaml
- http://getcloudify.org.s3.amazonaws.com/spec/aws-plugin/1.4.4/plugin.yaml
- imports/swarm-blueprint.yaml
inputs:
key_name:
default: docker-swarm-blueprint-key
private_key_path:
default: ~/.ssh/docker-swarm-blueprint-key.pem
vpc_id:
type: string
vpc_cidr_block:
type: string
public_subnet_id:
type: string
public_subnet_cidr:
type: string
private_subnet_id:
type: string
private_subnet_cidr:
type: string
ec2_region_name:
default: us-east-1
ec2_region_endpoint:
default: ec2.us-east-1.amazonaws.com
availability_zone:
default: us-east-1e
ami:
description: >
Amazon Ubuntu 14.04 AMI
instance_type:
description: >
Agent VM Instance Type
agent_user:
default: ubuntu
dsl_definitions:
aws_config: &aws_config
aws_access_key_id: { get_secret: aws_access_key_id }
aws_secret_access_key: { get_secret: aws_secret_access_key }
ec2_region_name: { get_input: ec2_region_name }
ec2_region_endpoint: { get_input: ec2_region_endpoint }
node_templates:
manager_host:
type: cloudify.aws.nodes.Instance
properties:
agent_config:
install_method: remote
port: 22
user: { get_input: agent_user }
key: { get_property: [ key, private_key_path ] }
min_workers: 2
aws_config: *aws_config
image_id: { get_input: ami }
instance_type: { get_input: instance_type }
parameters:
user_data: |
#!/bin/bash
sudo groupadd docker
sudo gpasswd -a ubuntu docker
placement: { get_property: [ public_subnet, availability_zone ] }
relationships:
- type: cloudify.aws.relationships.instance_connected_to_keypair
target: key
- type: cloudify.aws.relationships.instance_connected_to_subnet
target: public_subnet
- type: cloudify.aws.relationships.instance_connected_to_security_group
target: ssh_group
- type: cloudify.aws.relationships.instance_connected_to_security_group
target: swarm_secgroup
- type: cloudify.aws.relationships.instance_connected_to_elastic_ip
target: manager_public_ip
worker_host:
type: cloudify.aws.nodes.Instance
properties:
agent_config:
install_method: remote
port: 22
user: { get_input: agent_user }
key: { get_property: [ key, private_key_path ] }
min_workers: 2
aws_config: *aws_config
image_id: { get_input: ami }
instance_type: { get_input: instance_type }
parameters:
user_data: |
#!/bin/bash
sudo groupadd docker
sudo gpasswd -a ubuntu docker
placement: { get_property: [ private_subnet, availability_zone ] }
relationships:
- type: cloudify.aws.relationships.instance_connected_to_keypair
target: key
- type: cloudify.aws.relationships.instance_connected_to_subnet
target: private_subnet
- type: cloudify.aws.relationships.instance_connected_to_security_group
target: ssh_group
- type: cloudify.aws.relationships.instance_connected_to_security_group
target: swarm_secgroup
ssh_group:
type: cloudify.aws.nodes.SecurityGroup
properties:
aws_config: *aws_config
description: Puppet Group
rules:
- ip_protocol: tcp
from_port: 22
to_port: 22
cidr_ip: { get_input: vpc_cidr_block }
relationships:
- type: cloudify.aws.relationships.security_group_contained_in_vpc
target: vpc
swarm_secgroup:
type: cloudify.aws.nodes.SecurityGroup
properties:
aws_config: *aws_config
description: Swarm Group
rules:
- ip_protocol: tcp
from_port: 22
to_port: 22
cidr_ip: { get_input: vpc_cidr_block }
- ip_protocol: tcp
from_port: 80
to_port: 80
cidr_ip: 0.0.0.0/0
- ip_protocol: tcp
from_port: 2375
to_port: 2375
cidr_ip: { get_input: vpc_cidr_block }
- ip_protocol: tcp
from_port: 2377
to_port: 2377
cidr_ip: { get_input: vpc_cidr_block }
relationships:
- type: cloudify.aws.relationships.security_group_contained_in_vpc
target: vpc
public_subnet:
type: cloudify.aws.nodes.Subnet
properties:
aws_config: *aws_config
use_external_resource: true
resource_id: { get_input: public_subnet_id }
cidr_block: { get_input: public_subnet_cidr }
availability_zone: { get_input: availability_zone }
relationships:
- type: cloudify.aws.relationships.subnet_contained_in_vpc
target: vpc
private_subnet:
type: cloudify.aws.nodes.Subnet
properties:
aws_config: *aws_config
use_external_resource: true
resource_id: { get_input: private_subnet_id }
cidr_block: { get_input: private_subnet_cidr }
availability_zone: { get_input: availability_zone }
relationships:
- type: cloudify.aws.relationships.subnet_contained_in_vpc
target: vpc
vpc:
type: cloudify.aws.nodes.VPC
properties:
aws_config: *aws_config
use_external_resource: true
resource_id: { get_input: vpc_id }
cidr_block: { get_input: vpc_cidr_block }
key:
type: cloudify.aws.nodes.KeyPair
properties:
aws_config: *aws_config
resource_id: { get_input: key_name }
private_key_path: { get_input: private_key_path }
manager_public_ip:
type: cloudify.aws.nodes.ElasticIP
properties:
aws_config: *aws_config
domain: vpc
outputs:
swarm_info:
value:
manager_ip: {get_attribute: [manager_public_ip, aws_resource_id]}
manager_port: 2375