renamed scripts to be more intuitive; added check for docker
This commit is contained in:
parent
f635bbd031
commit
56f6aa16c4
|
@ -22,10 +22,10 @@ before_deploy:
|
|||
deploy:
|
||||
- provider: script
|
||||
skip_cleanup: true
|
||||
script: cd $TRAVIS_BUILD_DIR/$TEST_DIR && ./deploy.sh
|
||||
script: cd $TRAVIS_BUILD_DIR/$TEST_DIR && ./deploy.ci.sh
|
||||
on:
|
||||
repo: harijayms/terraform
|
||||
branch: master
|
||||
|
||||
# handle cleanup of resources
|
||||
after_deploy: cd $TRAVIS_BUILD_DIR/$TEST_DIR && ./after_deploy.sh
|
||||
after_deploy: cd $TRAVIS_BUILD_DIR/$TEST_DIR && ./after_deploy.ci.sh
|
||||
|
|
|
@ -8,10 +8,10 @@ docker run --rm -it \
|
|||
-e ARM_SUBSCRIPTION_ID \
|
||||
-e ARM_TENANT_ID \
|
||||
-v $(pwd):/data \
|
||||
--workdir=/data \
|
||||
--entrypoint "/bin/sh" \
|
||||
hashicorp/terraform:light \
|
||||
-c "cd /data; \
|
||||
/bin/terraform get; \
|
||||
-c "/bin/terraform get; \
|
||||
/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 apply out.tfplan"
|
|
@ -2,22 +2,14 @@
|
|||
|
||||
set -o errexit -o nounset
|
||||
|
||||
if docker -v; then
|
||||
|
||||
# generate a unique string for CI deployment
|
||||
export KEY=$(cat /dev/urandom | env LC_CTYPE=C tr -cd 'a-z' | head -c 12)
|
||||
export PASSWORD=$KEY$(cat /dev/urandom | env LC_CTYPE=C tr -cd 'A-Z' | head -c 2)$(cat /dev/urandom | env LC_CTYPE=C tr -cd '0-9' | head -c 2)
|
||||
|
||||
/bin/sh ./deploy.sh
|
||||
/bin/sh ./deploy.ci.sh
|
||||
|
||||
### capture vm image
|
||||
# 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 vm deallocate --name rgvm --resource-group permanent; \
|
||||
# az vm generalize --name rgvm --resource-group permanent; \
|
||||
# az image create --name customImage --source rgvm --resource-group permanent"
|
||||
|
||||
### cleanup
|
||||
# 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"
|
||||
else
|
||||
echo "Docker is used to run terraform commands, please install before run: https://docs.docker.com/docker-for-mac/install/"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue