Azure Devops with Terraform and Cisco ACI¶
Estimated time to read: 6 minutes
- Originally Written: October, 2020
The following posts will guide you through the steps to build the environment.
- Part 1: Architecture overview and storage setup
- Part 2: Azure pipeline setup and testing
- Part 3: Explanation of the configuration files
Azure Docker Agent Setup¶
- Sign up for an Azure Devops account
https://azure.microsoft.com/en-us/services/devops/
-
In the bottom left hand corner of the Azure Portal select
Project Settings
and thenAgent Pools
from the menu -
Click the
Add pool
button
-
Provide a name and select
Create
-
Make a note of the name of this pool
-
In the top right corner of the Azure portal select the person icon
-
Click
Personal access tokens
- Create a
New Token
- Provide a name for the token and set the scope to full access
- This token will be used to register the agent on your laptop to your Azure DevOps Pipeline
-
Make a copy of the access token created
-
Follow the instructions outlined here to build a new Docker image which will run Terraform.
https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops
Info
You should end up with two files on your local machine, a Dockerfile
, and a start.sh
script.
-
Copy and paste from the instructions above, no changes necessary.
-
Build the image as per the instructions
docker build -t azure_devops_agent:latest .
-
Run the container on your local machine.
- You need to provide the following:
- The
URL to Azure
(your organization name is found under the organization settings from the bottom left corner of the main Azure Devops homepage) - The
personal access token
just created - The
name of the agent pool
you created
- The
docker run -e AZP_URL= https://dev.azure.com/<your org here> -e AZP_TOKEN=<your access token> -e AZP_POOL=<your pool name> -e AZP_AGENT_NAME=azure_devops_terraform_aci azure_devops_agent:latest
- You need to provide the following:
Info
If everything is successful after a few moments of running the docker container you should see the agent registered in Azure.
Azure Pipeline Setup¶
- Login to your account and create a new project
- On the left hand menu select
Pipelines
andCreate Pipeline
.
- Select
Github
and the new repo which you forked.
Info
You may be asked to login to Github to provide Azure access to your repos.
Info
If everything is successful you will see the azure-pipelines.yml
displayed in the window.
-
Click the dropdown menu that shows
Run
and selectSave
-
On the left hand menu select
Library
and then add aVariable Group
-
Name the new variable group, "shared", and enter the following variables.
APIC_URL
: URL of the APIC cluster you will be configuring with Terraform. We are using the always on ACI demo from Cisco DevnetAPIC_USERNAME
APIC_PASSWORD
: Select the padlock on the right hand side of the text box to make this a secure field (covered by asterisks)AWS_ACCESS_KEY
: AWS access key used to access theterraform.tfstate
file from the S3 bucket. This was created previously when setting up the AWS UserAWS_SECRET_KEY
: AWS secret key used to access theterraform.tfstate
file from the S3 bucket. Select the padlock on the right hand side of the field to make this a secure field. This was created previously when setting up the AWS UserTERRAFORM_VERSION
: 0.13.4 (This can be changed if required)AWS_S3_BUCKET_NAME
: The name of the S3 bucket you previously createdAWS_S3_REGION
: The region in which the S3 bucket resides
-
Click the
Save
button at the top
Your First Test Run¶
If everything has been successful up until this point you should be ready for the first test. As previously mentioned, the Github repo contains the pipeline steps and the Terraform files. In the Terraform files you'll see that the following are created:
- Tenant
- VRF
- Bridge Domain
-
EPG
-
Navigate to the pipeline you created earlier
-
Select
Run Pipeline
and thenRun
- You should now see the pipeline running with two stages,
plan
andapply
. You can click into each stage to see the current jobs and output.
- The final check is confirm that the pipeline has succeeded, you can see the changes in your ACI fabric, and you can also see the new
terraform.tfstate
file in your AWS S3 bucket
Next Steps¶
Part 3: Explanation of the configuration files