imfreedom/teamcity-ansible
Remove the secrets and add basically everything else
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore Thu Oct 31 05:07:51 2019 -0500
@@ -0,0 +1,3 @@
--- a/agent.yml Thu Oct 31 02:08:01 2019 -0500
+++ b/agent.yml Thu Oct 31 05:07:51 2019 -0500
@@ -1,11 +1,13 @@
convey_sha256_checksum: c5f1d5c7d5da5ec61d325659e77e74a205f62929f2abca82b949c22164f2e5b6
+ teamcity_server: https://ci.imfreedom.org/ --- a/roles/convey/tasks/main.yml Thu Oct 31 02:08:01 2019 -0500
+++ b/roles/convey/tasks/main.yml Thu Oct 31 05:07:51 2019 -0500
@@ -18,7 +18,7 @@
convey_install_dir: "/usr/local/bin"
+- name: "download {{convey_url}}" dest: "{{convey_install_dir}}/convey"
--- a/roles/docker/tasks/main.yml Thu Oct 31 02:08:01 2019 -0500
+++ b/roles/docker/tasks/main.yml Thu Oct 31 05:07:51 2019 -0500
@@ -1,5 +1,5 @@
-- name: Install Dependencies
+- name: install dependencies @@ -8,14 +8,14 @@
when: ansible_facts['os_family'] == "Debian"
-- name: Add Docker apt-key
url: https://download.docker.com/linux/ubuntu/gpg
id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
when: ansible_facts['os_family'] == "Debian"
-- name: Add Docker repository
repo: "deb [arch=amd64] https://download.docker.com/linux/debian buster stable"
@@ -23,7 +23,7 @@
when: ansible_facts['os_family'] == "Debian"
-- name: Install Docker (Debian)
+- name: install (Debian) @@ -31,7 +31,7 @@
when: ansible_facts['os_family'] == "Debian"
-- name: Install Docker (Darwin)
+- name: install (Darwin) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/git/tasks/main.yml Thu Oct 31 05:07:51 2019 -0500
@@ -0,0 +1,9 @@
+- name: install (Debian) + when: ansible_facts['os_family'] == "Debian" --- a/roles/mercurial/tasks/main.yml Thu Oct 31 02:08:01 2019 -0500
+++ b/roles/mercurial/tasks/main.yml Thu Oct 31 05:07:51 2019 -0500
@@ -1,5 +1,5 @@
-- name: Install Dependencies
+- name: install dependencies @@ -11,7 +11,7 @@
when: ansible_facts['os_family'] == "Debian"
-- name: remove mercurial package
@@ -22,7 +22,7 @@
when: ansible_facts['os_family'] == "Debian"
-- name: install mercurial and evolve
+- name: install mercurial and evolve from pypi --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/openjdk/tasks/main.yml Thu Oct 31 05:07:51 2019 -0500
@@ -0,0 +1,9 @@
+- name: install (Debian) + - openjdk-11-jre-headless + when: ansible_facts['os_family'] == "Debian" --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/teamcity/defaults/main.yml Thu Oct 31 05:07:51 2019 -0500
@@ -0,0 +1,8 @@
+teamcity_group: teamcity +teamcity_home: /var/lib/teamcity/ +teamcity_properties: ["system.convey=True"] +teamcity_authorization_token: --- a/roles/teamcity/tasks/main.yml Thu Oct 31 02:08:01 2019 -0500
+++ b/roles/teamcity/tasks/main.yml Thu Oct 31 05:07:51 2019 -0500
@@ -1,10 +1,116 @@
-- name: precondition: teamcity server
+- name: precondition - teamcity server fail: msg="ERROR - required variable 'teamcity_server' missing"
when: teamcity_server is not defined
-- name: set internal var for buildAgent.zip
+- name: set internal var for buildAgent.zip url + teamcity_build_agent_zip_url: "{{teamcity_server}}update/buildAgent.zip" +- name: set internal var for teamcity_agent_home + teamcity_agent_home: "{{teamcity_home}}tc/" +- name: "create group: {{teamcity_group}}" + name: "{{teamcity_group}}" +- name: "create user: {{teamcity_user}}" + name: "{{teamcity_user}}" + group: "{{teamcity_group}}" + groups: "{{teamcity_groups}}" + home: "{{teamcity_home}}" +- name: "create directory {{teamcity_agent_home}}" + name: "{{teamcity_agent_home}}" + owner: "{{teamcity_user}}" + group: "{{teamcity_group}}" +- name: download and extract buildAgent.zip + src: "{{teamcity_build_agent_zip_url}}" + dest: "{{teamcity_agent_home}}" + owner: "{{teamcity_user}}" + group: "{{teamcity_group}}" +- name: check for agent configuration + path: "{{teamcity_agent_home}}conf/buildAgent.properties" + register: build_agent_properties +- name: save authorizationToken + shell: "grep authorizationToken= {{teamcity_agent_home}}conf/buildAgent.properties | cut -d= -f2-" + register: _build_agent_token + when: build_agent_properties.stat.exists +- name: set authorization token - teamcity_build_agent_zip: "{{teamcity_server}}update/buildAgent.zip"
+ teamcity_authorization_token: "{{_build_agent_token.stdout}}" + when: _build_agent_token.changed + dest: "{{teamcity_agent_home}}conf/buildAgent.properties" + serverUrl={{teamcity_server}} + name={{ansible_hostname}} + authorizationToken={{teamcity_authorization_token}} + {% for item in teamcity_properties %}{{item}} + owner: "{{teamcity_user}}" + group: "{{teamcity_group}}" +- name: check for systemd unit + path: /etc/systemd/system/teamcity-agent.service + when: systemd_unit.stat.exists +- name: install systemd unit + dest: /etc/systemd/system/teamcity-agent.service + Description=TeamCity Build Agent + Group={{teamcity_group}} + ExecStart={{teamcity_agent_home}}bin/agent.sh start + ExecStop={{teamcity_agent_home}}bin/agent.sh stop + SuccessExitStatus=0 143 + WantedBy=multi-user.target + when: ansible_system == "Linux" --- a/run Thu Oct 31 02:08:01 2019 -0500
+++ b/run Thu Oct 31 05:07:51 2019 -0500
@@ -1,5 +1,13 @@
-ansible-playbook -b agent.yml -i hosts --vault-password-file=secrets/ansible_vault_password.txt $@
+if [ "${#}" -lt 1 ]; then + echo "You must specify an inventory file to use" +ansible-playbook -b agent.yml -i "${INVENTORY}" $@