Git initial commit

This commit is contained in:
Lars Hahn 2023-08-20 11:13:25 +02:00
commit 394422ff7d
8 changed files with 158 additions and 0 deletions

9
LICENSE Executable file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

3
README.md Executable file
View File

@ -0,0 +1,3 @@
# cloud-gocd-agent
Ansible role to provide an GoCD agent for an existing GoCD server; does not necessarly have to on the GoCD server node.

23
defaults/main.yml Executable file
View File

@ -0,0 +1,23 @@
---
cloud_apps: /opt
cloud_storage: /opt/storage
cloud_stage: prod
cloud_update: false
domain_external: "my-domain.tld"
java_home: "{{ cloud_apps }}/java_jdk/java"
www_group: www-data
gocd_version: 22.1.0
gocd_build: 13913
gocd_source: "https://download.gocd.org/binaries/{{ gocd_version }}-{{ gocd_build }}/generic"
gocd_agent_file: "go-agent-{{ gocd_version }}-{{ gocd_build }}.zip"
gocd_java_home: "{{ java_home }}"
gocd_agent_java_xmx: 1024m
gocd_agent_java_xms: 128m
gocd_server: "https://gocd.{{ domain_external }}/go"

5
handlers/main.yml Executable file
View File

@ -0,0 +1,5 @@
---
- name: restart gocd-agent
systemd:
name: gocd-agent
state: restarted

17
meta/main.yml Executable file
View File

@ -0,0 +1,17 @@
---
galaxy_info:
role_name: gocd-agent
namespace: hahn-cloud
author: Lars Hahn
company: OpenDevChain
license: MIT
description: Role to setup GoCD agent for an GoCD CI/CD server
min_ansible_version: 2.7
platforms:
- name: Debian
versions:
- 11
galaxy_tags:
- gocd-agent
dependencies:
- java

79
tasks/main.yml Executable file
View File

@ -0,0 +1,79 @@
---
- name: install GoCD recommendations
apt:
update_cache: yes
state: "{% if cloud_update | bool %}latest{% else %}present{% endif %}"
install_recommends: yes
pkg:
- "unzip"
- name: setup GoCD group
group:
name: "{{ gocd_usr }}"
state: "present"
- name: setup Gocd user
user:
name: "{{ gocd_usr }}"
group: "{{ gocd_grp }}"
groups:
- "{{ gocd_grp }}"
comment: Virtual GocD User
shell: /sbin/nologin
state: present
system: yes
- name: setup GoCD directories
file:
state: directory
path: "{{ item }}"
owner: "{{ gocd_usr }}"
group: "{{ gocd_grp }}"
mode: 0750
loop:
- "{{ gocd_main }}"
- name: download GoCD Agent and unarchive
unarchive:
src: "{{ gocd_source }}/{{ gocd_agent_file }}"
dest: "{{ gocd_main }}"
remote_src: yes
owner: "{{ gocd_usr }}"
group: "{{ gocd_grp }}"
mode: "o="
creates: "{{ gocd_inst }}"
register: gocd_installation
- name: configure GoCD wrapper properties
lineinfile:
path: "{{ gocd_inst }}/wrapper-config/wrapper-properties.conf"
regexp: "^(#\\s*|){{ item.key }}="
line: "{{ item.key }}={{item.value}}"
loop:
- key: wrapper.java.command
value: "{{ gocd_java_home }}/bin/java"
- key: wrapper.app.parameter.101
value: "{{ gocd_server }}"
- key: set.AGENT_STARTUP_ARGS
value: "-Xms{{ gocd_agent_java_xmx }} -Xmx{{ gocd_agent_java_xmx }}"
- name: link installation dir
file:
state: link
src: "{{ gocd_inst }}"
dest: "{{ gocd_link }}"
owner: "{{ gocd_usr }}"
group: "{{ gocd_grp }}"
- name: setup GoCD agent systemd unit
template:
src: etc/systemd/system/gocd-agent.service.j2
dest: /etc/systemd/system/gocd-agent.service
notify: restart gocd-agent
- name: enable GoCD agent systemd unit
systemd:
name: gocd-agent
enabled: yes
daemon_reload: yes
state: started

View File

@ -0,0 +1,15 @@
[Unit]
Description=go-agent
After=syslog.target
[Service]
Type=forking
ExecStart={{ gocd_link }}/bin/go-agent start sysd
ExecStop={{ gocd_link }}/bin/go-agent stop sysd
User={{ gocd_usr }}
Group={{ gocd_grp }}
KillMode=control-group
Environment=SYSTEMD_KILLMODE_WARNING=true
[Install]
WantedBy=multi-user.target

7
vars/main.yml Executable file
View File

@ -0,0 +1,7 @@
---
gocd_main: "{{ cloud_apps }}/gocd-agent"
gocd_inst: "{{ gocd_main }}/go-agent-{{ gocd_version }}"
gocd_link: "{{ gocd_main }}/inst"
gocd_usr: gocd
gocd_grp: "{{ gocd_usr }}"