Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Available variables are listed below, along with default values (see `defaults/m
az_devops_accountname: null
az_devops_accesstoken: null
az_devops_project_name: null
az_devops_agent_version: 2.188.3
az_devops_agent_version: 3.241.0
az_devops_agent_user: "az_devops_agent"
az_devops_agent_uid: null
az_devops_agent_name: "{{ ansible_hostname }}"
Expand Down Expand Up @@ -57,6 +57,21 @@ Available variables are listed below, along with default values (see `defaults/m

Version of the installed agent package. Should be periodically updated to the latest version (see [here](https://github.com/microsoft/azure-pipelines-agent/releases/latest)).

- **az_devops_agent_package_url**

URL for the agent package (see [here](https://github.com/microsoft/azure-pipelines-agent/releases) for a list of available versions).
The value is pre-generated but can be controlled by setting `az_devops_agent_package_url` in your Ansible (inventory) file as follows:
- For pipeline based package with modern Node support for Azure DevOps SaaS:
```yaml
az_devops_agent_package_url: "https://vstsagentpackage.azureedge.net/agent/{{ az_devops_agent_version }}/pipelines-agent-{{ ansible_system | lower | replace('darwin', 'osx') }}-{{ ansible_architecture | replace('x86_64', 'x64') | replace('aarch64', 'arm64') }}-{{ az_devops_agent_version }}.tar.gz"
```

- For pipeline based package without modern Node support for VSTS / Azure DevOps Server: you can leave as it is but it won't support arm based infra, otherwise use as follows:
```yaml
az_devops_agent_package_url: "https://vstsagentpackage.azureedge.net/agent/{{ az_devops_agent_version }}/vsts-agent-{{ ansible_system | lower | replace('darwin', 'osx') }}-{{ ansible_architecture | replace('x86_64', 'x64') | replace('aarch64', 'arm64') }}-{{ az_devops_agent_version }}.tar.gz"
```
It can be added as a default variable that is used across all environments, I will leave for someone else to add it, as it is an easy implementation and not a priority.

- **az_devops_agent_user**

Name of the user used to run and configure the service.
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
az_devops_agent_version: 2.188.3
az_devops_agent_version: 3.241.0
az_devops_agent_user: "az_devops_agent"
az_devops_agent_name: "{{ ansible_hostname }}"
az_devops_server_url: "https://dev.azure.com/{{ az_devops_accountname }}/"
Expand Down
9 changes: 9 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ galaxy_info:
- name: EL
versions:
- 7
- 8
- 9
- name: Debian
versions:
- stretch
Expand All @@ -28,6 +30,13 @@ galaxy_info:
- name: MacOSX
versions:
- 10.15
- 13.6.0
- 13.6.6
- 14.3
- 14.3.1
- 14.4
- 14.4.1
- 14.5

galaxy_tags:
- azure
Expand Down
34 changes: 22 additions & 12 deletions tasks/Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
- name: Create directories
file:
state: directory
path: "{{ item }}"
path: "{{ directory }}"
owner: "{{ az_devops_agent_user }}"
group: "{{ az_devops_agent_group }}"
mode: 0755
loop:
- "{{ az_devops_agent_folder }}"
- "{{ az_devops_work_folder }}"
loop_control:
loop_var: directory
become: true

- name: Install dependencies
Expand Down Expand Up @@ -66,12 +68,12 @@
agent_cmd_args:
- "./config.sh"
- "--unattended"
- "--acceptteeeula"
- "--acceptTeeEula"
- "--url '{{ az_devops_server_url }}'"
- "--work '{{ az_devops_work_folder }}'"
- "--auth PAT"
- "--auth pat"
- "--token '{{ az_devops_accesstoken }}'"
- "--runasservice"
- "--runasservice" # * Windows Only
build_agent_cmd_args:
- "--pool '{{ az_devops_agent_pool_name }}'"
- "--agent '{{ az_devops_agent_name }}'"
Expand All @@ -88,6 +90,12 @@
service_is_running: "{{ svc_status.stdout is defined and svc_status.stdout is regex('active \\(running\\)') }}"
is_requested_version: "{{ bin_agent_listener.stat.exists and agent_listener_version.stdout is defined and agent_listener_version.stdout == az_devops_agent_version }}"

- name: Set Agent config facts combined
set_fact:
build_server_cmd_args: "{{ agent_cmd_args + build_agent_cmd_args }}"
deployment_server_cmd_args: "{{ agent_cmd_args + deployment_agent_cmd_args }}"
resource_server_cmd_args: "{{ agent_cmd_args + resource_agent_cmd_args }}"

- name: Determine if the agent should be reconfigured or replaced
set_fact:
reconfigure_or_replace: "{{ az_devops_reconfigure_agent or az_devops_agent_replace_existing or not is_requested_version }}"
Expand Down Expand Up @@ -139,14 +147,14 @@

- name: Add '--replace' configuration argument
set_fact:
build_agent_cmd_args: "{{ build_agent_cmd_args }} + ['--replace']"
deployment_agent_cmd_args: "{{ build_agent_cmd_args }} + ['--replace']"
resource_agent_cmd_args: "{{ resource_agent_cmd_args }} + ['--replace']"
build_server_cmd_args: "{{ build_server_cmd_args + ['--replace'] }}"
deployment_server_cmd_args: "{{ deployment_server_cmd_args + ['--replace'] }}"
resource_server_cmd_args: "{{ resource_server_cmd_args + ['--replace'] }}"
when:
- az_devops_agent_replace_existing

- name: Configure agent as a build server
command: "{{ (agent_cmd_args + build_agent_cmd_args) | join(' ') }}"
command: "{{ build_server_cmd_args | join(' ') }}"
args:
chdir: "{{ az_devops_agent_folder }}"
creates: "{{ az_devops_agent_folder }}/.agent"
Expand All @@ -157,7 +165,7 @@
- (not service_is_installed) or reconfigure_or_replace

- name: Configure agent as a deployment server
command: "{{ (agent_cmd_args + deployment_agent_cmd_args) | join(' ') }}"
command: "{{ deployment_server_cmd_args | join(' ') }}"
args:
chdir: "{{ az_devops_agent_folder }}"
creates: "{{ az_devops_agent_folder }}/.agent"
Expand All @@ -168,7 +176,7 @@
- (not service_is_installed) or reconfigure_or_replace

- name: Configure agent as an environment resource
command: "{{ (agent_cmd_args + resource_agent_cmd_args) | join(' ') }}"
command: "{{ resource_server_cmd_args | join(' ') }}"
args:
chdir: "{{ az_devops_agent_folder }}"
creates: "{{ az_devops_agent_folder }}/.agent"
Expand All @@ -182,12 +190,14 @@
community.general.ini_file:
path: "{{ az_devops_agent_folder }}/.env"
section: null
option: "{{ item.key }}"
value: "{{ item.value }}"
option: "{{ capability.key }}"
value: "{{ capability.value }}"
no_extra_spaces: yes
owner: "{{ az_devops_agent_user }}"
group: "{{ az_devops_agent_group }}"
loop: "{{ az_devops_agent_user_capabilities | default({}) | dict2items }}"
loop_control:
loop_var: capability
become: true

- name: Install agent service
Expand Down
3 changes: 3 additions & 0 deletions vars/dependencies-Linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Add empty dependency, refer to ./bin/install_dependencies.sh for more info
---
az_devops_agent_dependencies: []
6 changes: 6 additions & 0 deletions vars/dependencies-RedHat-8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
az_devops_agent_dependencies:
- krb5-libs
- libicu
- lttng-ust
- openssl-libs
- zlib
6 changes: 6 additions & 0 deletions vars/dependencies-RedHat-9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
az_devops_agent_dependencies:
- krb5-libs
- libicu
- lttng-ust
- openssl-libs
- zlib