This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudInit.yaml
229 lines (211 loc) · 6.45 KB
/
cloudInit.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
heat_template_version: queens
## cli deploy
#$ openstack stack create <--parameter FGT_count=2> -t cloudInit.yml <stack_name>
# cli scale-up
#$ openstack stack update --wait --existing --parameter FGT_count=3 --parameter WS_count=2 <stack_name>
description: >
Openstack demo infrastucture for Fortinet SecDays.
The template deploys 4 fortigates (FGT), 2 FGT are used in HA
2 others FGT are deployed with a resource group between the
two first one in parallele to provided security in a High Availability
################## PARAMETERS ##################
parameters:
mgmt_net:
type: string
description: My private network
default: "mgmt"
public_net:
type: string
description: External network for floating ips
default: "public"
inet:
type: string
description: External network for floating ips
default: "inet"
web_server_img_name:
type: string
description: Web Server image name in openstack
default: "web_server"
web_server_flavor:
type: string
description: Web Server flavor name in openstack
default: "ds512M"
fortigate_img_name:
type: string
description: Fortigate image name in openstack
default: "fortigateVM_604"
fortigate_flavor:
type: string
description: Fortigate flavor name in openstack
default: "m1.fgt"
FGT_count:
type: number
description: Number of FGT deployed
default: 2
WS_count:
type: number
description: Number of Web Server deployed
default: 2
WAN_CIDR:
type: string
default: "10.10.1"
LAN_CIDR:
type: string
default: "10.20.1"
Web_Server_CIDR:
type: string
description: CIDR for Web servers subnet
default: "10.100.1"
HA_CIDR:
type: string
description: CIDR for HA subnet
default: "1.1.1"
################## RESOURCES ##################
resources:
# SUBNETs
WAN:
type: OS::Neutron::Net
properties:
name: "WAN"
port_security_enabled: false
WAN_subnet:
type: OS::Neutron::Subnet
properties:
name: "WAN_subnet"
network_id: { get_resource: WAN }
cidr: { list_join: [".", [{ get_param: WAN_CIDR }, "0/24"]] }
gateway_ip: { list_join: [".", [{ get_param: WAN_CIDR}, "254"]] }
allocation_pools:
- start: { list_join: [".", [{ get_param: WAN_CIDR}, "3"]] }
end: { list_join: [".", [{ get_param: WAN_CIDR}, "250"]] }
LAN:
type: OS::Neutron::Net
properties:
name: "LAN"
port_security_enabled: false
LAN_subnet:
type: OS::Neutron::Subnet
properties:
name: "LAN_subnet"
network_id: { get_resource: LAN }
cidr: { list_join: [".", [{ get_param: LAN_CIDR }, "0/24"]] }
gateway_ip: null
allocation_pools:
- start: { list_join: [".", [{ get_param: LAN_CIDR}, "3"]] }
end: { list_join: [".", [{ get_param: LAN_CIDR}, "250"]] }
net01:
type: OS::Neutron::Net
properties:
name: "NET_01"
port_security_enabled: false
net01_subnet:
type: OS::Neutron::Subnet
properties:
name: "NET01_subnet"
network_id: { get_resource: net01 }
cidr: { list_join: [".", [{ get_param: Web_Server_CIDR }, "0/24"]] }
gateway_ip: { list_join: [".", [{ get_param: Web_Server_CIDR}, "254"]] }
allocation_pools:
- start: { list_join: [".", [{ get_param: Web_Server_CIDR}, "3"]] }
end: { list_join: [".", [{ get_param: Web_Server_CIDR}, "250"]] }
net_ha:
type: OS::Neutron::Net
properties:
name: "net_ha"
port_security_enabled: false
ha_subnet:
type: OS::Neutron::Subnet
properties:
name: "HA_subnet"
network_id: { get_resource: net_ha }
cidr: { list_join: [".", [{ get_param: HA_CIDR }, "0/24"]] }
gateway_ip: null
enable_dhcp: false
# INSTANCES
# FGT WAN HA mode
FGT_WAN:
type: instance.yaml
properties:
image: { get_param: fortigate_img_name }
flavor: { get_param: fortigate_flavor }
net_id_list:
# list of network to connect to
- { get_resource: WAN }
- { get_param: inet }
hostname: "FGT_WAN"
config: { get_file: ./config/FGT/fgt.conf } # conf to push on instance. !!!!! relative path !!!!!
# FGT LAN HA mode
FGT_LAN:
type: instance.yaml
properties:
image: { get_param: fortigate_img_name }
flavor: { get_param: fortigate_flavor }
net_id_list:
- { get_resource: LAN }
- { get_resource: net01 }
hostname: "FGT_LAN"
config: { get_file: ./config/FGT/fgt.conf }
# FGT ResourceGroup
# %index% -> loop index number
FGTs:
type: OS::Heat::ResourceGroup
properties:
count: { get_param: FGT_count } # specified with --parameter FGT_count=
resource_def:
type: instance.yaml
properties:
image: { get_param: fortigate_img_name }
flavor: { get_param: fortigate_flavor }
net_id_list:
- { get_resource: WAN }
- { get_resource: LAN }
- { get_resource: net_ha }
hostname: "FGT_%index%"
config: { get_file: ./config/FGT/fgt.conf }
# UBUNTU ResourceGroup
Web_Servers:
type: OS::Heat::ResourceGroup
properties:
count: { get_param: WS_count }
resource_def:
type: instance.yaml
properties:
image: { get_param: web_server_img_name }
flavor: { get_param: web_server_flavor }
net_id_list: [{ get_resource: net01 }]
hostname: "Web_server_%index%"
config: { get_file: ./config/web_server/debian.conf }
################## OUTPUTS ##################
outputs:
mgmtIP_FGT_WAN:
value: { get_attr: [FGT_WAN, addresses, mgmt, 0, addr] }
mgmtIP_FGT_LAN:
value: { get_attr: [FGT_LAN, addresses, mgmt, 0, addr] }
portWAN:
value: { get_attr: [FGT_WAN, addresses, inet, 0, port] }
FGTs:
value:
repeat:
template:
[<%hostname%>, <%IP%>]
for_each:
<%IP%>: { get_attr: [FGTs, addresses, mgmt, 0, addr]}
<%hostname%>: { get_attr: [FGTs, Hostname] }
permutations: false
IP_WebServers:
value:
repeat:
template:
[<%hostname%>, <%IP%>]
for_each:
<%IP%>: { get_attr: [Web_Servers, addresses, { get_attr: [net01, name] }, 0, addr]}
<%hostname%>: { get_attr: [Web_Servers, Hostname] }
permutations: false
WAN_CIDR:
value: { get_param: WAN_CIDR }
LAN_CIDR:
value: { get_param: LAN_CIDR }
NET01_CIDR:
value: { get_param: Web_Server_CIDR }
HA_CIDR:
value: { get_param: HA_CIDR }