зеркало из https://github.com/Azure/azurehpc.git
using local variables to avoid naming conflicts
This commit is contained in:
Родитель
6b643eb0de
Коммит
5ed0b20981
|
@ -57,27 +57,27 @@ function make_uuid_str {
|
|||
}
|
||||
|
||||
function process_value {
|
||||
prefix=${!1%%.*}
|
||||
local prefix=${!1%%.*}
|
||||
if [ "$prefix" = "variables" ]; then
|
||||
read_value $1 ".${!1}"
|
||||
elif [ "$prefix" = "secret" ]; then
|
||||
keyvault_str=${!1#*.}
|
||||
vault_name=${keyvault_str%.*}
|
||||
key_name=${keyvault_str#*.}
|
||||
local keyvault_str=${!1#*.}
|
||||
local vault_name=${keyvault_str%.*}
|
||||
local key_name=${keyvault_str#*.}
|
||||
debug "read_value reading from keyvault (keyvault=$vault_name, key=$key_name)"
|
||||
read $1 <<< $(az keyvault secret show --name $key_name --vault-name $vault_name -o json | jq -r '.value')
|
||||
elif [ "$prefix" = "sasurl" ]; then
|
||||
sasurl_storage_str=${!1#*.}
|
||||
sasurl_storage_account=${sasurl_storage_str%%.*}
|
||||
sasurl_storage_fullpath=${sasurl_storage_str#*.}
|
||||
sasurl_storage_container=${sasurl_storage_fullpath%%/*}
|
||||
sasurl_storage_url="$( \
|
||||
local sasurl_storage_str=${!1#*.}
|
||||
local sasurl_storage_account=${sasurl_storage_str%%.*}
|
||||
local sasurl_storage_fullpath=${sasurl_storage_str#*.}
|
||||
local sasurl_storage_container=${sasurl_storage_fullpath%%/*}
|
||||
local sasurl_storage_url="$( \
|
||||
az storage account show \
|
||||
--name $sasurl_storage_account \
|
||||
--query primaryEndpoints.blob \
|
||||
--output tsv \
|
||||
)"
|
||||
sasurl_storage_saskey=$( \
|
||||
local sasurl_storage_saskey=$( \
|
||||
az storage container generate-sas \
|
||||
--account-name $sasurl_storage_account \
|
||||
--name $sasurl_storage_container \
|
||||
|
@ -86,14 +86,14 @@ function process_value {
|
|||
--expiry $(date --utc -d "+1 hour" +%Y-%m-%dT%H:%M:%SZ) \
|
||||
--output tsv
|
||||
)
|
||||
sasurl_storage_full="$sasurl_storage_url$sasurl_storage_fullpath?$sasurl_storage_saskey"
|
||||
local sasurl_storage_full="$sasurl_storage_url$sasurl_storage_fullpath?$sasurl_storage_saskey"
|
||||
debug "read_value creating a sasurl (account=$sasurl_storage_account, fullpath=$sasurl_storage_fullpath, container=$sasurl_storage_container, sasurl=$sasurl_storage_full"
|
||||
read $1 <<< "$sasurl_storage_full"
|
||||
elif [ "$prefix" = "fqdn" ]; then
|
||||
fqdn_str=${!1#*.}
|
||||
resource_name=${fqdn_str%.*}
|
||||
local fqdn_str=${!1#*.}
|
||||
local resource_name=${fqdn_str%.*}
|
||||
debug "getting FQDN for $resource_name in $resource_group"
|
||||
fqdn=$(
|
||||
local fqdn=$(
|
||||
az network public-ip show \
|
||||
--resource-group $resource_group \
|
||||
--name ${resource_name}pip --query dnsSettings.fqdn \
|
||||
|
@ -102,16 +102,16 @@ function process_value {
|
|||
)
|
||||
read $1 <<< "$fqdn"
|
||||
elif [ "$prefix" = "sakey" ]; then
|
||||
sakey_str=${!1#*.}
|
||||
storage_name=${sakey_str%.*}
|
||||
local sakey_str=${!1#*.}
|
||||
local storage_name=${sakey_str%.*}
|
||||
debug "getting storage key for $storage_name in $resource_group"
|
||||
storage_key=$(az storage account keys list -g $resource_group -n $storage_name --query "[0].value" | sed 's/\"//g')
|
||||
local storage_key=$(az storage account keys list -g $resource_group -n $storage_name --query "[0].value" | sed 's/\"//g')
|
||||
read $1 <<< "$storage_key"
|
||||
elif [ "$prefix" = "acrkey" ]; then
|
||||
acrkey_str=${!1#*.}
|
||||
acr_name=${acrkey_str%.*}
|
||||
local acrkey_str=${!1#*.}
|
||||
local acr_name=${acrkey_str%.*}
|
||||
debug "getting acr key for $acr_name"
|
||||
acr_key=$(az acr credential show -n $acr_name --query passwords[0].value --output tsv)
|
||||
local acr_key=$(az acr credential show -n $acr_name --query passwords[0].value --output tsv)
|
||||
read $1 <<< "$acr_key"
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ function create_jumpbox_setup_script()
|
|||
local ssh_public_key="$2"
|
||||
local ssh_private_key="$3"
|
||||
|
||||
install_sh=$tmp_dir/install/00_install_node_setup.sh
|
||||
log_file=install/00_install_node_setup.log
|
||||
local install_sh=$tmp_dir/install/00_install_node_setup.sh
|
||||
local log_file=install/00_install_node_setup.log
|
||||
|
||||
cat <<OUTER_EOF > $install_sh
|
||||
#!/bin/bash
|
||||
|
@ -63,11 +63,11 @@ function create_jumpbox_script()
|
|||
local tmp_dir=$2
|
||||
local step=$3
|
||||
|
||||
idx=$(($step - 1))
|
||||
local idx=$(($step - 1))
|
||||
read_value install_script ".install[$idx].script"
|
||||
|
||||
install_sh=$tmp_dir/install/$(printf %02d $step)_$install_script
|
||||
log_file=install/$(printf %02d $step)_${install_script%.sh}.log
|
||||
local install_sh=$tmp_dir/install/$(printf %02d $step)_$install_script
|
||||
local log_file=install/$(printf %02d $step)_${install_script%.sh}.log
|
||||
|
||||
read_value install_tag ".install[$idx].tag"
|
||||
|
||||
|
@ -83,10 +83,10 @@ OUTER_EOF
|
|||
|
||||
read_value install_reboot ".install[$idx].reboot" false
|
||||
read_value install_sudo ".install[$idx].sudo" false
|
||||
install_nfiles=$(jq -r ".install[$idx].copy | length" $config_file)
|
||||
local install_nfiles=$(jq -r ".install[$idx].copy | length" $config_file)
|
||||
|
||||
install_script_arg_count=$(jq -r ".install[$idx].args | length" $config_file)
|
||||
install_command_line=$install_script
|
||||
local install_script_arg_count=$(jq -r ".install[$idx].args | length" $config_file)
|
||||
local install_command_line=$install_script
|
||||
if [ "$install_script_arg_count" -ne "0" ]; then
|
||||
for n in $(seq 0 $((install_script_arg_count - 1))); do
|
||||
read_value arg ".install[$idx].args[$n]"
|
||||
|
@ -101,7 +101,7 @@ OUTER_EOF
|
|||
done
|
||||
fi
|
||||
|
||||
sudo_prefix=
|
||||
local sudo_prefix=
|
||||
if [ "$install_sudo" = "true" ]; then
|
||||
sudo_prefix=sudo
|
||||
fi
|
||||
|
@ -130,11 +130,11 @@ function create_local_script()
|
|||
local tmp_dir=$2
|
||||
local step=$3
|
||||
|
||||
idx=$(($step - 1))
|
||||
local idx=$(($step - 1))
|
||||
read_value install_script ".install[$idx].script"
|
||||
|
||||
install_sh=$tmp_dir/install/$(printf %02d $step)_$install_script
|
||||
log_file=install/$(printf %02d $step)_${install_script%.sh}.log
|
||||
local install_sh=$tmp_dir/install/$(printf %02d $step)_$install_script
|
||||
local log_file=install/$(printf %02d $step)_${install_script%.sh}.log
|
||||
|
||||
cat <<OUTER_EOF > $install_sh
|
||||
#!/bin/bash
|
||||
|
@ -144,8 +144,8 @@ cd "\$( dirname "\${BASH_SOURCE[0]}" )/.."
|
|||
|
||||
OUTER_EOF
|
||||
|
||||
install_script_arg_count=$(jq -r ".install[$idx].args | length" $config_file)
|
||||
install_command_line=$install_script
|
||||
local install_script_arg_count=$(jq -r ".install[$idx].args | length" $config_file)
|
||||
local install_command_line=$install_script
|
||||
if [ "$install_script_arg_count" -ne "0" ]; then
|
||||
for n in $(seq 0 $((install_script_arg_count - 1))); do
|
||||
read_value arg ".install[$idx].args[$n]"
|
||||
|
@ -209,6 +209,7 @@ function create_install_scripts()
|
|||
cp -r $local_script_dir/* $tmp_dir/scripts/. 2>/dev/null
|
||||
|
||||
if [ "$is_jumpbox_required" = "1" ]; then
|
||||
echo "rsync $tmp_dir to $fqdn"
|
||||
rsync -a -e "ssh $ssh_args -i $ssh_private_key" $tmp_dir $admin_user@$fqdn:.
|
||||
fi
|
||||
|
||||
|
@ -241,7 +242,7 @@ function run_install_scripts()
|
|||
fi
|
||||
done
|
||||
|
||||
script_error=0
|
||||
local script_error=0
|
||||
for step in $(seq 0 $nsteps); do
|
||||
|
||||
# skip jumpbox setup if no jumpbox scripts are required
|
||||
|
|
Загрузка…
Ссылка в новой задаче