-
Notifications
You must be signed in to change notification settings - Fork 0
/
first_stack.yaml
executable file
·293 lines (252 loc) · 8.68 KB
/
first_stack.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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
heat_template_version: 2013-05-23
# # # # # # # # # # # # # # # # # # # # # # # # #
# DESCRIPTION #
# # # # # # # # # # # # # # # # # # # # # # # # #
description: >
Heat template to deploy scalables nginx webservers
with an haproxy load balancer
# # # # # # # # # # # # # # # # # # # # # # # # #
# PARAMETERS #
# # # # # # # # # # # # # # # # # # # # # # # # #
parameters:
key_name:
type: string
label: Key Name
description: Name of key-pair to be used for compute instance
image_id: # das sollte man vermeiden
type: string
label: Image ID - ubuntu-xenial-16.04_softwareconfig_0.0.2
description: Image to be used for compute instance
default: fbb3d9ed-615d-453c-9419-cf6165356384
instance_type:
type: string
label: Instance Type
description: Type of instance (flavor) to be used
default: gp1.small
availability_zone:
type: string
description: Name of the availability zone for the instance
default: zone00
public_net:
type: string
description: public network id
default: public00
secgroup_id:
type: string
description : Id of the security groupe
default: default
# # # # # # # # # # # # # # # # # # # # # # # # #
# RESOURCES #
# # # # # # # # # # # # # # # # # # # # # # # # #
resources:
private_net:
type: OS::Neutron::Net
properties:
name: my_network
private_subnet:
type: OS::Neutron::Subnet
properties:
name: subnet
network_id: { get_resource: private_net }
cidr: 192.168.0.0/24
gateway_ip: 192.168.0.1
router1:
type: OS::Neutron::Router
properties:
external_gateway_info:
network: { get_param: public_net }
router1_interface:
type: OS::Neutron::RouterInterface
properties:
router_id: { get_resource: router1 }
subnet_id: { get_resource: private_subnet }
nginx_1_port:
type: OS::Neutron::Port
properties:
network_id: { get_resource: private_net }
security_groups: [ get_param: secgroup_id ]
fixed_ips:
- subnet_id: { get_resource: private_subnet }
#nginx_1_floating_ip:
#type: OS::Neutron::FloatingIP
#properties:
#floating_network: { get_param: public_net }
#float_ip_ass:
#type: OS::Neutron::FloatingIPAssociation
#properties:
#floatingip_id: { get_resource: nginx_1_floating_ip }
#port_id: { get_resource: nginx_1_port }
nginx1:
type: OS::Nova::Server
properties:
name: Nginx_1
key_name: { get_param: key_name }
image: { get_param: image_id }
flavor: { get_param: instance_type }
availability_zone: { get_param: availability_zone }
networks:
- port: { get_resource: nginx_1_port }
user_data_format: RAW
user_data:
str_replace:
template: |
#!/bin/bash -v
echo "Installing nginx..."
apt-get update
apt-get -y install $server
echo "Adjusting firewall..."
ufw allow 'Nginx HTTP'
systemctl restart $server
systemctl enable $server
echo -e "<!DOCTYPE html> \\n
<html> \\n
<head> \\n
<title>Welcome to nginx!</title>\\n
<style>\\n
body {\\n
width: 35em;\\n
margin: 0 auto;\\n
font-family: Tahoma, Verdana, Arial, sans-serif;\\n
}\\n
</style>\\n
</head>\\n
<body>\\n
<h1>Welcome to nginx!</h1>\\n
<h3>Hostname: $ip </h3>\\n
<p>If you see this page, the nginx web server is successfully installed and\\n
working. Further configuration is required.</p>\\n
<p>For online documentation and support please refer to\\n
<a href="http://nginx.org/">nginx.org</a>.<br/>\\n
Commercial support is available at\\n
<a href="http://nginx.com/">nginx.com</a>.</p>\\n
<p><em>Thank you for using nginx.</em></p>\\n
</body>\\n
</html>\\n " > /usr/share/nginx/html/index.html
cat /usr/share/nginx/html/index.html > /var/www/html/index.nginx-debian.html
params:
$server: nginx
$ip: server1
pool_member1:
type: OS::Neutron::LBaaS::PoolMember
#depends_on: nginx1
properties:
pool: { get_resource: pool }
address: { get_attr: [nginx1, first_address] }
protocol_port: 80
subnet: { get_resource: private_subnet }
nginx_2_port:
type: OS::Neutron::Port
properties:
network_id: { get_resource: private_net }
security_groups: [ get_param: secgroup_id ]
fixed_ips:
- subnet_id: { get_resource: private_subnet }
nginx2:
type: OS::Nova::Server
properties:
name: Nginx_2
key_name: { get_param: key_name }
image: { get_param: image_id }
flavor: { get_param: instance_type }
availability_zone: { get_param: availability_zone }
networks:
- port: { get_resource: nginx_2_port }
user_data_format: RAW
user_data:
str_replace:
template: |
#!/bin/bash -v
echo "Installing nginx..."
apt-get update
apt-get -y install $server
echo "Adjusting firewall..."
ufw allow 'Nginx HTTP'
systemctl restart $server
systemctl enable $server
echo -e "<!DOCTYPE html> \\n
<html> \\n
<head> \\n
<title>Welcome to nginx!</title>\\n
<style>\\n
body {\\n
width: 35em;\\n
margin: 0 auto;\\n
font-family: Tahoma, Verdana, Arial, sans-serif;\\n
}\\n
</style>\\n
</head>\\n
<body>\\n
<h1>Welcome to nginx!</h1>\\n
<h3>Hostname: $ip </h3>\\n
<p>If you see this page, the nginx web server is successfully installed and\\n
working. Further configuration is required.</p>\\n
<p>For online documentation and support please refer to\\n
<a href="http://nginx.org/">nginx.org</a>.<br/>\\n
Commercial support is available at\\n
<a href="http://nginx.com/">nginx.com</a>.</p>\\n
<p><em>Thank you for using nginx.</em></p>\\n
</body>\\n
</html>\\n " > /usr/share/nginx/html/index.html
cat /usr/share/nginx/html/index.html > /var/www/html/index.nginx-debian.html
params:
$server: nginx
$ip: server2
pool_member2:
#depends_on: nginx2
type: OS::Neutron::LBaaS::PoolMember
properties:
pool: { get_resource: pool }
address: { get_attr: [nginx2, first_address] }
protocol_port: 80
subnet: { get_resource: private_subnet }
lbaas:
type: OS::Neutron::LBaaS::LoadBalancer
properties:
name: NginxLbaaS
vip_subnet: { get_resource: private_subnet }
listener:
type: OS::Neutron::LBaaS::Listener
properties:
loadbalancer: { get_resource: lbaas }
protocol: HTTP
protocol_port: 80
pool:
type: OS::Neutron::LBaaS::Pool
properties:
name: lb_front_pool
protocol: HTTP
lb_algorithm: ROUND_ROBIN
listener: { get_resource: listener }
lbaas_port:
type: OS::Neutron::Port
properties:
network: { get_resource: private_net }
device_id: { get_resource: lbaas }
security_groups: [ get_param: secgroup_id ]
fixed_ips:
- subnet_id: { get_attr: [ lbaas, vip_subnet_id ] }
lbaas_floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network: { get_param: public_net }
port_id: { get_attr: [ lbaas, vip_port_id ] }
#fixed_ip_address: { get_attr: [ lbaas, vip_address ] }
depends_on:
- lbaas
lb_ip_assoc:
type: OS::Neutron::FloatingIPAssociation
properties:
floatingip_id: { get_resource: lbaas_floating_ip }
port_id: { get_attr: [ lbaas, vip_port_id ] }
#monitor:
# # # # # # # # # # # # # # # # # # # # # # # # #
# OUTPUTS #
# # # # # # # # # # # # # # # # # # # # # # # # #
outputs:
instance_ip1:
description: The IP address of the deployed instance
value: { get_attr: [nginx1, first_address] }
instance_ip2:
description: The IP address of the deployed instance
value: { get_attr: [nginx2, first_address] }
#add lbaas floating ip