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: deploy:
- provider: script - provider: script
skip_cleanup: true skip_cleanup: true
script: cd $TRAVIS_BUILD_DIR/$TEST_DIR && ./deploy.sh script: cd $TRAVIS_BUILD_DIR/$TEST_DIR && ./deploy.ci.sh
on: on:
repo: harijayms/terraform repo: harijayms/terraform
branch: master branch: master
# handle cleanup of resources # 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_SUBSCRIPTION_ID \
-e ARM_TENANT_ID \ -e ARM_TENANT_ID \
-v $(pwd):/data \ -v $(pwd):/data \
--workdir=/data \
--entrypoint "/bin/sh" \ --entrypoint "/bin/sh" \
hashicorp/terraform:light \ hashicorp/terraform:light \
-c "cd /data; \ -c "/bin/terraform get; \
/bin/terraform get; \
/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"

View File

@ -2,22 +2,14 @@
set -o errexit -o nounset set -o errexit -o nounset
# generate a unique string for CI deployment if docker -v; then
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 # 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 /bin/sh ./deploy.ci.sh
# 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 else
# docker run --rm -it \ echo "Docker is used to run terraform commands, please install before run: https://docs.docker.com/docker-for-mac/install/"
# azuresdk/azure-cli-python \ fi
# sh -c "az login --service-principal -u $ARM_CLIENT_ID -p $ARM_CLIENT_SECRET --tenant $ARM_TENANT_ID; \
# az group delete -y -n $KEY"