remove!(gitlab_runner): unused
This commit is contained in:
parent
aa576bf5bc
commit
e33018f745
7 changed files with 0 additions and 453 deletions
|
@ -1,32 +0,0 @@
|
|||
---
|
||||
# Infrastructure
|
||||
# Ansible instructions to deploy the infrastructure
|
||||
# Copyright (C) 2019-2020 Christoph (Sheogorath) Kern
|
||||
# Copyright (C) 2020 Saibotk
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
- name: Install & configure GitLab Runner
|
||||
hosts: gitlab_runner
|
||||
roles:
|
||||
- docker
|
||||
- docker_cleanup
|
||||
- gitlab_runner
|
||||
tasks:
|
||||
- name: Install docker image prune crontab
|
||||
ansible.builtin.cron:
|
||||
name: "Prune unused docker images"
|
||||
minute: "0"
|
||||
hour: "*/4"
|
||||
job: "docker image prune -f"
|
||||
become: true
|
|
@ -1,87 +0,0 @@
|
|||
gitlab_runner
|
||||
=========
|
||||
|
||||
This will set up a [gitlab-runner](https://docs.gitlab.com/runner/) instance via Docker, that is used to run CI jobs from a GitLab instance.
|
||||
Multiple different runners can be created and configured for this runner instance.
|
||||
|
||||
**NOTE: Currently this will only allow to configure a docker, shell & docker+machine runner.**
|
||||
|
||||
**NOTE2: When deploying docker-machines with the privileged flag enabled, only use this in a trusted environment or set max builds to 1 to prevent malicious actions affecting other builds.**
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
You will need to have docker and docker-compose installed or declared as dependencies with their respective roles.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
**Please look at the [defaults/main.yml](defaults/main.yml) for all available variables and their description.**
|
||||
|
||||
**Note: Lines that are commented out via `#` are usually still valid/used variables, but they are not defined by default, so they might enable a feature, when uncommenting/defining them!**
|
||||
|
||||
### Example autoscaling Hetzner-Runner configuration:
|
||||
```yaml
|
||||
# This image has the hetzner plugin pre-installed
|
||||
gitlabrunner_image: "quay.io/shivering-isles/gitlab-hetzner-runner"
|
||||
gitlabrunner_image_version: 13.6.0
|
||||
|
||||
# Extra paths that should be created (eg. to be mounted in the container)
|
||||
gitlabrunner_extra_paths:
|
||||
- "{{ gitlabrunner_install_location }}/hetzner_machine"
|
||||
|
||||
gitlabrunner_runners:
|
||||
# The URL of the instance that this runner should be associated with
|
||||
- gitlab_url: https://gitlab.example.com
|
||||
|
||||
# The token that you received when registering the runner (not the register token!!!)
|
||||
# Register a runner first to obtain a token: https://docs.gitlab.com/runner/register/index.html#docker
|
||||
# Can be done via the API and the registration token: eg. `curl --request POST "https://gitlab.example.com/api/v4/runners" --form "token=<registration_token>"`
|
||||
gitlab_token: "ENTER_YOUR_TOKEN_HERE"
|
||||
|
||||
# Adjust the name of the runner
|
||||
name: "hetzner-docker-auto-scale"
|
||||
|
||||
# Set the docker executor
|
||||
executor: "docker+machine"
|
||||
|
||||
# Should the docker runner start containers as privileged? (eg. needed for docker in docker / building with docker etc)
|
||||
docker_privileged: true
|
||||
# Should the docker socket be mounted into the containers? (SECURITY NOTE: This is critical, as it is effectively the same as root!)
|
||||
docker_mount_socket: true
|
||||
|
||||
# The docker-machine driver that should be used (the server provider)
|
||||
machine_driver: "hetzner"
|
||||
# The template for naming new machines
|
||||
machine_name: "machine-%s-gitlab-runner"
|
||||
# The maximum amount of builds on a machine (VM) before a new one will be used
|
||||
machine_max_builds: 20
|
||||
# Time (in seconds) for machine to be in Idle state before it is removed.
|
||||
machine_idle_time: 1800
|
||||
# Number of machines, that need to be created and are waiting in Idle state.
|
||||
machine_idle_count: 0
|
||||
|
||||
# The "MachineOptions" field with parameters that depend on the driver (these usually provide the api token, which machine type is used etc...)
|
||||
machine_options:
|
||||
hetzner-api-token: "REPLACE_WITH_YOUR_API_TOKEN" # The Hetzner specific API token
|
||||
hetzner-image: "debian-10" # The image that should be used for new machines
|
||||
hetzner-server-type: "cx11" # The server type (the hardware configuration) to use for a new machine
|
||||
hetzner-server-location: "fsn1" # The server location to use for a new machine
|
||||
engine-install-url: "https://releases.rancher.com/install-docker/19.03.9.sh" # Workaround until 20.10 gets an update https://github.com/JonasProgrammer/docker-machine-driver-hetzner/issues/54
|
||||
|
||||
# Extra volumes that should be added to the gitlab runner container.
|
||||
gitlabrunner_extra_volumes:
|
||||
- "./hetzner_machine:/root/.docker/machine"
|
||||
|
||||
```
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
- docker
|
||||
- docker-compose
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
GPL-3.0-only
|
|
@ -1,109 +0,0 @@
|
|||
---
|
||||
# Default variables for the gitlab_runner role
|
||||
|
||||
# Infrastructure
|
||||
# Ansible instructions to deploy the infrastructure
|
||||
# Copyright (C) 2020 Saibotk
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Install location settings
|
||||
gitlab_runner_install_location: "/srv/gitlab-runner"
|
||||
gitlab_runner_config_location: "{{ gitlab_runner_install_location }}/config"
|
||||
|
||||
# The runner image & tag/version to be used
|
||||
gitlab_runner_image: "docker.io/gitlab/gitlab-runner"
|
||||
# renovate: depName=docker.io/gitlab/gitlab-runner
|
||||
gitlab_runner_image_version: "v17.5.3"
|
||||
gitlab_runner_image_variant: "alpine-{{ gitlab_runner_image_version }}"
|
||||
|
||||
# Extra paths that should be created (eg. to be mounted in the container)
|
||||
gitlab_runner_extra_paths: []
|
||||
|
||||
# Enable or disable selinux handling
|
||||
gitlab_runner_selinux_enabled: true
|
||||
|
||||
# Should the docker socket be mounted to the gitlab runner (usually needed for the docker executor)
|
||||
gitlab_runner_mount_docker_socket: false
|
||||
|
||||
# Extra volumes that should be added to the gitlab runner container.
|
||||
gitlab_runner_extra_volumes: []
|
||||
|
||||
# The maximum overall concurrent running jobs. This is the most upper limit of number of jobs using all defined runners, local and autoscale.
|
||||
gitlab_runner_concurrent: 1
|
||||
|
||||
# The interval in seconds, to check for available jobs. (0 means default value is used.
|
||||
# See https://docs.gitlab.com/runner/configuration/advanced-configuration.html#how-check_interval-works)
|
||||
gitlab_runner_check_interval: 0
|
||||
|
||||
# This is used to define all the runners, that may be served by this gitlab-runner
|
||||
# !! YOU WILL NEED TO ADJUST THIS! BELOW IS A FULL EXAMPLE!
|
||||
gitlab_runner_runners:
|
||||
# The URL of the instance that this runner should be associated with
|
||||
- gitlab_url: https://gitlab.example.com
|
||||
|
||||
# The token that you received when registering the runner (not the register token!!!)
|
||||
# Register a runner first to obtain a token: https://docs.gitlab.com/runner/register/index.html#docker
|
||||
# Can be done via the API and the registration token:
|
||||
# curl --request POST "https://gitlab.example.com/api/v4/runners" --form "token=<registration_token>"
|
||||
gitlab_token:
|
||||
|
||||
# The name of the runner
|
||||
name: "docker-runner"
|
||||
|
||||
# The limit of machines created by the runner and with that also the limit of jobs that can be handled concurrently by this specific runner.
|
||||
limit: 1
|
||||
|
||||
# The executor that is used for this runner.
|
||||
# Eg. "docker", "shell", "docker+machine"
|
||||
executor: "docker"
|
||||
|
||||
# Should the docker runner start containers as privileged? (eg. needed for docker in docker / building with docker etc)
|
||||
docker_privileged: false
|
||||
# Should the docker socket be mounted into the containers? (SECURITY NOTE: This is critical, as it is effectively the same as root!)
|
||||
docker_mount_socket: false
|
||||
# The image that should be used for jobs by default
|
||||
docker_image: "docker.io/library/docker:stable"
|
||||
|
||||
# The docker-machine driver that should be used (the server provider)
|
||||
machine_driver: "hetzner"
|
||||
# The template for naming new machines
|
||||
machine_name: "machine-%s-gitlab-runner"
|
||||
# The maximum amount of builds on a machine (VM) before a new one will be used
|
||||
machine_max_builds: 20
|
||||
# Time (in seconds) for machine to be in Idle state before it is removed.
|
||||
machine_idle_time: 1800
|
||||
# Number of machines, that need to be created and are waiting in Idle state.
|
||||
machine_idle_count: 0
|
||||
|
||||
# The "MachineOptions" field with parameters that depend on the driver (these usually provide the api token, which machine type is used etc...)
|
||||
# This for example are parameters for the Hetzner driver (but remember, that this will need the hetzner docker-machine plugin)
|
||||
# The options can also be omitted if you do not need any.
|
||||
machine_options:
|
||||
# The Hetzner specific API token
|
||||
hetzner-api-token: "TOKENHERE"
|
||||
# The image that should be used for new machines
|
||||
hetzner-image: "debian-10"
|
||||
# The server type (the hardware configuration) to use for a new machine
|
||||
hetzner-server-type: "cx11"
|
||||
# The server location to use for a new machine
|
||||
hetzner-server-location: "fsn1"
|
||||
|
||||
# S3 Runner cache configuration to improve performance between runs
|
||||
# (see https://docs.gitlab.com/runner/configuration/autoscale.html#distributed-runners-caching)
|
||||
# The options can also be omitted if you do not want to configure a cache
|
||||
cache_s3:
|
||||
server: s3.example.com
|
||||
access_key: ""
|
||||
secret_key: ""
|
||||
bucket: "runner"
|
|
@ -1,43 +0,0 @@
|
|||
galaxy_info:
|
||||
author: saibotk
|
||||
description: "Deploys a gitlab-runner using Docker."
|
||||
license: GPL-3.0-only
|
||||
min_ansible_version: "2.9"
|
||||
standalone: true
|
||||
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- all
|
||||
- name: GenericUNIX
|
||||
versions:
|
||||
- all
|
||||
- name: Fedora
|
||||
versions:
|
||||
- all
|
||||
- name: opensuse
|
||||
versions:
|
||||
- all
|
||||
- name: GenericBSD
|
||||
versions:
|
||||
- all
|
||||
- name: FreeBSD
|
||||
versions:
|
||||
- all
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- all
|
||||
- name: SLES
|
||||
versions:
|
||||
- all
|
||||
- name: GenericLinux
|
||||
versions:
|
||||
- all
|
||||
- name: Debian
|
||||
versions:
|
||||
- all
|
||||
|
||||
galaxy_tags: []
|
||||
|
||||
dependencies:
|
||||
- role: docker
|
|
@ -1,86 +0,0 @@
|
|||
---
|
||||
# Tasks file for the gitlab_runner role
|
||||
|
||||
# Infrastructure
|
||||
# Ansible instructions to deploy the infrastructure
|
||||
# Copyright (C) 2019-2020 Christoph (Sheogorath) Kern
|
||||
# Copyright (C) 2020 Alexander Wellbrock
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
- name: Update default SELinux contexts
|
||||
community.general.sefcontext:
|
||||
target: "{{ item }}(/.*)?"
|
||||
setype: "container_file_t"
|
||||
state: present
|
||||
with_items:
|
||||
- "{{ gitlab_runner_config_location }}"
|
||||
- "{{ gitlab_runner_extra_paths }}"
|
||||
when:
|
||||
- gitlab_runner_selinux_enabled
|
||||
become: true
|
||||
|
||||
- name: Create install directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: "0700"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
with_items:
|
||||
- "{{ gitlab_runner_install_location }}"
|
||||
become: true
|
||||
|
||||
- name: Create config directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: "0700"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
setype: "container_file_t"
|
||||
with_items:
|
||||
- "{{ gitlab_runner_config_location }}"
|
||||
- "{{ gitlab_runner_extra_paths }}"
|
||||
become: true
|
||||
|
||||
- name: Deploy docker-compose.yml
|
||||
ansible.builtin.template:
|
||||
src: docker-compose.yml
|
||||
dest: "{{ gitlab_runner_install_location }}/docker-compose.yml"
|
||||
mode: "0600"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
validate: docker compose -f %s config -q
|
||||
tags:
|
||||
- docker
|
||||
become: true
|
||||
|
||||
- name: Deploy config.toml for gitlab-runner
|
||||
ansible.builtin.template:
|
||||
src: config.toml
|
||||
dest: "{{ gitlab_runner_config_location }}/config.toml"
|
||||
mode: "0600"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
become: true
|
||||
|
||||
- name: Compose gitlab-runner
|
||||
community.docker.docker_compose_v2:
|
||||
state: present
|
||||
project_src: "{{ gitlab_runner_install_location }}"
|
||||
pull: always
|
||||
remove_orphans: true
|
||||
tags:
|
||||
- gitlab-runner
|
||||
become: true
|
|
@ -1,63 +0,0 @@
|
|||
# Infrastructure
|
||||
# Ansible instructions to deploy the infrastructure
|
||||
# Copyright (C) 2019-2020 Christoph (Sheogorath) Kern
|
||||
# Copyright (C) 2020 Saibotk
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
concurrent = {{ gitlab_runner_concurrent }}
|
||||
check_interval = {{ gitlab_runner_check_interval }}
|
||||
|
||||
{% for gitlabrunner in gitlab_runner_runners %}
|
||||
[[runners]]
|
||||
name = "{{ gitlabrunner.name }}"
|
||||
limit = {{ gitlabrunner.limit | default(1) }}
|
||||
url = "{{ gitlabrunner.gitlab_url }}"
|
||||
token = "{{ gitlabrunner.gitlab_token }}"
|
||||
executor = "{{ gitlabrunner.executor }}"
|
||||
{% if gitlabrunner.executor == "docker" or gitlabrunner.executor == "docker+machine" %}
|
||||
[runners.docker]
|
||||
image = "{{ gitlabrunner.docker_image | default("docker.io/library/docker:stable") }}"
|
||||
privileged = {{ gitlabrunner.docker_privileged | bool | lower }}
|
||||
volumes = [
|
||||
"/cache",
|
||||
{% if gitlabrunner.docker_mount_socket %}
|
||||
"/var/run/docker.sock:/var/run/docker.sock"
|
||||
{% endif %}
|
||||
]
|
||||
{% endif %}
|
||||
{% if gitlabrunner.executor == "docker+machine" %}
|
||||
[runners.machine]
|
||||
IdleCount = {{ gitlabrunner.machine_idle_count }}
|
||||
IdleTime = {{ gitlabrunner.machine_idle_time }}
|
||||
MaxBuilds = {{ gitlabrunner.machine_max_builds }}
|
||||
MachineDriver = "{{ gitlabrunner.machine_driver }}"
|
||||
MachineName = "{{ gitlabrunner.machine_name }}"
|
||||
MachineOptions = [
|
||||
{% for key, value in gitlabrunner.machine_options.items() %}
|
||||
"{{ key }}={{ value }}",
|
||||
{% endfor %}
|
||||
]
|
||||
{% endif %}
|
||||
[runners.cache]
|
||||
{% if gitlabrunner.cache_s3 is defined %}
|
||||
Type = "s3"
|
||||
Shared = false
|
||||
[runners.cache.s3]
|
||||
ServerAddress = "{{ gitlabrunner.cache_s3.server }}"
|
||||
AccessKey = "{{ gitlabrunner.cache_s3.access_key }}"
|
||||
SecretKey = "{{ gitlabrunner.cache_s3.secret_key }}"
|
||||
BucketName = "{{ gitlabrunner.cache_s3.bucket }}"
|
||||
Insecure = false
|
||||
{% endif %}
|
||||
{% endfor %}
|
|
@ -1,33 +0,0 @@
|
|||
{{ ansible_managed | comment }}
|
||||
|
||||
# Infrastructure
|
||||
# Ansible instructions to deploy the infrastructure
|
||||
# Copyright (C) 2019-2020 Christoph (Sheogorath) Kern
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
version: '2'
|
||||
services:
|
||||
runner:
|
||||
image: {{ gitlab_runner_image }}:{{ gitlab_runner_image_variant }}
|
||||
mem_limit: 128mb
|
||||
memswap_limit: 256mb
|
||||
volumes:
|
||||
- "{{ gitlab_runner_config_location }}:/etc/gitlab-runner"
|
||||
{% if gitlab_runner_mount_docker_socket %}
|
||||
- "/var/run/docker.sock:/var/run/docker.sock"
|
||||
{% endif %}
|
||||
{% for item in gitlab_runner_extra_volumes %}
|
||||
- "{{item}}"
|
||||
{% endfor %}
|
||||
restart: always
|
Loading…
Add table
Reference in a new issue