Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fgauna12
Copy link
Contributor

@fgauna12 fgauna12 commented Jun 1, 2022

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.

Signed-off-by: Facundo Gauna <[email protected]>
Signed-off-by: Facundo Gauna <[email protected]>
@fgauna12 fgauna12 force-pushed the feature/add-terraform-workshop branch from e3aa678 to 3e319a4 Compare June 1, 2022 21:49
```

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Now, from Visual Studio Code, open the `backend.tf` file.
Now, from Visual Studio Code, open the `terraform/backend.tf` file.

Comment on lines +128 to +129
cd ..
cd ansible
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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>"
Copy link
Member

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.
Copy link
Member

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

Comment on lines +144 to +145
cd ..
cd terraform
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cd ..
cd terraform
cd ../terraform

``` bash
cd ..
cd terraform
terraform destroy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
terraform destroy
terraform apply -destroy

Next, login to Azure. Ensure you have the right subscription selected.

``` bash
az login
Copy link
Member

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.
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants