- Vagrant installed locally
- Python 3 installed locally
- Ansible installed locally
- Git installed locally
- Variables declared
To trigger installation and configuration run vagrant up
from your local repository directory.
Azure DevOps Personal Access Token creation:
In your organization https://dev.azure.com/YOUR_ORGANIZATION_NAME/_usersSettings/tokens add new token:
- Scope:
Agent Pools (read, manage)
. Make sure all the other boxes are cleared. -> my default case here. - If it's deployment group agent, define scope:
Deployment group (read, manage)
. Make sure all the other boxes are cleared. - If you want to add your agent to some other Agent Pool then default - make sure to provide correct name.
- Creates Ubuntu20.04LTS VM locally.
- Uses key created by Vagrant.
- Creates VM with dynamically assigned IP (my network doesn't have static IP assigned, so this is a workaround). Due to that fact, Vagrant needs to publish the VM hostname on the network, which by next VM runs resolves the hostname
azdevops-ubuntu20-agent.local
to the correct IP by Avahi daemon, whatever the IP is. - Uses ansible to provision & configure Azure DevOps self-hosted agent.
- Update package cache and all packages.
- Installs software such as: Git, Azure CLI, Python 3, Docker, .NET Core, Node.js, and Java, Kubernetes.
- Downloads agent files from Azure DevOps portal and runs installation passing variables to target environment.
- Configures agent auto-start after each system reboot.
- Uses variables declared in
/vars/main.yml
specified in roles where it is necessary. - The agent is not assigned to a single organization, but listens to jobs request in each project in organization (for changes/adjustmens read further).
- Installs and configures Avahi daemon on self-hosted agent VM (uses avahi.conf.j2 provided in the same directory, where ansible playbook is).
-
For building Kubernetes infrastructure using Azure DevOps pipelines, and BE ABLE TO TEST it by deploying apps to the built infrastructure, installation of Kubernetes on self-hosted agent is MANDATORY.
-
For building the infrastructure and NOT TESTING it, Kubernetes installation is NOT needed. Instead, use Azure DevOps to create the necessary resources in cloud (such as AKS clusters or AKS node pools) and use other tools/processes to deploy apps to those resources. If this is your case, just remove/comment related tasks: Install Kubernetes dependencies, Add the Kubernetes GPG key, Add the Kubernetes package repository, Install the Kubernetes packages.
Do not pass any --project
in azure-devops-agent
role, just omit it.
It will then listen if any job requests are posted across all projects in organization.
Define variable for project and pass parameter with that variable as: --project {{ AZDEVOPS_PROJECT_NAME1 }}
in azure-devops-agent
role.
Adjust Configure the Azure DevOps agent
task in azure-devops-agent
role adding parameter:
--project {{ AZDEVOPS_PROJECT_NAME1 }},{{ AZDEVOPS_PROJECT_NAME2 }},{{ AZDEVOPS_PROJECT_NAME2 }}
Before running the playbook, make sure you have declared all the required variables.
- Vagrant 2.2.19
- Ansible 2.10.8
- Python 3.10.6