Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix ansible-lint #76

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
warn_list:
- yaml[line-length]
13 changes: 7 additions & 6 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
galaxy_info:
role_name: azure_devops_agent
author: Yohan Belval
author: gsoft
description: Azure DevOps Agent for Linux.
company: GSoft
standalone: true

license: "license (Apache-2.0)"

min_ansible_version: 2.4
min_ansible_version: '2.4'

platforms:
- name: Ubuntu
Expand All @@ -16,18 +17,18 @@ galaxy_info:
- focal
- name: EL
versions:
- 7
- '7'
- name: Debian
versions:
- stretch
- buster
- name: Windows
versions:
- 2016
- 2019
- '2016'
- '2019'
- name: MacOSX
versions:
- 10.15
- '10.15'

galaxy_tags:
- azure
Expand Down
52 changes: 27 additions & 25 deletions tasks/Darwin.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
---
- name: Add an agent user
user:
ansible.builtin.user:
name: "{{ az_devops_agent_user }}"
comment: "Azure DevOps Agent"
shell: /bin/zsh
group: "{{ az_devops_agent_group }}"
uid: "{{ az_devops_agent_uid|default(omit) }}"
uid: "{{ az_devops_agent_uid | default(omit) }}"
become: true

- name: Create directories
file:
ansible.builtin.file:
state: directory
path: "{{ item }}"
owner: "{{ az_devops_agent_user }}"
group: "{{ az_devops_agent_group }}"
mode: 0755
mode: '0755'
loop:
- "{{ az_devops_launchagent_folder }}"
- "{{ az_devops_agent_folder }}"
Expand All @@ -25,7 +26,7 @@
# even then doesn't use the provided gnu tar.
# Makes using ansible on macos a questionable endeavor (but some of us are left with that)...
- name: Download agent
get_url:
ansible.builtin.get_url:
url: "{{ az_devops_agent_package_url }}"
dest: "{{ az_devops_default_agent_local_package }}"
owner: "{{ az_devops_agent_user }}"
Expand All @@ -35,33 +36,33 @@
become: true

- name: Unarchive agent
shell: "cd {{ az_devops_agent_folder }} && tar -zxf {{ az_devops_default_agent_local_package }}"
ansible.builtin.shell: "cd {{ az_devops_agent_folder }} && tar -zxf {{ az_devops_default_agent_local_package }}"
become: true
become_user: "{{ az_devops_agent_user }}"
when: agent_download.changed or agent_directory.changed
tags: ['skip_ansible_lint']

- name: Check if svc.sh exists
stat:
ansible.builtin.stat:
path: "{{ '/'.join((az_devops_agent_folder, 'svc.sh')) }}"
register: svc_sh
become: true
changed_when: false
check_mode: no
check_mode: false

- name: Check service status
command: ./svc.sh status
ansible.builtin.command: ./svc.sh status
become: true
become_user: "{{ az_devops_agent_user }}"
args:
chdir: "{{ az_devops_agent_folder }}"
register: svc_status
changed_when: false
check_mode: no
check_mode: false
when: svc_sh.stat.exists

- name: Set agent config facts
set_fact:
ansible.builtin.set_fact:
agent_cmd_args:
- "./config.sh"
- "--unattended"
Expand All @@ -88,21 +89,21 @@
reconfigure_or_replace: "{{ az_devops_reconfigure_agent or az_devops_agent_replace_existing }}"

- name: Add deployment group tags
set_fact:
ansible.builtin.set_fact:
deployment_agent_cmd_args: "{{ deployment_agent_cmd_args }} +
['--addDeploymentGroupTags', '--deploymentGroupTags \\'{{ az_devops_deployment_group_tags }}\\'']"
when:
- az_devops_deployment_group_tags is defined

- name: Set proxy
set_fact:
ansible.builtin.set_fact:
agent_cmd_args: "{{ agent_cmd_args }} + ['--proxyurl \\'{{ az_devops_proxy_url }}\\'',
'--proxyusername \\'{{ az_devops_proxy_username }}\\'', '--proxypassword \\'{{ az_devops_proxy_password }}\\'']"
when:
- az_devops_proxy_url is defined

- name: Uninstall agent service
command: ./svc.sh uninstall
ansible.builtin.command: ./svc.sh uninstall
become: true
become_user: "{{ az_devops_agent_user }}"
args:
Expand All @@ -113,7 +114,7 @@
- reconfigure_or_replace

- name: Unconfigure agent
command: "./config.sh remove --auth PAT --token {{ az_devops_accesstoken }}"
ansible.builtin.command: "./config.sh remove --auth PAT --token {{ az_devops_accesstoken }}"
args:
chdir: "{{ az_devops_agent_folder }}"
removes: "{{ az_devops_agent_folder }}/.agent"
Expand All @@ -124,15 +125,15 @@
- reconfigure_or_replace

- name: Add '--replace' configuration argument
set_fact:
ansible.builtin.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']"
when:
- az_devops_agent_replace_existing

- name: Configure agent as a build server
command: "{{ (agent_cmd_args + build_agent_cmd_args) | join(' ') }}"
ansible.builtin.command: "{{ (agent_cmd_args + build_agent_cmd_args) | join(' ') }}"
args:
chdir: "{{ az_devops_agent_folder }}"
creates: "{{ az_devops_agent_folder }}/.agent"
Expand All @@ -143,7 +144,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(' ') }}"
ansible.builtin.command: "{{ (agent_cmd_args + deployment_agent_cmd_args) | join(' ') }}"
args:
chdir: "{{ az_devops_agent_folder }}"
creates: "{{ az_devops_agent_folder }}/.agent"
Expand All @@ -154,7 +155,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(' ') }}"
ansible.builtin.command: "{{ (agent_cmd_args + resource_agent_cmd_args) | join(' ') }}"
args:
chdir: "{{ az_devops_agent_folder }}"
creates: "{{ az_devops_agent_folder }}/.agent"
Expand All @@ -165,28 +166,29 @@
- (not service_is_installed) or reconfigure_or_replace

- name: Set provided user defined capabilities
ini_file:
community.general.ini_file:
path: "{{ az_devops_agent_folder }}/.env"
section: null
option: "{{ item.key }}"
value: "{{ item.value }}"
no_extra_spaces: yes
no_extra_spaces: true
owner: "{{ az_devops_agent_user }}"
group: "{{ az_devops_agent_group }}"
mode: '0600'
loop: "{{ az_devops_agent_user_capabilities | default({}) | dict2items }}"
become: true

- name: Install agent service
command: ./svc.sh install {{ az_devops_agent_user }}
- name: Install agent service # noqa no-changed-when
ansible.builtin.command: ./svc.sh install {{ az_devops_agent_user }}
become: true
become_user: "{{ az_devops_agent_user }}"
args:
chdir: "{{ az_devops_agent_folder }}"
when:
- (not service_is_installed) or reconfigure_or_replace

- name: Start agent service
command: ./svc.sh start
- name: Start agent service # noqa no-changed-when
ansible.builtin.command: ./svc.sh start
become: true
become_user: "{{ az_devops_agent_user }}"
args:
Expand Down
Loading