Skip to content

Instantly share code, notes, and snippets.

@dtelaroli
Last active January 24, 2019 17:31
Show Gist options
  • Select an option

  • Save dtelaroli/61726495f7ee4d83e43e5d80eb0b0fb9 to your computer and use it in GitHub Desktop.

Select an option

Save dtelaroli/61726495f7ee4d83e43e5d80eb0b0fb9 to your computer and use it in GitHub Desktop.
Deploy a new vsts self-hosted agent on Ubuntu 18.04
# Ansible tests
# $ ansible-playbook vsts-playbook.yml
---
- name: Install vsts agent
hosts:
- <your host>
vars:
ansible_python_interpreter: /usr/bin/python3
vsts_version: 2.144.0
vsts_folder: /opt/vsts-agent
vsts_server_url: https://dev.azure.com/<your company>
vsts_accesstoken: "<your token>"
vsts_poolname: <your pool name>
vsts_agent_name: <your agent name>
tasks:
- name: install pip
apt:
pkg: python3-pip
state: present
become: yes
- name: install pexpect
pip:
name: pexpect
become: yes
- name: ensure vsts-agent directory exists
file:
path: "{{vsts_folder}}"
owner: ubuntu
state: directory
become: yes
- name: unpack agent
unarchive:
src: https://vstsagentpackage.azureedge.net/agent/{{vsts_version}}/vsts-agent-linux-x64-{{vsts_version}}.tar.gz
dest: "{{vsts_folder}}"
remote_src: yes
creates: "{{vsts_folder}}/config.sh"
- name: configure vsts-agent
expect:
chdir: "{{vsts_folder}}"
command: "./config.sh"
echo: true
creates: "{{vsts_folder}}/.agent"
responses:
Enter.+Accept the Team Explorer: "Y"
Enter server URL: "{{vsts_server_url}}"
Enter authentication type: "PAT"
Enter personal access token: "{{vsts_accesstoken}}"
Enter agent pool: "{{vsts_poolname}}"
Enter agent name: "{{vsts_agent_name}}"
Enter work folder: "_work"
- name: install vsts-agent service
command: "./svc.sh install"
args:
chdir: "{{vsts_folder}}"
creates: ".service"
become: yes
- name: start vsts-agent service
command: "./svc.sh start"
args:
chdir: "{{vsts_folder}}"
become: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment