Skip to content

Commit cea6dee

Browse files
committed
Add support for Ubuntu 22.04
2 parents 6136134 + 12143ae commit cea6dee

File tree

8 files changed

+130
-61
lines changed

8 files changed

+130
-61
lines changed

Diff for: README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ Available variables are listed below, along with default values (see `defaults/m
1919
az_devops_accountname: null
2020
az_devops_accesstoken: null
2121
az_devops_project_name: null
22-
az_devops_agent_version: 2.188.3
22+
az_devops_agent_version: 2.218.1
2323
az_devops_agent_user: "az_devops_agent"
24+
az_devops_agent_group: "az_devops_agent"
2425
az_devops_agent_uid: null
26+
az_devops_agent_gid: null
2527
az_devops_agent_name: "{{ ansible_hostname }}"
2628
az_devops_server_url: "https://dev.azure.com/{{ az_devops_accountname }}"
2729
az_devops_agent_folder: "/home/{{ az_devops_agent_user }}/agent/"
@@ -69,6 +71,10 @@ Available variables are listed below, along with default values (see `defaults/m
6971
7072
Default group of the user used to run and configure the service.
7173
74+
- **az_devops_agent_gid**
75+
76+
GID of the user group used to run and configure the service.
77+
7278
- **az_devops_agent_name**
7379
7480
Name of the agent shown in Azure DevOps (defaults to the name of the host.).

Diff for: defaults/main.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
az_devops_agent_version: 2.188.3
1+
---
2+
az_devops_agent_version: 2.218.1
23
az_devops_agent_user: "az_devops_agent"
34
az_devops_agent_name: "{{ ansible_hostname }}"
45
az_devops_server_url: "https://dev.azure.com/{{ az_devops_accountname }}/"
@@ -18,3 +19,5 @@ az_devops_proxy_url: null
1819
az_devops_proxy_username: null
1920
az_devops_proxy_password: null
2021
az_devops_agent_create_local_user: true
22+
az_devops_agent_legacy_dependencies: []
23+
...

Diff for: meta/main.yml

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
1+
---
12
galaxy_info:
23
role_name: azure_devops_agent
3-
author: Yohan Belval
4+
author: gsoft
45
description: Azure DevOps Agent for Linux.
56
company: GSoft
7+
standalone: true
68

79
license: "license (Apache-2.0)"
810

9-
min_ansible_version: 2.4
11+
min_ansible_version: "2.10"
1012

1113
platforms:
1214
- name: Ubuntu
1315
versions:
1416
- xenial
1517
- bionic
1618
- focal
19+
- jammy
1720
- name: EL
1821
versions:
19-
- 7
22+
- "7"
23+
- "8"
2024
- name: Debian
2125
versions:
2226
- stretch
2327
- buster
28+
- bullseye
2429
- name: Windows
2530
versions:
26-
- 2016
27-
- 2019
31+
- "2016"
32+
- "2019"
2833
- name: MacOSX
2934
versions:
30-
- 10.15
35+
- "10.15"
3136

3237
galaxy_tags:
3338
- azure
@@ -37,3 +42,4 @@ galaxy_info:
3742
- deployment
3843
- ci
3944
- cd
45+
...

Diff for: tasks/Darwin.yml

+34-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
---
2+
- name: Add an agent group {{ az_devops_agent_group }}
3+
ansible.builtin.group:
4+
name: "{{ az_devops_agent_group }}"
5+
gid: "{{ az_devops_agent_gid | default(omit) }}"
6+
state: present
7+
become: true
8+
19
- name: Add an agent user
210
ansible.builtin.user:
311
name: "{{ az_devops_agent_user }}"
412
comment: "Azure DevOps Agent"
513
shell: /bin/zsh
614
group: "{{ az_devops_agent_group }}"
7-
uid: "{{ az_devops_agent_uid|default(omit) }}"
15+
uid: "{{ az_devops_agent_uid | default(omit) }}"
816
become: true
917

1018
- name: Create directories
@@ -47,7 +55,7 @@
4755
register: svc_sh
4856
become: true
4957
changed_when: false
50-
check_mode: no
58+
check_mode: false
5159

5260
- name: Check service status
5361
ansible.builtin.command: ./svc.sh status
@@ -57,7 +65,7 @@
5765
chdir: "{{ az_devops_agent_folder }}"
5866
register: svc_status
5967
changed_when: false
60-
check_mode: no
68+
check_mode: false
6169
when: svc_sh.stat.exists
6270

6371
- name: Set agent config facts
@@ -89,17 +97,21 @@
8997

9098
- name: Add deployment group tags
9199
ansible.builtin.set_fact:
92-
deployment_agent_cmd_args: "{{ deployment_agent_cmd_args }} +
93-
['--addDeploymentGroupTags', '--deploymentGroupTags \\'{{ az_devops_deployment_group_tags }}\\'']"
100+
deployment_agent_cmd_args: "{{ deployment_agent_cmd_args + ['--addDeploymentGroupTags', '--deploymentGroupTags', az_devops_deployment_group_tags] }}"
101+
when:
102+
- az_devops_deployment_group_tags is defined and az_devops_deployment_group_tags != None
103+
104+
- name: Set proxy url
105+
ansible.builtin.set_fact:
106+
agent_cmd_args: "{{ agent_cmd_args + ['--proxyurl', az_devops_proxy_url] }}"
94107
when:
95-
- az_devops_deployment_group_tags is defined
108+
- az_devops_proxy_url is defined and az_devops_proxy_url != None
96109

97-
- name: Set proxy
110+
- name: Set proxy username and password
98111
ansible.builtin.set_fact:
99-
agent_cmd_args: "{{ agent_cmd_args }} + ['--proxyurl \\'{{ az_devops_proxy_url }}\\'',
100-
'--proxyusername \\'{{ az_devops_proxy_username }}\\'', '--proxypassword \\'{{ az_devops_proxy_password }}\\'']"
112+
agent_cmd_args: "{{ agent_cmd_args + ['--proxyusername', az_devops_proxy_username, '--proxypassword', az_devops_proxy_password] }}"
101113
when:
102-
- az_devops_proxy_url is defined
114+
- az_devops_proxy_url is defined and az_devops_proxy_url != None and az_devops_proxy_username != None and az_devops_proxy_password != None
103115

104116
- name: Uninstall agent service
105117
ansible.builtin.command: ./svc.sh uninstall
@@ -125,9 +137,9 @@
125137

126138
- name: Add '--replace' configuration argument
127139
ansible.builtin.set_fact:
128-
build_agent_cmd_args: "{{ build_agent_cmd_args }} + ['--replace']"
129-
deployment_agent_cmd_args: "{{ build_agent_cmd_args }} + ['--replace']"
130-
resource_agent_cmd_args: "{{ resource_agent_cmd_args }} + ['--replace']"
140+
build_agent_cmd_args: "{{ build_agent_cmd_args + ['--replace'] }}"
141+
deployment_agent_cmd_args: "{{ build_agent_cmd_args + ['--replace'] }}"
142+
resource_agent_cmd_args: "{{ resource_agent_cmd_args + ['--replace'] }}"
131143
when:
132144
- az_devops_agent_replace_existing
133145

@@ -170,14 +182,18 @@
170182
section: null
171183
option: "{{ item.key }}"
172184
value: "{{ item.value }}"
173-
no_extra_spaces: yes
185+
no_extra_spaces: true
174186
owner: "{{ az_devops_agent_user }}"
175187
group: "{{ az_devops_agent_group }}"
188+
mode: "0640"
176189
loop: "{{ az_devops_agent_user_capabilities | default({}) | dict2items }}"
177190
become: true
178191

179192
- name: Install agent service
180193
ansible.builtin.command: ./svc.sh install {{ az_devops_agent_user }}
194+
register: agent_install
195+
failed_when: agent_install.rc != 0
196+
changed_when: agent_install.rc == 0
181197
become: true
182198
become_user: "{{ az_devops_agent_user }}"
183199
args:
@@ -187,9 +203,13 @@
187203

188204
- name: Start agent service
189205
ansible.builtin.command: ./svc.sh start
206+
register: agent_start
207+
failed_when: agent_start.rc != 0
208+
changed_when: agent_start.rc == 0
190209
become: true
191210
become_user: "{{ az_devops_agent_user }}"
192211
args:
193212
chdir: "{{ az_devops_agent_folder }}"
194213
when:
195214
- (not service_is_running) or reconfigure_or_replace
215+
...

Diff for: tasks/Linux.yml

+43-22
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
- name: Add an agent user group
1+
---
2+
- name: Add an agent group {{ az_devops_agent_group }}
23
ansible.builtin.group:
34
name: "{{ az_devops_agent_group }}"
5+
gid: "{{ az_devops_agent_gid | default(omit) }}"
46
state: present
5-
become: true
67

78
- name: Add an agent user
89
ansible.builtin.user:
910
name: "{{ az_devops_agent_user }}"
1011
group: "{{ az_devops_agent_group }}"
11-
uid: "{{ az_devops_agent_uid|default(omit) }}"
12+
uid: "{{ az_devops_agent_uid | default(omit) }}"
1213
comment: "Azure DevOps Agent"
1314
shell: /bin/bash
1415
become: true
1516

1617
- name: Create directories
17-
ansible.bulitin.file:
18+
ansible.builtin.file:
1819
state: directory
1920
path: "{{ item }}"
2021
owner: "{{ az_devops_agent_user }}"
@@ -27,8 +28,9 @@
2728

2829
- name: Install Legacy dependencies
2930
ansible.builtin.apt:
30-
name: "{{ az_devops_agent_legacy_dependencies }}"
31+
deb: "{{ item }}"
3132
state: present
33+
loop: "{{ az_devops_agent_legacy_dependencies }}"
3234
become: true
3335
when: ansible_os_family == "Debian"
3436

@@ -51,7 +53,7 @@
5153
register: svc_sh
5254
become: true
5355
changed_when: false
54-
check_mode: no
56+
check_mode: false
5557

5658
- name: Check service status
5759
ansible.builtin.command: ./svc.sh status
@@ -60,7 +62,7 @@
6062
chdir: "{{ az_devops_agent_folder }}"
6163
register: svc_status
6264
changed_when: false
63-
check_mode: no
65+
check_mode: false
6466
when: svc_sh.stat.exists
6567

6668
- name: Check if bin/Agent.Listener exists
@@ -69,7 +71,7 @@
6971
register: bin_agent_listener
7072
become: true
7173
changed_when: false
72-
check_mode: no
74+
check_mode: false
7375

7476
- name: Check agent version
7577
ansible.builtin.command: ./bin/Agent.Listener --version
@@ -78,7 +80,7 @@
7880
chdir: "{{ az_devops_agent_folder }}"
7981
register: agent_listener_version
8082
changed_when: false
81-
check_mode: no
83+
check_mode: false
8284
when: bin_agent_listener.stat.exists
8385

8486
- name: Set agent config facts
@@ -114,22 +116,33 @@
114116

115117
- name: Add deployment group tags
116118
ansible.builtin.set_fact:
117-
deployment_agent_cmd_args: "{{ deployment_agent_cmd_args }} +
118-
['--addDeploymentGroupTags', '--deploymentGroupTags \\'{{ az_devops_deployment_group_tags }}\\'']"
119+
deployment_agent_cmd_args: "{{ deployment_agent_cmd_args + ['--addDeploymentGroupTags', '--deploymentGroupTags', az_devops_deployment_group_tags] }}"
119120
when:
120-
- az_devops_deployment_group_tags is defined
121+
- az_devops_deployment_group_tags is defined and az_devops_deployment_group_tags != None
121122

122-
- name: Set proxy
123+
- name: Set proxy url
123124
ansible.builtin.set_fact:
124-
agent_cmd_args: "{{ agent_cmd_args }} + ['--proxyurl \\'{{ az_devops_proxy_url }}\\'', '--proxyusername \\'{{ az_devops_proxy_username }}\\'', '--proxypassword \\'{{ az_devops_proxy_password }}\\'']"
125+
agent_cmd_args: "{{ agent_cmd_args + ['--proxyurl', az_devops_proxy_url] }}"
125126
when:
126-
- az_devops_proxy_url is defined
127+
- az_devops_proxy_url is defined and az_devops_proxy_url != None
127128

128-
- name: Download and unarchive
129+
- name: Set proxy user and password
130+
ansible.builtin.set_fact:
131+
agent_cmd_args: "{{ agent_cmd_args + ['--proxyusername', az_devops_proxy_username, '--proxypassword', az_devops_proxy_password] }}"
132+
when:
133+
- az_devops_proxy_url is defined and az_devops_proxy_url != None and az_devops_proxy_username != None and az_devops_proxy_password != None
134+
135+
- name: Download {{ az_devops_agent_package_url }}
136+
ansible.builtin.get_url:
137+
url: "{{ az_devops_agent_package_url }}"
138+
dest: "/tmp/az_devops_agent_package.tar.gz"
139+
mode: "0644"
140+
141+
- name: Unarchive /tmp/az_devops_agent_package.tar.gz
129142
ansible.builtin.unarchive:
130-
src: "{{ az_devops_agent_package_url }}"
143+
src: "/tmp/az_devops_agent_package.tar.gz"
131144
dest: "{{ az_devops_agent_folder }}"
132-
remote_src: yes
145+
remote_src: true
133146
owner: "{{ az_devops_agent_user }}"
134147
group: "{{ az_devops_agent_group }}"
135148
become: true
@@ -159,9 +172,9 @@
159172

160173
- name: Add '--replace' configuration argument
161174
ansible.builtin.set_fact:
162-
build_agent_cmd_args: "{{ build_agent_cmd_args }} + ['--replace']"
163-
deployment_agent_cmd_args: "{{ build_agent_cmd_args }} + ['--replace']"
164-
resource_agent_cmd_args: "{{ resource_agent_cmd_args }} + ['--replace']"
175+
build_agent_cmd_args: "{{ build_agent_cmd_args + ['--replace'] }}"
176+
deployment_agent_cmd_args: "{{ build_agent_cmd_args + ['--replace'] }}"
177+
resource_agent_cmd_args: "{{ resource_agent_cmd_args + ['--replace'] }}"
165178
when:
166179
- az_devops_agent_replace_existing
167180

@@ -204,14 +217,18 @@
204217
section: null
205218
option: "{{ item.key }}"
206219
value: "{{ item.value }}"
207-
no_extra_spaces: yes
220+
no_extra_spaces: true
208221
owner: "{{ az_devops_agent_user }}"
209222
group: "{{ az_devops_agent_group }}"
223+
mode: "0640"
210224
loop: "{{ az_devops_agent_user_capabilities | default({}) | dict2items }}"
211225
become: true
212226

213227
- name: Install agent service
214228
ansible.builtin.command: ./svc.sh install {{ az_devops_agent_user }}
229+
register: agent_install
230+
failed_when: agent_install.rc != 0
231+
changed_when: agent_install.rc == 0
215232
become: true
216233
args:
217234
chdir: "{{ az_devops_agent_folder }}"
@@ -220,8 +237,12 @@
220237

221238
- name: Start agent service
222239
ansible.builtin.command: ./svc.sh start
240+
register: agent_start
241+
failed_when: agent_start.rc != 0
242+
changed_when: agent_start.rc == 0
223243
become: true
224244
args:
225245
chdir: "{{ az_devops_agent_folder }}"
226246
when:
227247
- (not service_is_running) or reconfigure_or_replace
248+
...

0 commit comments

Comments
 (0)