gsoft-inc / ansible-role-azure-devops-agent

An Ansible role that installs and configures a Linux machine to be used as an Azure DevOps build or deployment agent.
59 stars 72 forks source link

Unexpected templating type error occurred on ({{ (agent_cmd_args + build_agent_cmd_args) | join(' ') }}): can only concatenate str #67

Closed Martin-Andreasson closed 2 years ago

Martin-Andreasson commented 2 years ago

Hi!

I'm receiving the following error when trying to create a build agent.

TASK [gsoft.azure_devops_agent : Configure agent as a build server] **** fatal: [195.154.78.148]: FAILED! => {"msg": "Unexpected templating type error occurred on ({{ (agent_cmd_args + build_agent_cmd_args) | join(' ') }}): can only concatenate str (not \"list\") to str"}

Why is this caused? I've tried reinstalling the ansible role and changing my playbook to the bare minimum.

It looks like this right now. Can someone please help me?

- hosts: all
  roles:
    - gsoft.azure_devops_agent
  vars_files:
    - ../vars/vault.yml
  environment:
    az_devops_accesstoken: "{{ az_devops_accesstoken }}"
  vars:
    az_devops_agent_role: build
    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
    az_devops_accesstoken: "{{ az_devops_accesstoken }}"
    az_devops_server_url: URL
    az_devops_agent_pool_name: Self-hosted Linux
    az_devops_agent_name: linux-agent02-01
    az_devops_agent_group: azure-agent
pcurt commented 2 years ago

Hi,

I have encountered the same issue. The problem is with the task Set proxy (cf #66 )

Try to modify the task from

- name: Set proxy
  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

to

- name: Set proxy
  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 not none
Martin-Andreasson commented 2 years ago

That worked wonders! Thank you!