Getting start with Azure, packer and terraform
Recently, I started using Azure for my test env. This is a reminder for myself.
How https://github.com/Azure/azure-cli
NOTE Both v1 and v2 are installed, as packer's azure-setup.sh
requires v1.
git clone git@github.com:nak3/lab3.git
cd lab3
This just creates single VM instance from CentOS image.
azure vm quick-create -M ~/.ssh/id_rsa.pub \
--location southeastasia \
-g ${RESOURCE_GROUP} \
-n centos73-01 \
-Q OpenLogic:CentOS:7.3:7.3.20170612 \
-y Linux \
--admin-username ${USERNAME} \
--admin-password ${PASSWORD}
wget https://raw.githubusercontent.com/hashicorp/packer/master/contrib/azure-setup.sh
bash azure-setup.sh setup
cd packer
cp variables.sample.json variables.json
vim variables.sample.json
$GOBIN/packer build -var-file=variables.json
az image create \
--resource-group ${RESOURCE_GROUP} \
--name nak3testimage \
--os-type linux \
--source ${IMAGE_ID}
cd terraform/centos7-cluster
cp terraform.tfvars.template terraform.tfvars
vim terraform.tfvars.template
Reference: https://www.terraform.io/docs/providers/azurerm/
$GOBIN/terraform init
$GOBIN/terraform plna
$GOBIN/terraform apply