-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Terraform/Ansible infrastructure lab #9
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Facundo Gauna <[email protected]>
Signed-off-by: Facundo Gauna <[email protected]>
e3aa678
to
3e319a4
Compare
``` | ||
|
||
Next, create a resource group and a storage account. We will use the storage account for the Terraform backend. | ||
Substitue `[your-name]` with your first name to avoid name collisions with your peers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Substitue `[your-name]` with your first name to avoid name collisions with your peers. | |
Substitute `[your-name]` with your first name to avoid name collisions with your peers. |
export ARM_ACCESS_KEY=$(az storage account keys list -g $RESOURCE_GROUP_STATE -n $STORAGE_ACCOUNT_STATE --query "[0].value" -o tsv) | ||
``` | ||
|
||
Now, from Visual Studio Code, open the `backend.tf` file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, from Visual Studio Code, open the `backend.tf` file. | |
Now, from Visual Studio Code, open the `terraform/backend.tf` file. |
cd .. | ||
cd ansible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cd .. | |
cd ansible | |
cd ../ansible |
Before you run the Terraform configuration, you'll need to pick a password for your virtual machine. | ||
|
||
``` bash | ||
export TF_VAR_admin_password="<your password here>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also pass in the user's name or randomize the Resource Group name created as part of the Terraform run
|
||
That's it! 🎉 | ||
|
||
You created a virtual machine using Terraform, then used Ansible to configure the virtual machine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should maybe add a way to validate a successful run for the user after this
cd .. | ||
cd terraform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cd .. | |
cd terraform | |
cd ../terraform |
``` bash | ||
cd .. | ||
cd terraform | ||
terraform destroy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
terraform destroy | |
terraform apply -destroy |
Next, login to Azure. Ensure you have the right subscription selected. | ||
|
||
``` bash | ||
az login |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running this in GitHub Codespaces in the browser, I got a 404 on the callback from az login
and had to allow pop-ups from my Codespace. Another option would be to use az login --use-device-code
when running from the Codespaces in the browser
``` | ||
|
||
Next, create a resource group and a storage account. We will use the storage account for the Terraform backend. | ||
Substitue `[your-name]` with your first name to avoid name collisions with your peers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll want to add verbiage around here where their name must be less than or equal to 17 characters and all lower case letters
Adding a lab for using Terraform to provision a Windows VM and using Ansible to configure it.
It is based on a real-world example where there needed to be a DNS forwarder configured for Azure Private Link DNS zones.