Skip to content

baidarka/vsts-agent-infrastructure

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure DevOps Agent Docker Image

This repo contains the infrastructure and image definition that accompanies the blogpost How to create a custom VSTS agent on Azure ACI with Terraform by Elena Neroslavskaya. When implementing infrastructure as code (IaC) with Azure, it is useful to have some infrastructure tools available on your build agent. This repo contains files to:

  • create a custom build agent that contains Terraform, Packer and Ansible
  • create an Azure Container Instances (ACI) resource to run the custom build agent

This build container runs in Azure. To set this up, Terraform script main.tf is used. (for details: see 'How to use this repo' below) Please note that the availability of Terraform within the build container is unrelated to the Terraform main.tf.

Since collaboration on Docker Hub is not (yet?) set up, the resulting container image may be available on Docker Hub in various personal repositories.

The scripts in this fork point to: knoflook/vsts-agent-infrastructure
Downloads from Docker Hub Stars on Docker Hub Microbadger Badge

Lenishas image (possibly older) is available on Docker Hub under lenisha/vsts-agent-infrastructure
Downloads from Docker Hub Stars on Docker Hub Microbadger Badge

How to use this repo

1 Create an Agent Pool named "ACI-Pool" in your Azure DevOps organisation.

2 Prepare environment variables

  • VSTS_ACCOUNT: the name of your Visual Studio account
  • VSTS_TOKEN: a personal access token (PAT) for your Visual Studio account, with Agent Pools (read, manage) and Deployment Groups (Read & manage).
  • VSTS_AGENT: the name of the agent (here: "$(hostname)-agent")
  • VSTS_POOL: the name of your agent pool (here: "ACI-Pool")

3 Set up your Azure environment
Open https://shell.azure.com, select Bash shell, then:
git clone https://github.com/baidarka/vsts-agent-infrastructure.git
cd vsts-agent-infrastructure/terraform
terraform init
terraform plan
terraform apply -var vsts-pool="ACI-pool" -var vsts-account="[org]" -var vsts-token="[pat]"

Notes

  • TODO: remove random number from Storage Account, this hampers idempotent deployments

  • TODO: add automatic updates when new release posted

  • Other tools installed on VSTS image are listed: vsts agent tools

  • If you want to run this image as a standalone container use:

docker run \
  -e VSTS_ACCOUNT=<name> \
  -e VSTS_TOKEN=<pat> \
  -e VSTS_AGENT='$(hostname)-agent' \
  -e VSTS_POOL=ACI-pool \
  -it knoflook/vsts-agent-infrastructure:1.0.0

Releases

No releases published

Packages

No packages published

Languages

  • HCL 45.4%
  • Dockerfile 31.0%
  • PowerShell 17.9%
  • Shell 5.7%