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

fix(Windows): formatting package_params input to Chocolatey #73

Open
wants to merge 3 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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ Available variables are listed below, along with default values (see `defaults/m
az_devops_agent_pool_name: "Default"
az_devops_agent_role: "build"
az_devops_deployment_group_tags: null
az_devops_environment_name: null
az_devops_deployment_group_name: null
az_devops_environment_name: null
az_devops_environment_tags: null
az_devops_agent_replace_existing: false
az_devops_reconfigure_agent: false
az_devops_agent_user_capabilities: null
Expand Down Expand Up @@ -105,6 +106,10 @@ Available variables are listed below, along with default values (see `defaults/m

Use in conjuction with the `resource` agent role. The name of the environment in which to add the VM resource. **This needs to be manually created in you Azure DevOps project beforehand.**

- **az_devops_environment_tags**

Use in conjuction with the `resource` agent role. Allows the user of tags to identify the agent (ex: QA, Staging, Prod, etc.)

- **az_devops_agent_replace_existing**

Adds the `--replace` argument to the configuration script for the [scenario where you need to replace an exiting agent with a new host](https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/v2-linux?view=azure-devops#pool-and-agent-names).
Expand Down
63 changes: 37 additions & 26 deletions tasks/Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
password: "{{ az_devops_agent_password }}"
state: present
password_never_expires: true
become: yes
become: true
when:

- az_devops_agent_create_local_user

- name: Ensure chocolatey is present
win_chocolatey:
name: chocolatey
Expand All @@ -17,7 +17,7 @@
# https://github.com/flcdrg/au-packages/blob/master/azure-pipelines-agent/README.md

- name: Set basic agent package parameters
set_fact:
ansible.builtin.set_fact:
common_install_options:
- "/Directory:{{ az_devops_agent_folder }}"
- "/Url:{{ az_devops_server_url }}"
Expand All @@ -41,55 +41,66 @@
- "/ProjectName:{{ az_devops_project_name }}"

- name: Add '/Replace' configuration argument
set_fact:
common_install_options: "{{ common_install_options }} + ['/Replace']"
ansible.builtin.set_fact:
common_install_options: "{{ common_install_options + ['/Replace'] }}"
when:
- az_devops_agent_replace_existing

- name: Add deployment group tags
set_fact:
deployment_install_options: "{{ deployment_install_options }} + ['/DeploymentGroupTags:{{ az_devops_deployment_group_tags }}']"
ansible.builtin.set_fact:
deployment_install_options: "{{ deployment_install_options + ['/DeploymentGroupTags:' + az_devops_deployment_group_tags] }}"
when:
- az_devops_deployment_group_tags is defined
- az_devops_deployment_group_tags

- name: Add environment resource tags
ansible.builtin.set_fact:
resource_agent_install_options: "{{ resource_agent_install_options + ['/EnvironmentTags:' + az_devops_environment_tags] }}"
when:
- az_devops_environment_tags is defined
- az_devops_environment_tags

- name: Add az_devops_proxy_url
set_fact:
common_install_options: "{{ common_install_options }} + ['/ProxyUrl:{{ az_devops_proxy_url }}']"
ansible.builtin.set_fact:
common_install_options: "{{ common_install_options + ['/ProxyUrl:' + az_devops_proxy_url] }}"
when:
- az_devops_proxy_url is defined and az_devops_proxy_url
- az_devops_proxy_url is defined
- az_devops_proxy_url

- name: Add az_devops_proxy_username
set_fact:
common_install_options: "{{ common_install_options }} + ['/ProxyUserName:{{ az_devops_proxy_username }}']"
ansible.builtin.set_fact:
common_install_options: "{{ common_install_options + ['/ProxyUserName:' + az_devops_proxy_username] }}"
when:
- az_devops_proxy_username is defined and az_devops_proxy_username
- az_devops_proxy_username is defined
- az_devops_proxy_username

- name: Add az_devops_proxy_password
set_fact:
common_install_options: "{{ common_install_options }} + ['/ProxyPassword:{{ az_devops_proxy_password }}']"
ansible.builtin.set_fact:
common_install_options: "{{ common_install_options + ['/ProxyPassword:' + az_devops_proxy_password] }}"
when:
- az_devops_proxy_password is defined and az_devops_proxy_password
- az_devops_proxy_password is defined
- az_devops_proxy_password

- name: Configure agent as a build server
set_fact:
az_devops_agent_package_params: "{{ common_install_options }} + {{ build_agent_install_options }}"
ansible.builtin.set_fact:
az_devops_agent_package_params: "{{ common_install_options + build_agent_install_options }}"
when:
- az_devops_agent_role == 'build'
- az_devops_agent_role == 'build'

- name: Configure agent as a deployment server
set_fact:
az_devops_agent_package_params: "{{ common_install_options }} + {{ deployment_install_options }}"
ansible.builtin.set_fact:
az_devops_agent_package_params: "{{ common_install_options + deployment_install_options }}"
when:
- az_devops_agent_role == 'deployment'
- az_devops_agent_role == 'deployment'

- name: Configure agent as an environment resource
set_fact:
az_devops_agent_package_params: "{{ common_install_options }} + {{ resource_agent_install_options }}"
ansible.builtin.set_fact:
az_devops_agent_package_params: "{{ common_install_options + resource_agent_install_options }}"
when:
- az_devops_agent_role == 'resource'
- az_devops_agent_role == 'resource'

- name: Install azure-pipelines-agent package
win_chocolatey:
chocolatey.chocolatey.win_chocolatey:
name: azure-pipelines-agent
state: present
version: "{{ az_devops_agent_version }}"
Expand Down