Sets USE_MSI env var, get latest version of terraform, reflect changes in readme.
This commit is contained in:
@ -2,17 +2,24 @@
|
||||
|
||||
apt-get update
|
||||
|
||||
retry=0
|
||||
while true;do
|
||||
wget -O terraform.zip https://releases.hashicorp.com/terraform/0.11.1/terraform_0.11.1_linux_amd64.zip?_ga=2.228206621.1801000149.1512425211-1345627201.1504718143 && break || ((retry++))
|
||||
((retry >= 10)) && break
|
||||
done
|
||||
apt-get install jq
|
||||
|
||||
apt-get install unzip
|
||||
|
||||
unzip terraform.zip
|
||||
apt-get update
|
||||
|
||||
mv terraform /usr/local/bin
|
||||
TF_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M ".current_version") \
|
||||
&& wget -O terraform.zip https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip \
|
||||
&& wget -O terraform.sha256 https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_SHA256SUMS \
|
||||
&& wget -O terraform.sha256.sig https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_SHA256SUMS.sig \
|
||||
&& curl -s https://keybase.io/hashicorp/pgp_keys.asc | gpg --import \
|
||||
&& gpg --verify terraform.sha256.sig terraform.sha256 \
|
||||
&& echo $(grep -Po "[[:xdigit:]]{64}(?=\s+terraform_${TF_VERSION}_linux_amd64.zip)" terraform.sha256) terraform.zip | sha256sum -c \
|
||||
&& unzip terraform.zip \
|
||||
&& mkdir /usr/local/terraform \
|
||||
&& mv terraform /usr/local/bin \
|
||||
&& rm -f terraform terraform.zip terraform.sha256 terraform.sha256.sig \
|
||||
&& unset TF_VERSION
|
||||
|
||||
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main" | sudo tee /etc/apt/sources.list.d/azure-cli.list
|
||||
|
||||
|
@ -89,6 +89,7 @@ TEMPLATEFOLDER="/home/$USERNAME/tfTemplate"
|
||||
REMOTESTATEFILE="$TEMPLATEFOLDER/remoteState.tf"
|
||||
TFENVFILE="/home/$USERNAME/tfEnv.sh"
|
||||
CREDSFILE="$TEMPLATEFOLDER/azureProviderAndCreds.tf"
|
||||
PROFILEFILE="/home/$USERNAME/.profile"
|
||||
|
||||
mkdir $TEMPLATEFOLDER
|
||||
|
||||
@ -111,6 +112,14 @@ chown -R $USERNAME:$USERNAME /home/$USERNAME/tfTemplate
|
||||
touch $TFENVFILE
|
||||
echo "export ARM_SUBSCRIPTION_ID=\"$SUBSCRIPTION_ID\"" >> $TFENVFILE
|
||||
echo "export ARM_CLIENT_ID=\"$MSI_PRINCIPAL_ID\"" >> $TFENVFILE
|
||||
echo "export USE_MSI=true" >> $TFENVFILE
|
||||
|
||||
# Set these variables in the profile
|
||||
echo "echo export ARM_SUBSCRIPTION_ID=\"$SUBSCRIPTION_ID\" >>$PROFILEFILE" >> $TFENVFILE
|
||||
echo "echo export ARM_CLIENT_ID=\"$MSI_PRINCIPAL_ID\" >>$PROFILEFILE" >> $TFENVFILE
|
||||
echo "echo export USE_MSI=true >>$PROFILEFILE" >> $TFENVFILE
|
||||
|
||||
# Add contributor permissions to the MSI for entire subscription
|
||||
echo "az login" >> $TFENVFILE
|
||||
echo "az role assignment create --assignee \"$MSI_PRINCIPAL_ID\" --role 'b24988ac-6180-42a0-ab88-20f7382dd24c' --scope /subscriptions/\"$SUBSCRIPTION_ID\"" >> $TFENVFILE
|
||||
chmod 755 $TFENVFILE
|
||||
@ -121,9 +130,3 @@ logger -t devvm "Creating the container for remote state"
|
||||
az login --msi
|
||||
az storage container create -n terraform-state --account-name $STORAGE_ACCOUNT_NAME --account-key $STORAGE_ACCOUNT_KEY
|
||||
logger -t devvm "Container for remote state created: $?"
|
||||
|
||||
if [[ -v DESKTOPINSTALL ]]; then
|
||||
echo "Installing Mate Desktop"
|
||||
bash ./desktop.sh
|
||||
echo "Desktop installed"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user