cleanup; sane defaults

This commit is contained in:
Scott Nowicki 2017-04-24 11:45:24 -05:00
parent 34d0c450ff
commit 9a7e42459b
6 changed files with 32 additions and 33 deletions

View File

@ -18,6 +18,7 @@ before_deploy:
- export KEY=$(cat /dev/urandom | tr -cd 'a-z' | head -c 12) - export KEY=$(cat /dev/urandom | tr -cd 'a-z' | head -c 12)
- export PASSWORD=$KEY$(cat /dev/urandom | tr -cd 'A-Z' | head -c 2)$(cat /dev/urandom | tr -cd '0-9' | head -c 2) - export PASSWORD=$KEY$(cat /dev/urandom | tr -cd 'A-Z' | head -c 2)$(cat /dev/urandom | tr -cd '0-9' | head -c 2)
# terraform deploy script # terraform deploy script
deploy: deploy:
- provider: script - provider: script
@ -27,5 +28,9 @@ deploy:
repo: 10thmagnitude/terraform repo: 10thmagnitude/terraform
branch: topic-101-vm-simple-linux branch: topic-101-vm-simple-linux
# TODO: possibly use Azure CLI to delete the resource group # destroy resources with Azure CLI
after_deploy: 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" after_deploy:
- 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"

View File

@ -0,0 +1,14 @@
#!/bin/bash
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)
/bin/sh ./deploy.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 group delete -y -n $KEY"

View File

@ -2,10 +2,6 @@
set -o errexit -o nounset set -o errexit -o nounset
# generate a unique string for CI deployment
# 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)
docker run --rm -it \ docker run --rm -it \
-e ARM_CLIENT_ID \ -e ARM_CLIENT_ID \
-e ARM_CLIENT_SECRET \ -e ARM_CLIENT_SECRET \
@ -14,26 +10,8 @@ docker run --rm -it \
-v $(pwd):/data \ -v $(pwd):/data \
--entrypoint "/bin/sh" \ --entrypoint "/bin/sh" \
hashicorp/terraform:light \ hashicorp/terraform:light \
-c "cd /data; /bin/terraform get; /bin/terraform plan -var dns_name=$KEY -var resource_group=$KEY -var admin_username=$KEY -var admin_password=$PASSWORD -out=out.tfplan; /bin/terraform apply out.tfplan" -c "cd /data; \
/bin/terraform get; \
# TODO: determine external validation, possibly Azure CLI /bin/terraform validate; \
/bin/terraform plan -out=out.tfplan -var dns_name=$KEY -var hostname=$KEY -var resource_group=$KEY -var admin_password=$PASSWORD; \
# echo "Setting git user name" /bin/terraform apply out.tfplan"
# 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

View File

@ -18,9 +18,9 @@ resource "azurerm_subnet" "subnet" {
} }
resource "azurerm_network_interface" "nic" { resource "azurerm_network_interface" "nic" {
name = "${var.rg_prefix}nic" name = "${var.rg_prefix}nic"
location = "${var.location}" location = "${var.location}"
resource_group_name = "${azurerm_resource_group.rg.name}" resource_group_name = "${azurerm_resource_group.rg.name}"
ip_configuration { ip_configuration {
name = "${var.rg_prefix}ipconfig" name = "${var.rg_prefix}ipconfig"

View File

@ -3,5 +3,4 @@ rg_prefix = "rg"
hostname = "myvm" hostname = "myvm"
dns_name = "mydnsname" dns_name = "mydnsname"
location = "southcentralus" location = "southcentralus"
admin_username = "vmadmin"
admin_password = "T3rr@f0rmP@ssword" admin_password = "T3rr@f0rmP@ssword"

View File

@ -4,6 +4,7 @@ variable "resource_group" {
variable "rg_prefix" { variable "rg_prefix" {
description = "The shortened abbreviation to represent your resource group that will go on the front of some resources." description = "The shortened abbreviation to represent your resource group that will go on the front of some resources."
default = "rg"
} }
variable "hostname" { variable "hostname" {
@ -16,6 +17,7 @@ variable "dns_name" {
variable "location" { variable "location" {
description = "The location/region where the virtual network is created. Changing this forces a new resource to be created." description = "The location/region where the virtual network is created. Changing this forces a new resource to be created."
default = "southcentralus"
} }
variable "virtual_network_name" { variable "virtual_network_name" {
@ -65,6 +67,7 @@ variable "image_version" {
variable "admin_username" { variable "admin_username" {
description = "administrator user name" description = "administrator user name"
default = "vmadmin"
} }
variable "admin_password" { variable "admin_password" {