This repository has been archived by the owner on Feb 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 282
/
Copy pathtask.sh
executable file
·228 lines (217 loc) · 7.29 KB
/
task.sh
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
#!/bin/bash
set -eu
iaas_configuration=$(
jq -n \
--arg vcenter_host "$VCENTER_HOST" \
--arg vcenter_username "$VCENTER_USR" \
--arg vcenter_password "$VCENTER_PWD" \
--arg datacenter "$VCENTER_DATA_CENTER" \
--arg disk_type "$VCENTER_DISK_TYPE" \
--arg ephemeral_datastores_string "$EPHEMERAL_STORAGE_NAMES" \
--arg persistent_datastores_string "$PERSISTENT_STORAGE_NAMES" \
--arg bosh_vm_folder "$BOSH_VM_FOLDER" \
--arg bosh_template_folder "$BOSH_TEMPLATE_FOLDER" \
--arg bosh_disk_path "$BOSH_DISK_PATH" \
--argjson ssl_verification_enabled false \
--argjson nsx_networking_enabled "$NSX_NETWORKING_ENABLED" \
--arg nsx_address "$NSX_ADDRESS" \
--arg nsx_username "$NSX_USERNAME" \
--arg nsx_password "$NSX_PASSWORD" \
--arg nsx_ca_certificate "$NSX_CA_CERTIFICATE" \
'
{
"vcenter_host": $vcenter_host,
"vcenter_username": $vcenter_username,
"vcenter_password": $vcenter_password,
"datacenter": $datacenter,
"disk_type": $disk_type,
"ephemeral_datastores_string": $ephemeral_datastores_string,
"persistent_datastores_string": $persistent_datastores_string,
"bosh_vm_folder": $bosh_vm_folder,
"bosh_template_folder": $bosh_template_folder,
"bosh_disk_path": $bosh_disk_path,
"ssl_verification_enabled": $ssl_verification_enabled,
"nsx_networking_enabled": $nsx_networking_enabled,
}
+
# NSX networking. If not enabled, the following section is not required
if $nsx_networking_enabled then
{
"nsx_address": $nsx_address,
"nsx_username": $nsx_username,
"nsx_password": $nsx_password,
"nsx_ca_certificate": $nsx_ca_certificate
}
else
.
end
'
)
az_configuration=$(cat <<-EOF
[
{
"name": "$AZ_1",
"cluster": "$AZ_1_CLUSTER_NAME",
"resource_pool": "$AZ_1_RP_NAME"
},
{
"name": "$AZ_2",
"cluster": "$AZ_2_CLUSTER_NAME",
"resource_pool": "$AZ_2_RP_NAME"
},
{
"name": "$AZ_3",
"cluster": "$AZ_3_CLUSTER_NAME",
"resource_pool": "$AZ_3_RP_NAME"
}
]
EOF
)
network_configuration=$(
jq -n \
--argjson icmp_checks_enabled $ICMP_CHECKS_ENABLED \
--arg infra_network_name "$INFRA_NETWORK_NAME" \
--arg infra_vcenter_network "$INFRA_VCENTER_NETWORK" \
--arg infra_network_cidr "$INFRA_NW_CIDR" \
--arg infra_reserved_ip_ranges "$INFRA_EXCLUDED_RANGE" \
--arg infra_dns "$INFRA_NW_DNS" \
--arg infra_gateway "$INFRA_NW_GATEWAY" \
--arg infra_availability_zones "$INFRA_NW_AZS" \
--arg deployment_network_name "$DEPLOYMENT_NETWORK_NAME" \
--arg deployment_vcenter_network "$DEPLOYMENT_VCENTER_NETWORK" \
--arg deployment_network_cidr "$DEPLOYMENT_NW_CIDR" \
--arg deployment_reserved_ip_ranges "$DEPLOYMENT_EXCLUDED_RANGE" \
--arg deployment_dns "$DEPLOYMENT_NW_DNS" \
--arg deployment_gateway "$DEPLOYMENT_NW_GATEWAY" \
--arg deployment_availability_zones "$DEPLOYMENT_NW_AZS" \
--arg services_network_name "$SERVICES_NETWORK_NAME" \
--arg services_vcenter_network "$SERVICES_VCENTER_NETWORK" \
--arg services_network_cidr "$SERVICES_NW_CIDR" \
--arg services_reserved_ip_ranges "$SERVICES_EXCLUDED_RANGE" \
--arg services_dns "$SERVICES_NW_DNS" \
--arg services_gateway "$SERVICES_NW_GATEWAY" \
--arg services_availability_zones "$SERVICES_NW_AZS" \
--arg dynamic_services_network_name "$DYNAMIC_SERVICES_NETWORK_NAME" \
--arg dynamic_services_vcenter_network "$DYNAMIC_SERVICES_VCENTER_NETWORK" \
--arg dynamic_services_network_cidr "$DYNAMIC_SERVICES_NW_CIDR" \
--arg dynamic_services_reserved_ip_ranges "$DYNAMIC_SERVICES_EXCLUDED_RANGE" \
--arg dynamic_services_dns "$DYNAMIC_SERVICES_NW_DNS" \
--arg dynamic_services_gateway "$DYNAMIC_SERVICES_NW_GATEWAY" \
--arg dynamic_services_availability_zones "$DYNAMIC_SERVICES_NW_AZS" \
'
{
"icmp_checks_enabled": $icmp_checks_enabled,
"networks": [
{
"name": $infra_network_name,
"service_network": false,
"subnets": [
{
"iaas_identifier": $infra_vcenter_network,
"cidr": $infra_network_cidr,
"reserved_ip_ranges": $infra_reserved_ip_ranges,
"dns": $infra_dns,
"gateway": $infra_gateway,
"availability_zone_names": ($infra_availability_zones | split(","))
}
]
},
{
"name": $deployment_network_name,
"service_network": false,
"subnets": [
{
"iaas_identifier": $deployment_vcenter_network,
"cidr": $deployment_network_cidr,
"reserved_ip_ranges": $deployment_reserved_ip_ranges,
"dns": $deployment_dns,
"gateway": $deployment_gateway,
"availability_zone_names": ($deployment_availability_zones | split(","))
}
]
},
{
"name": $services_network_name,
"service_network": false,
"subnets": [
{
"iaas_identifier": $services_vcenter_network,
"cidr": $services_network_cidr,
"reserved_ip_ranges": $services_reserved_ip_ranges,
"dns": $services_dns,
"gateway": $services_gateway,
"availability_zone_names": ($services_availability_zones | split(","))
}
]
},
{
"name": $dynamic_services_network_name,
"service_network": true,
"subnets": [
{
"iaas_identifier": $dynamic_services_vcenter_network,
"cidr": $dynamic_services_network_cidr,
"reserved_ip_ranges": $dynamic_services_reserved_ip_ranges,
"dns": $dynamic_services_dns,
"gateway": $dynamic_services_gateway,
"availability_zone_names": ($dynamic_services_availability_zones | split(","))
}
]
}
]
}'
)
director_config=$(cat <<-EOF
{
"ntp_servers_string": "$NTP_SERVERS",
"resurrector_enabled": $ENABLE_VM_RESURRECTOR,
"max_threads": $MAX_THREADS,
"database_type": "internal",
"blobstore_type": "local",
"director_hostname": "$OPS_DIR_HOSTNAME"
}
EOF
)
security_configuration=$(
jq -n \
--arg trusted_certificates "$TRUSTED_CERTIFICATES" \
'
{
"trusted_certificates": $trusted_certificates,
"vm_password_type": "generate"
}'
)
network_assignment=$(
jq -n \
--arg infra_availability_zones "$INFRA_NW_AZS" \
--arg network "$INFRA_NETWORK_NAME" \
'
{
"singleton_availability_zone": {
"name": ($infra_availability_zones | split(",") | .[0])
},
"network": {
"name": $network
}
}'
)
echo "Configuring IaaS, AZ and Director..."
om-linux \
--target https://$OPSMAN_DOMAIN_OR_IP_ADDRESS \
--skip-ssl-validation \
--username "$OPS_MGR_USR" \
--password "$OPS_MGR_PWD" \
configure-director \
--iaas-configuration "$iaas_configuration" \
--director-configuration "$director_config" \
--az-configuration "$az_configuration"
echo "Configuring Network and Security..."
om-linux \
--target https://$OPSMAN_DOMAIN_OR_IP_ADDRESS \
--skip-ssl-validation \
--username "$OPS_MGR_USR" \
--password "$OPS_MGR_PWD" \
configure-director \
--networks-configuration "$network_configuration" \
--network-assignment "$network_assignment" \
--security-configuration "$security_configuration"