ansible-role-azure-devops-agent icon indicating copy to clipboard operation
ansible-role-azure-devops-agent copied to clipboard

Wrong condition is defined for Role Variables

Open pcurt opened this issue 2 years ago • 0 comments

The issue

Some task are depending on the definition of some role variables. For example the set proxy task is defined like it:

- 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

The problem is that az_devops_proxy_url is defined to null in main.yml file az_devops_proxy_url: null

With this initialisation the condition az_devops_proxy_url is defined is true and the task is not skipped.

The fix

To fix the issue we shall use this condition for all tasks depending a variable role definition:

 when:
    - az_devops_proxy_url is not none

pcurt avatar Aug 08 '22 12:08 pcurt