Closed marchenm closed 4 years ago
partly fixed with latest merge.
Let me check for the set_facts
@marchenm what's the problem with setting the vars in any case? I find the set_fact
is a clean way to build the vars right now, even if they aren't used.
The issue was az_devops_project_name
wasn't set in defaults and isn't required for a build agent. I was suggesting splitting set_facts
into 3 separate tasks and using when
to only set facts that are required like so:
- name: Set agent config facts
set_fact:
agent_cmd_args:
- "./config.sh"
- "--unattended"
- "--acceptteeeula"
- "--agent '{{ az_devops_agent_name }}'"
- "--url '{{ az_devops_server_url }}'"
- "--work _work"
- "--auth PAT"
- "--token '{{ az_devops_accesstoken }}'"
- "--runasservice"
- name: Set build agent facts
set_fact:
build_agent_cmd_args:
- "--pool '{{ az_devops_agent_pool_name }}'"
when: az_devops_agent_role == 'build'
- name: Set deploy agent facts
set_fact:
deployment_agent_cmd_args:
- "--deploymentgroup"
- "--deploymentgroupname '{{ az_devops_deployment_group_name }}'"
- "--addDeploymentGroupTags"
- "--deploymentGroupTags '{{ az_devops_deployment_group_tags }}'"
- "--projectname '{{ az_devops_project_name }}'"
when: az_devops_agent_role == 'deployment'
oh ok! I'll gladly accept a PR for this change if you're up to it. Thanks
Seems to be fixed with previous PR https://github.com/gsoft-inc/ansible-role-azure-devops-agent/pull/8. Closing.
the deployment vars should be set only when its a deployment agent. Additionally a default value for
az_devops_project_name
needs to be set.Simply break out the
set_facts
into 3 different tasks and add when statements to build facts and deployment facts.