consolidated deploy and after_deploy into a single script; simplified ci process; added os_profile_linux_config
This commit is contained in:
parent
64b52ee25f
commit
77775462ff
|
@ -22,7 +22,7 @@ before_deploy:
|
||||||
- export KEY=$(cat /dev/urandom | tr -cd 'a-z' | head -c 12)
|
- export KEY=$(cat /dev/urandom | tr -cd 'a-z' | head -c 12)
|
||||||
- export PASSWORD=$KEY$(cat /dev/urandom | tr -cd 'A-Z' | head -c 2)$(cat /dev/urandom | tr -cd '0-9' | head -c 2)
|
- export PASSWORD=$KEY$(cat /dev/urandom | tr -cd 'A-Z' | head -c 2)$(cat /dev/urandom | tr -cd '0-9' | head -c 2)
|
||||||
|
|
||||||
# terraform deploy script
|
# terraform deploy + script
|
||||||
deploy:
|
deploy:
|
||||||
- provider: script
|
- provider: script
|
||||||
skip_cleanup: true
|
skip_cleanup: true
|
||||||
|
@ -30,6 +30,3 @@ deploy:
|
||||||
on:
|
on:
|
||||||
repo: harijayms/terraform
|
repo: harijayms/terraform
|
||||||
branch: master
|
branch: master
|
||||||
|
|
||||||
# handle cleanup of resources
|
|
||||||
after_deploy: cd $TRAVIS_BUILD_DIR/$TEST_DIR && ./after_deploy.ci.sh
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -o errexit -o nounset
|
|
||||||
|
|
||||||
# cleanup deployed azure resources
|
|
||||||
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; \
|
|
||||||
az group delete -y -n $KEY"
|
|
|
@ -15,3 +15,23 @@ docker run --rm -it \
|
||||||
/bin/terraform validate; \
|
/bin/terraform validate; \
|
||||||
/bin/terraform plan -out=out.tfplan -var dns_name=$KEY -var hostname=$KEY -var resource_group=$KEY -var admin_password=$PASSWORD; \
|
/bin/terraform plan -out=out.tfplan -var dns_name=$KEY -var hostname=$KEY -var resource_group=$KEY -var admin_password=$PASSWORD; \
|
||||||
/bin/terraform apply out.tfplan"
|
/bin/terraform apply out.tfplan"
|
||||||
|
|
||||||
|
|
||||||
|
# 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 dns_name=$KEY -var hostname=$KEY -var resource_group=$KEY -var admin_password=$PASSWORD;"
|
||||||
|
|
||||||
|
|
||||||
|
# cleanup deployed azure resources via azure-cli
|
||||||
|
# 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; \
|
||||||
|
# az group delete -y -n $KEY"
|
||||||
|
|
|
@ -97,6 +97,10 @@ resource "azurerm_virtual_machine" "vm" {
|
||||||
admin_password = "${var.admin_password}"
|
admin_password = "${var.admin_password}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os_profile_linux_config {
|
||||||
|
disable_password_authentication = false
|
||||||
|
}
|
||||||
|
|
||||||
boot_diagnostics {
|
boot_diagnostics {
|
||||||
enabled = "true"
|
enabled = "true"
|
||||||
storage_uri = "${azurerm_storage_account.stor.primary_blob_endpoint}"
|
storage_uri = "${azurerm_storage_account.stor.primary_blob_endpoint}"
|
||||||
|
|
Loading…
Reference in New Issue