-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.tftpl
More file actions
53 lines (44 loc) · 2.66 KB
/
setup.tftpl
File metadata and controls
53 lines (44 loc) · 2.66 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
#!/bin/bash
set -x
exec > >(tee /var/log/user-data.log|logger -t user-data ) 2>&1
echo BEGIN
function wait-for-admin(){
while ! nc -z ${admin_server_private_ip} 8443; do
sleep 0.1
done
}
function install-azure-cli(){
rpm --import https://packages.microsoft.com/keys/microsoft.asc
dnf install -y https://packages.microsoft.com/config/rhel/9.0/packages-microsoft-prod.rpm
dnf install -y https://packages.microsoft.com/config/rhel/8/packages-microsoft-prod.rpm
dnf install azure-cli -y
az login --identity
}
date '+%Y-%m-%d %H:%M:%S'
my_nameserver=$(ifconfig eth0 | grep "inet " | awk '{print $2}')
my_ip=$(ifconfig eth0 | grep "inet " | awk '{print $2}')
my_default_gw=$(ip route show | grep default | awk '{print $3}')
my_cidr=$(awk -F. '{
split($0, octets)
for (i in octets) {
mask += 8 - log(2**8 - octets[i])/log(2);
}
print mask
}' <<< $(ifconfig eth0 | grep "inet " | awk '{print $4}'))
sudo su
export ITP_HOME=/opt/itp
export ITPBA_HOME=/opt/itpba
export CATALINA_HOME=/opt/apache-tomcat
chmod +x /opt/itp_global_conf/auto_deploy.sh
wait-for-admin
sed -i 's/^hosts:.*/hosts: files dns/' /etc/nsswitch.conf
install-azure-cli
archiver_password=$(az keyvault secret show --name ${analytics_archiver_password_name} --vault-name ${vault_name} --query "value" --output tsv)
admin_registration_password=$(az keyvault secret show --name ${admin_analytics_registration_password_name} --vault-name ${vault_name} --query "value" --output tsv)
ssh_password=$(az keyvault secret show --name ${analytics_ssh_password_secret_name} --vault-name ${vault_name} --query "value" --output tsv)
/opt/itp_global_conf/auto_deploy.sh --hostname "$(hostname)" --ip-address "$my_ip" --dns-servers "$my_nameserver" --registration-password "$admin_registration_password" --cidr "$my_cidr" --default-gateway "$my_default_gw" --machine-type "Analytics" --analytics-user "${archiver_user}" --analytics-password "$archiver_password" --admin-server-ip "${admin_server_private_ip}"
# Allow using ssh to the Analytics server with username and password as a WA, because currently there is an issue with exchanging the keys from the hub to the Analytics server
sed -i 's/.*PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
systemctl restart sshd
echo $ssh_password | passwd --stdin cbadmin
#/opt/itp_global_conf/auto_deploy_cloud.sh --hostname "$(hostname)" --dhcp 1 --ip-address "$my_ip" --dns-servers "$my_nameserver" --registration-password "$admin_registration_password" --cidr "$my_cidr" --default-gateway "$my_default_gw" --machine-type "Analytics" --analytics-user "${archiver_user}" --analytics-password "$archiver_password" --admin-server-ip "${admin_server_private_ip}"