Open andrescolodrero opened 2 years ago
Hi, this will download an create a new folder for a new agent. but it will be nice to have agent_name as an array az_devops_agent_name: "{{ ansible_hostname }}-agent1" az_devops_agent_folder: "/home/{{ az_devops_agent_user }}/{{ az_devops_agent_name }}/" az_devops_work_folder: "/home/{{ az_devops_agent_user }}/{{ az_devops_agent_name }}/_work"
I've worked around this using the following ansible:
- name: Check for agent service for {{ az_devops_agent_name }}
ansible.windows.win_service_info:
name: 'vstsagent.tfs.{{ az_devops_agent_pool_name }}.{{ az_devops_agent_name }}'
register: service_info
# - debug:
# var: service_info
# Removing chocolately lib allows installing multiple packages of same version
# See: https://github.com/chocolatey/choco/issues/1022
- name: Remove chocolatly lib folder azure-pipelines-agent.{{ az_devops_agent_version }}
ansible.windows.win_file:
path: 'C:\ProgramData\chocolatey\lib\azure-pipelines-agent.{{ az_devops_agent_version }}'
state: absent
when: service_info.exists == false or service_info.services[0].state != "started"
# This role https://github.com/gsoft-inc/ansible-role-azure-devops-agent
# Uses chocolaty package https://community.chocolatey.org/packages/azure-pipelines-agent
- name: Install Azure DevOps Agent {{ az_devops_agent_name }}
include_role:
name: gsoft.azure_devops_agent
allow_duplicates: yes
when: service_info.exists == false or service_info.services[0].state != "started"
Playbook could accept an array of agent names, so it is possible to have multiple agents in same server.
Actually, there is no possibility and adding a new name to the variables, will uninstall existing one.