You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jdongmo 4b6cd5d212 Add first code. преди 3 години
modules Add first code. преди 3 години
.gitignore Initial commit преди 3 години
LICENSE Initial commit преди 3 години
README.md Add first code. преди 3 години
main.tf Add first code. преди 3 години
outputs.tf Add first code. преди 3 години
run.sh Add first code. преди 3 години
variables.tf Add first code. преди 3 години

README.md

terraform.azure.automation

Terraform repository to perform automatic tasks in Azure cloud.

Requirements

First you must have terraform installed on host who run your automatism.

To install terraform, you should have wget and unzip.

sudo apt install wget unzip
wget -O terraform_0.12.20_linux_amd64.zip https://releases.hashicorp.com/terraform/0.12.20/terraform_0.12.20_linux_amd64.zip \
&& wget -O terraform_0.12.20_SHA256SUMS https://releases.hashicorp.com/terraform/0.12.20/terraform_0.12.20_SHA256SUMS \
&& sha256sum --ignore-missing -c terraform_0.12.20_SHA256SUMS \
&& unzip -qn terraform_0.12.20_linux_amd64.zip \
&& mv terraform ${PATH%%:*}/ \
&& rm terraform_0.12.20_linux_amd64.zip terraform_0.12.20_SHA256SUMS 

To run terraform against Azure cloud, you should have Azure variable (credentials and location) set in environment

$ export ARM_CLIENT_ID="00000000-0000-0000-0000-000000000000"
$ export ARM_CLIENT_CERTIFICATE_PATH="/path/to/my/client/certificate.pfx"
$ export ARM_CLIENT_CERTIFICATE_PASSWORD="Pa55w0rd123"
$ export ARM_SUBSCRIPTION_ID="00000000-0000-0000-0000-000000000000"
$ export ARM_TENANT_ID="00000000-0000-0000-0000-000000000000"

Run

To run terraform, we’ll use wrapper script run.sh To run default infrastructure playbook infra.tf who create all the infra

./run.sh -v

To only play another state file state.tf

TERRAFORM_FILE=state.tf ./run.sh -v

Docker

We’ll have a Dockerfile in order to generate a docker image to use it for running play in an controled environment.

  • Build image: docker build -t devops-docker .
  • Run terraform using this image:
docker run -e "TERRAFORM_FILE=state.tf" --entrypoint "./run.sh"
devops-docker -v