forked from angrox/ansible-role-vsts-agent
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from stone-payments/feature/debian-rhel
Debian support
- Loading branch information
Showing
13 changed files
with
395 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 40 additions & 40 deletions
80
tasks/configure_vsts_agent.yml → tasks/debian/configure_vsts_agent.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
- name: Register base install command as fact in variable install_command | ||
set_fact: | ||
install_command: "./config.sh --unattended --acceptteeeula --url {{vsts_server_url}} --auth PAT --token {{vsts_accesstoken}} --agent {{vsts_agent_name}} --work {{vsts_workfolder}} --replace" | ||
|
||
- name: Add agent pool to install command (default queue-agent) | ||
set_fact: | ||
install_command: "{{ install_command }} --pool {{ vsts_poolname }}" | ||
when: vsts_poolname|default("") != "" | ||
|
||
- name: Add proxy-url to install command | ||
set_fact: | ||
install_command: "{{ install_command }} --proxyurl {{ vsts_proxyurl }}" | ||
when: vsts_proxyurl|default("") != "" | ||
|
||
- name: Add deployment group info to install command (deployment group agent) | ||
set_fact: | ||
install_command: "{{ install_command }} --projectname {{ vsts_projectname}} --deploymentgroup --deploymentgroupname {{ vsts_deploymentgroupname}} " | ||
when: | ||
- vsts_deploymentgroupname|default("") != "" | ||
- vsts_projectname|default("") != "" | ||
|
||
- name: Fail for conflicting options for default agent x deployment agent | ||
fail: | ||
msg: "The vsts_poolname({{ vsts_poolname }}) and vsts_deploymentgroupname({{ vsts_deploymentgroupname }}) vars are present at same time, choose one of them to install the default queue/build agent or the deployment group agent." | ||
when: | ||
- vsts_poolname|default("") != "" | ||
- vsts_deploymentgroupname|default("") != "" | ||
|
||
- name: Fail for missing parameters in install command | ||
fail: | ||
msg: "Neither the vsts_poolname({{ AGENT_POOL }}) or the vsts_deploymentgroupname({{ vsts_deploymentgroupname }}) vars are present, choose one of them to install the default queue/build agent or the deployment group agent." | ||
when: | ||
- vsts_poolname|default("") == "" | ||
- vsts_deploymentgroupname|default("") == "" | ||
|
||
- name: Configure vsts-agent | ||
command: "{{ install_command }}" | ||
args: | ||
chdir: "{{vsts_agentfolder}}" | ||
creates: "{{vsts_agentfolder}}/.agent" | ||
- name: Register base install command as fact in variable install_command | ||
set_fact: | ||
install_command: "./config.sh --unattended --acceptteeeula --url {{vsts_server_url}} --auth PAT --token {{vsts_accesstoken}} --agent {{vsts_agent_name}} --work {{vsts_workfolder}} --replace" | ||
|
||
- name: Add agent pool to install command (default queue-agent) | ||
set_fact: | ||
install_command: "{{ install_command }} --pool {{ vsts_poolname }}" | ||
when: vsts_poolname|default("") != "" | ||
|
||
- name: Add proxy-url to install command | ||
set_fact: | ||
install_command: "{{ install_command }} --proxyurl {{ vsts_proxyurl }}" | ||
when: vsts_proxyurl|default("") != "" | ||
|
||
- name: Add deployment group info to install command (deployment group agent) | ||
set_fact: | ||
install_command: "{{ install_command }} --projectname {{ vsts_projectname}} --deploymentgroup --deploymentgroupname {{ vsts_deploymentgroupname}} " | ||
when: | ||
- vsts_deploymentgroupname|default("") != "" | ||
- vsts_projectname|default("") != "" | ||
|
||
- name: Fail for conflicting options for default agent x deployment agent | ||
fail: | ||
msg: "The vsts_poolname({{ vsts_poolname }}) and vsts_deploymentgroupname({{ vsts_deploymentgroupname }}) vars are present at same time, choose one of them to install the default queue/build agent or the deployment group agent." | ||
when: | ||
- vsts_poolname|default("") != "" | ||
- vsts_deploymentgroupname|default("") != "" | ||
|
||
- name: Fail for missing parameters in install command | ||
fail: | ||
msg: "Neither the vsts_poolname({{ AGENT_POOL }}) or the vsts_deploymentgroupname({{ vsts_deploymentgroupname }}) vars are present, choose one of them to install the default queue/build agent or the deployment group agent." | ||
when: | ||
- vsts_poolname|default("") == "" | ||
- vsts_deploymentgroupname|default("") == "" | ||
|
||
- name: Configure vsts-agent | ||
command: "{{ install_command }}" | ||
args: | ||
chdir: "{{vsts_agentfolder}}" | ||
creates: "{{vsts_agentfolder}}/.agent" | ||
become_user: "{{vsts_agent_user}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
- name: create "{{ vsts_agent_user }}" user for running the app | ||
user: | ||
name: "{{ vsts_agent_user }}" | ||
groups: admin | ||
|
||
- name: Create directories | ||
file: | ||
state: directory | ||
path: "{{item}}" | ||
owner: "{{vsts_agent_user}}" | ||
group: "{{vsts_agent_user}}" | ||
mode: 0755 | ||
with_items: | ||
- "{{vsts_agentfolder}}" | ||
- "{{vsts_workfolder}}" | ||
|
||
- name: Fetch latest downloadurl if variable vsts_server_url is not defined | ||
shell: "curl -s https://api.github.com/repos/Microsoft/vsts-agent/releases/latest | jq -r .assets[].browser_download_url | grep rhel" | ||
delegate_to: localhost | ||
register: githubapi_downloadurl_output | ||
when: vsts_agent_fullurl is not defined | ||
|
||
- name: Register githubapi_downloadurl_output as fact in variable vsts_agent_fullurl | ||
set_fact: | ||
vsts_agent_fullurl: "{{ githubapi_downloadurl_output.stdout_lines[0] }}" | ||
when: vsts_agent_fullurl is not defined | ||
|
||
- name: Download and unarchive | ||
unarchive: | ||
src: "{{vsts_agent_fullurl}}" | ||
dest: "{{vsts_agentfolder}}" | ||
remote_src: yes | ||
owner: "{{vsts_agent_user}}" | ||
group: "{{vsts_agent_user}}" | ||
creates: "{{vsts_agentfolder}}/config.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
- name: Install required software for vsts-agent | ||
apt: | ||
name: "{{ item }}" | ||
state: present | ||
with_items: | ||
- python-pip | ||
- python-pexpect | ||
- libcurl4-gnutls-dev | ||
become: true | ||
|
||
- name: Pip install pexpect (we need a new-enough version that isn't packaged in ubuntu and debian | ||
pip: | ||
name: "{{ item }}" | ||
state: present | ||
with_items: | ||
- pexpect | ||
|
||
- name: Installation dependencies | ||
command: "./bin/installdependencies.sh" | ||
args: | ||
chdir: "{{ vsts_agentfolder }}" | ||
creates: "/etc/systemd/system/vsts.agent.{{ vsts_accountname }}.{{ vsts_agent_name }}.service" | ||
become: true | ||
when: dryrun is not defined | ||
|
||
- name: Include configure vsts-agent tasks | ||
include_tasks: configure_vsts_agent.yml | ||
when: dryrun is not defined | ||
|
||
- name: Initial installation of systemd service files and generation of runsvc.sh | ||
command: "./svc.sh install {{ vsts_agent_user }}" | ||
args: | ||
chdir: "{{ vsts_agentfolder }}" | ||
creates: "/etc/systemd/system/vsts.agent.{{ vsts_accountname }}.{{ vsts_agent_name }}.service" | ||
become: true | ||
when: dryrun is not defined | ||
|
||
- name: Enable and start vsts-agent service | ||
service: | ||
name: "vsts.agent.{{ vsts_accountname }}.{{ vsts_agent_name }}" | ||
enabled: yes | ||
state: started | ||
become: true | ||
when: dryrun is not defined | ||
tags: | ||
- service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
- name: Check if vsts agent service already installed | ||
stat: path="/etc/systemd/system/vsts.agent.{{ vsts_accountname }}.{{ vsts_agent_name }}.service" | ||
register: vsts_service_result | ||
failed_when: vsts_service_result is not defined | ||
ignore_errors: yes | ||
|
||
- name: Include uninstall agent tasks | ||
include_tasks: uninstall_vsts_agent.yml | ||
when: | ||
- vsts_service_result.stat.exists | ||
- vsts_remove or vsts_reinstall | ||
|
||
- name: Include get agent files tasks | ||
include_tasks: get_agent_files.yml | ||
when: | ||
- not vsts_service_result.stat.exists or vsts_reinstall | ||
- not vsts_remove | ||
|
||
- name: Include install agent tasks | ||
include_tasks: install_vsts_agent.yml | ||
when: | ||
- not vsts_service_result.stat.exists or vsts_reinstall | ||
- not vsts_remove |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
- name: Unconfigure vsts-agent - remove service | ||
command: "./svc.sh uninstall" | ||
args: | ||
chdir: "{{vsts_agentfolder}}" | ||
removes: "/etc/systemd/system/vsts.agent.{{ vsts_accountname }}.{{ vsts_agent_name }}.service" | ||
when: vsts_remove|bool | ||
become: true | ||
tags: | ||
- service | ||
- unconfig | ||
|
||
- name: Unconfigure vsts-agent | ||
command: "./config.sh remove --unattended --auth PAT --token {{vsts_accesstoken}}" | ||
args: | ||
chdir: "{{vsts_agentfolder}}" | ||
become_user: "{{vsts_agent_user}}" | ||
when: vsts_remove|bool | ||
tags: | ||
- unconfig | ||
|
||
# - name: remove "{{ vsts_agent_user }}" user for running the app | ||
# user: | ||
# name: "{{ vsts_agent_user }}" | ||
# state: absent | ||
# remove: yes | ||
|
||
# - name: delete directories | ||
# file: | ||
# state: absent | ||
# path: "{{item}}" | ||
# with_items: | ||
# - "{{vsts_agentfolder}}" | ||
# - "{{vsts_workfolder}}" |
Oops, something went wrong.