From 56f6aa16c4148b097c5ad8edac9ca3034554cdcc Mon Sep 17 00:00:00 2001 From: Scott Nowicki Date: Wed, 26 Apr 2017 21:53:25 -0500 Subject: [PATCH] renamed scripts to be more intuitive; added check for docker --- .travis.yml | 4 ++-- .../{after_deploy.sh => after_deploy.ci.sh} | 0 .../{deploy.sh => deploy.ci.sh} | 4 ++-- .../deploy.mac.sh | 24 +++++++------------ 4 files changed, 12 insertions(+), 20 deletions(-) rename examples/azure-vm-simple-linux-managed-disk/{after_deploy.sh => after_deploy.ci.sh} (100%) rename examples/azure-vm-simple-linux-managed-disk/{deploy.sh => deploy.ci.sh} (90%) diff --git a/.travis.yml b/.travis.yml index 7a97c1e91..9c9210904 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/examples/azure-vm-simple-linux-managed-disk/after_deploy.sh b/examples/azure-vm-simple-linux-managed-disk/after_deploy.ci.sh similarity index 100% rename from examples/azure-vm-simple-linux-managed-disk/after_deploy.sh rename to examples/azure-vm-simple-linux-managed-disk/after_deploy.ci.sh diff --git a/examples/azure-vm-simple-linux-managed-disk/deploy.sh b/examples/azure-vm-simple-linux-managed-disk/deploy.ci.sh similarity index 90% rename from examples/azure-vm-simple-linux-managed-disk/deploy.sh rename to examples/azure-vm-simple-linux-managed-disk/deploy.ci.sh index 5347f3a83..8fa08573f 100755 --- a/examples/azure-vm-simple-linux-managed-disk/deploy.sh +++ b/examples/azure-vm-simple-linux-managed-disk/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" diff --git a/examples/azure-vm-simple-linux-managed-disk/deploy.mac.sh b/examples/azure-vm-simple-linux-managed-disk/deploy.mac.sh index ab076afdb..9c6563f07 100755 --- a/examples/azure-vm-simple-linux-managed-disk/deploy.mac.sh +++ b/examples/azure-vm-simple-linux-managed-disk/deploy.mac.sh @@ -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