renamed scripts to be more intuitive; added check for docker

This commit is contained in:
Scott Nowicki 2017-04-26 21:53:25 -05:00
parent f635bbd031
commit 56f6aa16c4
4 changed files with 12 additions and 20 deletions

View File

@ -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

View File

@ -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"

View File

@ -2,22 +2,14 @@
set -o errexit -o nounset
# 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)
if docker -v; then
/bin/sh ./deploy.sh
# 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)
### 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"
/bin/sh ./deploy.ci.sh
### 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