2017-04-20 00:59:56 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -o errexit -o nounset
|
|
|
|
|
2017-04-20 01:28:42 +02:00
|
|
|
# generate a unique string for CI deployment
|
2017-04-20 20:44:23 +02:00
|
|
|
# KEY=$(cat /dev/urandom | tr -cd 'a-z' | head -c 12)
|
|
|
|
# PASSWORD=$KEY$(cat /dev/urandom | tr -cd 'A-Z' | head -c 2)$(cat /dev/urandom | tr -cd '0-9' | head -c 2)
|
2017-04-20 00:59:56 +02:00
|
|
|
|
2017-04-20 20:52:15 +02:00
|
|
|
docker run --rm -it -v \
|
|
|
|
$(pwd):/data -w /data \
|
|
|
|
hashicorp/terraform:light \
|
|
|
|
get
|
|
|
|
|
2017-04-20 21:06:59 +02:00
|
|
|
docker run --rm -it -v \
|
2017-04-20 21:33:49 +02:00
|
|
|
-e $ARM_CLIENT_ID \
|
|
|
|
-e $ARM_CLIENT_SECRET \
|
|
|
|
-e $ARM_SUBSCRIPTION_ID \
|
|
|
|
-e $ARM_TENANT_ID \
|
2017-04-20 20:52:15 +02:00
|
|
|
$(pwd):/data -w /data \
|
|
|
|
hashicorp/terraform:light \
|
|
|
|
plan -var dns_name=$KEY -var resource_group=$KEY -var admin_username=$KEY -var admin_password=$PASSWORD -out=out.tfplan
|
|
|
|
|
|
|
|
docker run --rm -it -v \
|
2017-04-20 21:33:49 +02:00
|
|
|
-e $ARM_CLIENT_ID \
|
|
|
|
-e $ARM_CLIENT_SECRET \
|
|
|
|
-e $ARM_SUBSCRIPTION_ID \
|
|
|
|
-e $ARM_TENANT_ID \
|
2017-04-20 20:52:15 +02:00
|
|
|
$(pwd):/data -w /data \
|
|
|
|
hashicorp/terraform:light \
|
|
|
|
apply out.tfplan
|
2017-04-20 01:28:42 +02:00
|
|
|
|
2017-04-20 20:44:23 +02:00
|
|
|
# terraform get
|
|
|
|
#
|
|
|
|
# terraform plan -var 'dns_name='$KEY -var 'admin_password='$PASSWORD -var 'admin_username='$KEY -var 'resource_group='$KEY -out=out.tfplan
|
|
|
|
#
|
|
|
|
# terraform apply out.tfplan
|
2017-04-20 01:28:42 +02:00
|
|
|
|
2017-04-20 00:59:56 +02:00
|
|
|
|
|
|
|
# TODO: determine external validation, possibly Azure CLI
|
|
|
|
|
|
|
|
# echo "Setting git user name"
|
|
|
|
# git config user.name $GH_USER_NAME
|
|
|
|
#
|
|
|
|
# echo "Setting git user email"
|
|
|
|
# git config user.email $GH_USER_EMAIL
|
|
|
|
#
|
|
|
|
# echo "Adding git upstream remote"
|
|
|
|
# git remote add upstream "https://$GH_TOKEN@github.com/$GH_REPO.git"
|
|
|
|
#
|
|
|
|
# git checkout master
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# NOW=$(TZ=America/Chicago date)
|
|
|
|
#
|
|
|
|
# git commit -m "tfstate: $NOW [ci skip]"
|
|
|
|
#
|
|
|
|
# echo "Pushing changes to upstream master"
|
|
|
|
# git push upstream master
|