-
Notifications
You must be signed in to change notification settings - Fork 194
Expand file tree
/
Copy pathgatewayVMSS.sh
More file actions
163 lines (135 loc) · 3.93 KB
/
gatewayVMSS.sh
File metadata and controls
163 lines (135 loc) · 3.93 KB
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
#!/bin/bash
set -o errexit \
-o pipefail \
-o nounset
main() {
# transaction attempt retry time in seconds
# shellcheck disable=SC2034
local -ri retry_wait_time=30
# shellcheck disable=SC2068
local -ri pkg_retry_count=60
create_required_dirs
configure_sshd
configure_rpm_repos retry_wait_time \
"$pkg_retry_count"
# shellcheck disable=SC2034
local -ar exclude_pkgs=(
"-x WALinuxAgent"
"-x WALinuxAgent-udev"
)
dnf_update_pkgs exclude_pkgs \
retry_wait_time \
"$pkg_retry_count"
# shellcheck disable=SC2034
local -ra install_pkgs=(
azure-cli
azure-mdsd
podman
podman-docker
openssl-perl
# hack - we are installing python3 on hosts due to an issue with Azure Linux Extensions https://github.com/Azure/azure-linux-extensions/pull/1505
python3
# required for podman networking
firewalld
# Required to enable fips
grubby
dracut-fips
)
dnf_install_pkgs install_pkgs \
retry_wait_time \
"$pkg_retry_count"
fips_configure
# shellcheck disable=SC2119
configure_logrotate
# shellcheck disable=SC2034 disable=SC2153
local -r mdmimage="${RPIMAGE%%/*}/${MDMIMAGE#*/}"
local -r rpimage="$RPIMAGE"
# shellcheck disable=SC2034
local -r fluentbit_image="$FLUENTBITIMAGE"
# values are references to variables, they should not be dereferenced here
# shellcheck disable=SC2034
local -rA aro_images=(
["mdm"]="mdmimage"
["rp"]="rpimage"
["fluentbit"]="fluentbit_image"
)
pull_container_images aro_images
# shellcheck disable=SC2034
local -ra enable_ports=(
# RP gateway
"80/tcp"
"8081/tcp"
"443/tcp"
# JIT ssh
"22/tcp"
)
firewalld_configure enable_ports
# shellcheck disable=SC2034
local -r fluentbit_conf_file="[INPUT]
Name systemd
Tag journald
Systemd_Filter _COMM=aro
DB /var/lib/fluent/journaldb
[FILTER]
Name modify
Match journald
Remove_wildcard _
Remove TIMESTAMP
[OUTPUT]
Name forward
Match *
Port 29230"
# shellcheck disable=SC2034
local -r aro_gateway_conf_file="ACR_RESOURCE_ID='$ACRRESOURCEID'
DATABASE_ACCOUNT_NAME='$DATABASEACCOUNTNAME'
MDM_ACCOUNT='$RPMDMACCOUNT'
MDM_NAMESPACE='${role_gateway^}'
GATEWAY_DOMAINS='$GATEWAYDOMAINS'
GATEWAY_FEATURES='$GATEWAYFEATURES'
RPIMAGE='$rpimage'"
# shellcheck disable=SC2034
local -r mdsd_config_version="$GATEWAYMDSDCONFIGVERSION"
# values are references to variables, they should not be dereferenced here
# shellcheck disable=SC2034
local -rA aro_configs=(
["gateway_config"]="aro_gateway_conf_file"
["fluentbit"]="fluentbit_conf_file"
["mdsd"]="mdsd_config_version"
["static_ip_address"]="static_ip_addresses"
)
# shellcheck disable=SC2034
# use default podman network with range 10.88.0.0/16
local -rA static_ip_addresses=(
["gateway"]="10.88.0.2"
["mdm"]="10.88.0.8"
)
configure_vmss_aro_services role_gateway \
aro_images \
aro_configs
# shellcheck disable=SC2034
local -ra gateway_services=(
"aro-gateway"
"azsecd"
"mdsd"
"mdm"
"chronyd"
"fluentbit"
"download-mdsd-credentials.timer"
"download-mdm-credentials.timer"
"firewalld"
)
enable_services gateway_services
reboot_vm
}
# export AZURE_CLOUD_NAME="${AZURECLOUDNAME:?"Failed to carry over variables"}"
export AZURE_CLOUD_NAME="${AZURECLOUDNAME:?"Failed to carry over variables"}"
# util="util.sh"
#
# util.sh does not exist when deployed to VMSS via VMSS extensions
# Provides shellcheck definitions
util="util.sh"
if [ -f "$util" ]; then
# shellcheck source=util.sh
source "$util"
fi
main "$@"