gsoft.azure_devops_agent
Azure DevOps Agent
This is an Ansible role that helps you set up a Linux machine as an Azure DevOps build or deployment agent.
For more information, check out this blog post.
Requirements
If you are installing on MacOS, there may be issues when an admin user connects while another user runs the service. Setting pipelining = True
can help, especially if the DevOps agent user can't access the temporary files created by Ansible.
Role Variables
The variables you can use are listed below with their default values (see defaults/main.yml
):
az_devops_accountname: null
az_devops_accesstoken: null
az_devops_project_name: null
az_devops_agent_version: 2.188.3
az_devops_agent_user: "az_devops_agent"
az_devops_agent_uid: null
az_devops_agent_name: "{{ ansible_hostname }}"
az_devops_server_url: "https://dev.azure.com/{{ az_devops_accountname }}"
az_devops_agent_folder: "/home/{{ az_devops_agent_user }}/agent/"
az_devops_work_folder: "/home/{{ az_devops_agent_user }}/agent/_work"
az_devops_agent_pool_name: "Default"
az_devops_agent_role: "build"
az_devops_deployment_group_tags: null
az_devops_environment_name: null
az_devops_deployment_group_name: null
az_devops_agent_replace_existing: false
az_devops_reconfigure_agent: false
az_devops_agent_user_capabilities: null
az_devops_proxy_url: null
az_devops_proxy_username: null
az_devops_proxy_password: null
Variable descriptions:
az_devops_accountname: Your Azure DevOps account name (e.g., https://dev.azure.com/YOUR_ACCOUNT_NAME).
az_devops_accesstoken: A Personal Access Token (PAT) for authentication. Learn how to create one here.
Note: Use Ansible Vault to keep this secure.
az_devops_project_name: Name of the Azure DevOps project where the agent will be registered (used for deployment groups).
az_devops_agent_version: The version of the agent package you want to install. It is important to regularly update it (see latest releases here).
az_devops_agent_user: The username for the account that runs and configures the service.
az_devops_agent_uid: The user ID (UID) for the account running the service.
az_devops_agent_group: Default group for the user running the service.
az_devops_agent_name: The agent's display name in Azure DevOps (defaults to the host's name).
az_devops_server_url: URL for your Azure DevOps account.
az_devops_agent_folder: Folder for agent-specific files (ensure the service user has permission to execute files in this folder).
az_devops_work_folder: Folder for work files like code and build results.
az_devops_agent_pool_name: The pool into which the Azure DevOps agent is added.
az_devops_agent_role: Choose either
build
,deployment
, orresource
.- Build: Use the agent for building code.
- Deployment: Use the agent for deployment groups.
- Resource: Use the agent as a VM resource for deployments.
az_devops_deployment_group_tags: Tags used to identify the agent with the
deployment
role (e.g., QA, Staging, Prod).az_devops_deployment_group_name: Name of the deployment group where the agent will be added. This must already exist in your Azure DevOps project.
az_devops_environment_name: Name of the environment for adding the VM resource with the
resource
role. This must also be created in your Azure DevOps project first.az_devops_agent_replace_existing: Use
--replace
to replace existing agents if needed.az_devops_reconfigure_agent: Forces reconfiguration of the agent even if it is already active.
az_devops_proxy_url: URL for the proxy server in the format
http://url:port
.az_devops_proxy_username: Username for the proxy; leave blank if no authentication is needed.
az_devops_proxy_password: Password for the proxy; leave blank if no authentication is needed.
Note: Consider using Ansible Vault to secure this.
az_devops_agent_user_capabilities: A dictionary for environment variables that the agent process will recognize, useful for setting release pipeline demands.
Example usage:
- az_devops_agent_user_capabilities:
user_capability_key: user_capability_value
Example Playbooks
Build Agent
- hosts: agents
roles:
- gsoft.azure_devops_agent
vars:
- az_devops_agent_role: build
- az_devops_accountname: fubar
- az_devops_accesstoken: ***
Deployment Agent
- hosts: agents
roles:
- gsoft.azure_devops_agent
vars:
- az_devops_agent_role: deployment
- az_devops_accountname: fubar
- az_devops_accesstoken: ***
- az_devops_project_name: baz
- az_devops_deployment_group_name: fubar_group
- az_devops_deployment_group_tags: "web,prod"
Resource
- hosts: agents
roles:
- gsoft.azure_devops_agent
vars:
- az_devops_agent_role: resource
- az_devops_accountname: fubar
- az_devops_accesstoken: ***
- az_devops_project_name: baz
- az_devops_environment_name: staging
Proxy
- hosts: agents
roles:
- gsoft.azure_devops_agent
vars:
- az_devops_agent_role: build
- az_devops_accountname: fubar
- az_devops_accesstoken: ***
- az_devops_proxy_url: "http://127.0.0.1:8080"
- az_devops_proxy_username: bob
- az_devops_proxy_password: ***
License
Copyright © 2020, GSoft inc. This code is licensed under the Apache License, Version 2.0. You can find the license here.
Azure DevOps Agent for Linux.
ansible-galaxy install gsoft.azure_devops_agent