This Terraform moudule enables you to build this system: With additional machine to run ansible and configure the other machine.
-
Conncte your Azure CLI to your Azure accont-
az login
. -
Add a directory named
vasrsFiles
to the project directory. -
Add the files
production.tfvars
andstaging.tfvars
to thevasrsFiles
directory.3.1 Each tfvars file should contain this information:
prefix="<enviroment prefix>" webAppMachines_username="<username>" webAppMachines_password="<password>" ansible_username="<username>" ansible_password="<password>" machines_ammount="<number of machines in the enviroment>" pg_user="<postgress user name>" pg_pass="<postgress password>" ipToconnetAnsibleWorkStation="<your ip>"
-
Run the command
terraform init
. -
The staging resource will be connected to the
default
Terraform workspace. so you can run the commandterraform apply -var-file varsFiles/staging.tfvars
to build the staging system. -
Run
terraform worspace new production
to build the production system. -
Run the command
terraform apply -var-file varsFiles/production.tfvars
to build the production system. -
In Azure portal get the pulic IP of the machine where you run ansible.
-
You can use the ansible project to run the Weight Tracker app on your enviroment.
To upload the terraform state to azure storage, you need to cancel the comment inside the "backetStateConfiguration.tf" file. And change the storage attributes names to your own.
You need to run terraform init
again, to apply the backend configuration.
You can read more details about this terraform module in the automated documentation: Terraform-docs