terraform/examples/azure-vm-from-user-image/deploy.ci.sh

46 lines
1.6 KiB
Bash
Raw Normal View History

provider/azurerm: Add example of vm from user image (#14231) * initial commit - 101-vm-from-user-image * changed branch name * not deploying - storage problems * provisions vm but image not properly prepared * storage not correct * provisions properly * changed main.tf to azuredeploy.tf * added tfvars and info for README * tfvars ignored and corrected file ext * added CI config; added sane defaults for variables; updated deployment script, added mac specific deployment for local testing * deploy.sh to be executable * executable deploy files * added CI files; changed vars * prep for PR * removal of old folder * prep for PR * wrong args for travis * more PR prep * updated README * commented out variables in terraform.tfvars * Topic 101 vm from user image (#2) * initial commit - 101-vm-from-user-image * added tfvars and info for README * added CI config; added sane defaults for variables; updated deployment script, added mac specific deployment for local testing * prep for PR * added new template * oops, left off master * prep for PR * correct repository for destination * renamed scripts to be more intuitive; added check for docker * consolidated deploy and after_deploy into a single script; simplified ci process; added os_profile_linux_config * added terraform show * added az cli check * on this branch, only build test_dir; master will aggregate all the examples * suppress az login output * forgot about line breaks * breaking build as an example * fixing broken build example * fixed grammar in readme * typo fix * changed password variable description * added graph to README
2017-05-11 18:40:35 +02:00
#!/bin/bash
set -o errexit -o nounset
docker run --rm -it \
-e ARM_CLIENT_ID \
-e ARM_CLIENT_SECRET \
-e ARM_SUBSCRIPTION_ID \
-e ARM_TENANT_ID \
-v $(pwd):/data \
--workdir=/data \
--entrypoint "/bin/sh" \
hashicorp/terraform:light \
-c "/bin/terraform get; \
/bin/terraform validate; \
/bin/terraform plan -out=out.tfplan -var hostname=$KEY -var resource_group=$EXISTING_RESOURCE_GROUP -var admin_username=$KEY -var admin_password=$PASSWORD -var image_uri=$EXISTING_IMAGE_URI -var storage_account_name=$EXISTING_STORAGE_ACCOUNT_NAME; \
/bin/terraform apply out.tfplan; \
/bin/terraform show;"
docker run --rm -it \
azuresdk/azure-cli-python \
sh -c "az login --service-principal -u $ARM_CLIENT_ID -p $ARM_CLIENT_SECRET --tenant $ARM_TENANT_ID > /dev/null; \
az vm show --name $KEY --resource-group permanent"
# cleanup deployed azure resources via terraform
docker run --rm -it \
-e ARM_CLIENT_ID \
-e ARM_CLIENT_SECRET \
-e ARM_SUBSCRIPTION_ID \
-e ARM_TENANT_ID \
-v $(pwd):/data \
--workdir=/data \
--entrypoint "/bin/sh" \
hashicorp/terraform:light \
-c "/bin/terraform destroy -force \
-var hostname=$KEY \
-var resource_group=$EXISTING_RESOURCE_GROUP \
-var admin_username=$KEY \
-var admin_password=$PASSWORD \
-var image_uri=$EXISTING_IMAGE_URI \
-var storage_account_name=$EXISTING_STORAGE_ACCOUNT_NAME \
-target=azurerm_virtual_machine.vm \
-target=azurerm_network_interface.nic \
-target=azurerm_virtual_network.vnet \
-target=azurerm_public_ip.pip;"