Rolle entfernt: gitlab runner (#468)

Co-authored-by: Michael Grote <michael.grote@posteo.de>
Reviewed-on: #468
This commit is contained in:
Michael Grote 2023-02-17 11:47:28 +01:00
parent d8b81f90cf
commit 8d4acdeda6
46 changed files with 0 additions and 2856 deletions

View file

@ -1 +0,0 @@
ansible.cfg

View file

@ -1,64 +0,0 @@
---
jobs:
include:
- os: linux
dist: focal
python: "3.8"
language: python
addons:
apt:
packages:
- python3-pip
install:
# Install ansible
- sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
- echo $PATH
- pip3 install ansible flask
# Check ansible version
- ansible --version
# Create ansible.cfg with correct roles_path
#- printf '[defaults]\nroles_path=../' > ansible.cfg
- "{ echo '[defaults]'; echo 'roles_path = ../'; } > ansible.cfg"
script:
# Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
# Running tests
- ansible-playbook tests/test.yml -i tests/inventory
after_failure:
- touch ~/mock_ci.pid && cat ~/mock_ci.pid
- touch ~/mock_ci.log && cat ~/mock_ci.log
- os: osx
osx_image: xcode10.3
# See https://github.com/travis-ci/travis-ci/issues/2312#issuecomment-422830059
#language: python
language: generic
install:
# Install ansible
- pip install ansible flask
# Check ansible version
- ansible --version
# Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' > ansible.cfg
script:
# Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
# Running tests
- ansible-playbook tests/test.yml -i tests/inventory
after_failure:
- touch ~/mock_ci.pid && cat ~/mock_ci.pid
- touch ~/mock_ci.log && cat ~/mock_ci.log
- os: windows
language: shell
install:
- powershell -ExecutionPolicy ByPass -File tests/travis-bootstrap-ansible.ps1
- wsl ansible --version
script:
- wsl mkdir -p tests/roles/ansible-gitlab-runner/
- cd tests/roles/ansible-gitlab-runner/
- wsl ln -s ../../../* .
- cd ../../
- wsl ansible-playbook test.yml -i inventory --syntax-check
# Running tests
- wsl ansible-playbook test.yml -i inventory --extra-vars 'ansible_user=ansible ansible_password=Ans1ble_User! ansible_connection=winrm ansible_winrm_server_cert_validation=ignore ansible_ssh_port=5986'
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View file

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2016 Harold Barker
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.

View file

@ -1,165 +0,0 @@
GitLab Runner [![Build Status](https://api.travis-ci.org/riemers/ansible-gitlab-runner.svg?branch=master)](https://travis-ci.org/riemers/ansible-gitlab-runner) [![Ansible Role](https://img.shields.io/badge/role-riemers.gitlab--runner-blue.svg?maxAge=2592000)](https://galaxy.ansible.com/riemers/gitlab-runner/)
=============
This role will install the [official GitLab Runner](https://gitlab.com/gitlab-org/gitlab-runner)
(fork from haroldb) with updates. Needed something simple and working, this did the trick for me. Open for changes though.
Requirements
------------
This role requires Ansible 2.7 or higher.
Role Variables
--------------
- `gitlab_runner_package_name` - **Since Gitlab 10.x** The package name of `gitlab-ci-multi-runner` has been renamed to `gitlab-runner`. In order to install a version < 10.x you will need to define this variable `gitlab_runner_package_name: gitlab-ci-multi-runner`.
- `gitlab_runner_wanted_version` or `gitlab_runner_package_version` - To install a specific version of the gitlab runner (by default it installs the latest).
On Mac OSX and Windows, use e.g. `gitlab_runner_wanted_version: 12.4.1`.
On Linux, use `gitlab_runner_package_version` instead.
- `gitlab_runner_concurrent` - The maximum number of global jobs to run concurrently. Defaults to the number of processor cores.
- `gitlab_runner_registration_token` - The GitLab registration token. If this is specified, a runner will be registered to a GitLab server.
- `gitlab_runner_coordinator_url` - The GitLab coordinator URL. Defaults to `https://gitlab.com`.
- `gitlab_runner_sentry_dsn` - Enable tracking of all system level errors to Sentry
- `gitlab_runner_listen_address` - Enable `/metrics` endpoint for Prometheus scraping.
- `gitlab_runner_runners` - A list of gitlab runners to register & configure. Defaults to a single shell executor.
- `gitlab_runner_skip_package_repo_install`- Skip the APT or YUM repository installation (by default, false). You should provide a repository containing the needed packages before running this role.
See the [`defaults/main.yml`](https://github.com/riemers/ansible-gitlab-runner/blob/master/defaults/main.yml) file listing all possible options which you can be passed to a runner registration command.
### Gitlab Runners cache
For each gitlab runner in gitlab_runner_runners you can set cache options. At the moment role support s3 or gcs types.
Example configurration for s3 can be:
```yaml
gitlab_runner_runners:
cache_type: "s3"
cache_path: "cache"
cache_shared: true
cache_s3_server_address: "s3.amazonaws.com"
cache_s3_access_key: "<access_key>"
cache_s3_secret_key: "<secret_key>"
cache_s3_bucket_name: "<bucket_name>
cache_s3_bucket_location: "eu-west-1"
cache_s3_insecure: false
```
## Autoscale Runner Machine vars for AWS (optional)
- `gitlab_runner_machine_options: []` - Foremost you need to pass an array of dedicated vars in the machine_options to configure your scaling runner:
+ `amazonec2-access-key` and `amazonec2-secret-key` the keys of the dedicated IAM user with permission for EC2
+ `amazonec2-zone`
+ `amazonec2-region`
+ `amazonec2-vpc-id`
+ `amazonec2-subnet-id`
+ `amazonec2-use-private-address=true`
+ `amazonec2-security-group`
+ `amazonec2-instance-type`
+ you can also set `amazonec2-tags` to identify you instance more easily via aws-cli or the console.
- `MachineDriver` - which should be set to `amzonec2` when working on AWS
- `MachineName` - Name of the machine. It **must** contain `%s`, which will be replaced with a unique machine identifier.
- `IdleCount` - Number of machines, that need to be created and waiting in Idle state.
- `IdleTime` - Time (in seconds) for machine to be in Idle state before it is removed.
In addition you could set *off peak* settings. This lets you select a regular time periods when no work is done. For example most of commercial companies are working from Monday to Friday in a fixed hours, eg. from 10am to 6pm. In the rest of the week - from Monday to Friday at 12am-9am and 6pm-11pm and whole Saturday and Sunday - no one is working. These time periods were naming here as Off Peak.
- `gitlab_runner_machine_off_peak_periods`
- `gitlab_runner_machine_off_peak_idle_time`
- `gitlab_runner_machine_off_peak_idle_count`
### Read Sources
For details follow these links:
- [gitlab-docs/runner: advanced configuration: runners.machine section](https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersmachine-section)
- [gitlab-docs/runner: autoscale: supported cloud-providers](https://docs.gitlab.com/runner/configuration/autoscale.html#supported-cloud-providers)
- [gitlab-docs/runner: autoscale_aws: runners.machine section](https://docs.gitlab.com/runner/configuration/runner_autoscale_aws/#the-runnersmachine-section)
See the [config for more options](https://github.com/riemers/ansible-gitlab-runner/blob/master/tasks/register-runner.yml)
Example Playbook
----------------
```yaml
- hosts: all
become: true
vars_files:
- vars/main.yml
roles:
- { role: riemers.gitlab-runner }
```
Inside `vars/main.yml`
```yaml
gitlab_runner_coordinator_url: https://gitlab.com
gitlab_runner_registration_token: '12341234'
gitlab_runner_runners:
- name: 'Example Docker GitLab Runner'
# token is an optional override to the global gitlab_runner_registration_token
token: 'abcd'
# url is an optional override to the global gitlab_runner_coordinator_url
url: 'https://my-own-gitlab.mydomain.com'
executor: docker
docker_image: 'alpine'
tags:
- node
- ruby
- mysql
docker_volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "/cache"
extra_configs:
runners.docker:
memory: 512m
allowed_images: ["ruby:*", "python:*", "php:*"]
runners.docker.sysctls:
net.ipv4.ip_forward: "1"
```
## autoscale setup on AWS
how `vars/main.yml` would look like, if you setup an autoscaling GitLab-Runner on AWS:
```yaml
gitlab_runner_registration_token: 'HUzTMgnxk17YV8Rj8ucQ'
gitlab_runner_coordinator_url: 'https://gitlab.com'
gitlab_runner_runners:
- name: 'Example autoscaling GitLab Runner'
state: present
# token is an optional override to the global gitlab_runner_registration_token
token: 'HUzTMgnxk17YV8Rj8ucQ'
executor: 'docker+machine'
# Maximum number of jobs to run concurrently on this specific runner.
# Defaults to 0, simply means don't limit.
concurrent_specific: '0'
docker_image: 'alpine'
# Indicates whether this runner can pick jobs without tags.
run_untagged: true
extra_configs:
runners.machine:
IdleCount: 1
IdleTime: 1800
MaxBuilds: 10
MachineDriver: 'amazonec2'
MachineName: 'git-runner-%s'
MachineOptions: ["amazonec2-access-key={{ lookup('env','AWS_IAM_ACCESS_KEY') }}", "amazonec2-secret-key={{ lookup('env','AWS_IAM_SECRET_KEY') }}", "amazonec2-zone={{ lookup('env','AWS_EC2_ZONE') }}", "amazonec2-region={{ lookup('env','AWS_EC2_REGION') }}", "amazonec2-vpc-id={{ lookup('env','AWS_VPC_ID') }}", "amazonec2-subnet-id={{ lookup('env','AWS_SUBNET_ID') }}", "amazonec2-use-private-address=true", "amazonec2-tags=gitlab-runner", "amazonec2-security-group={{ lookup('env','AWS_EC2_SECURITY_GROUP') }}", "amazonec2-instance-type={{ lookup('env','AWS_EC2_INSTANCE_TYPE') }}"]
```
### NOTE
from https://docs.gitlab.com/runner/executors/docker_machine.html:
>The **first time** youre using Docker Machine, its best to execute **manually** `docker-machine create...` with your chosen driver and **all options from the MachineOptions** section. This will set up the Docker Machine environment properly and will also be a good validation of the specified options. After this, you *can destroy the machine* with `docker-machine rm [machine_name]` and start the Runner.
Example:
`docker-machine create -d amazonec2 --amazonec2-zone=a --amazonec2-region=us-east-1 --amazonec2-vpc-id=vpc-11111111 --amazonec2-subnet-id=subnet-1111111 --amazonec2-use-private-address=true --amazonec2-tags=gitlab-runner --amazonec2-instance-type=t3.medium test
docker-machine rm test
`
Contributors
------------
Feel free to add your name to the readme if you make a PR. A full list of people from the PR's is [here](https://github.com/riemers/ansible-gitlab-runner/pulls?q=is%3Apr+is%3Aclosed)
- Gastrofix for adding Mac Support
- Matthias Schmieder for adding Windows Support
- dniwdeus & rosenstrauch for adding AWS autoscale option

View file

@ -1,161 +0,0 @@
---
# for versions >= 10.x
gitlab_runner_package_name: 'gitlab-runner'
gitlab_runner_system_mode: yes
# gitlab_runner_package_version for version pinning on debian/redhat
# The following are for version pinning on MacOSX
gitlab_runner_wanted_version: latest
# This variable should not be modified usually as it depends on the gitlab_runner_wanted_version variable
gitlab_runner_wanted_tag: "{{ 'latest' if gitlab_runner_wanted_version == 'latest' else ('v' + gitlab_runner_wanted_version) }}"
# Overridden based on platform
gitlab_runner_config_file: "{{ __gitlab_runner_config_file_system_mode if gitlab_runner_system_mode else __gitlab_runner_config_file_user_mode }}"
gitlab_runner_config_file_location: "{{ gitlab_runner_config_file | dirname }}"
gitlab_runner_executable: "{{ gitlab_runner_package_name }}"
# Maximum number of global jobs to run concurrently
gitlab_runner_concurrent: '{{ ansible_processor_vcpus }}'
# GitLab coordinator URL
gitlab_runner_coordinator_url: 'https://gitlab.com'
# GitLab registration token
gitlab_runner_registration_token: ''
gitlab_runner_sentry_dsn: ''
# Prometheus Metrics & Monitoring
gitlab_runner_listen_address: ''
# Skip the APT or YUM repository installation
# You should provide a repository containing the needed packages before running this role.
# Use this if you use a mirror repository
# gitlab_runner_skip_package_repo_install: true
# The credentials for the Windows user used to run the gitlab-runner service.
# Those credentials will be passed to `gitlab-runner.exe install`.
# https://docs.gitlab.com/runner/install/windows.html
gitlab_runner_windows_service_user: ''
gitlab_runner_windows_service_password: ''
# gitlab_runner_container_install
gitlab_runner_container_install: false
# default state to restart
gitlab_runner_restart_state: "restarted"
# A list of runners to register and configure
gitlab_runner_runners:
# The identifier of the runner.
- name: '{{ ansible_hostname }}'
# set to 'absent' if you want to delete the runner. Defaults to 'present'.
state: present
# The executor used by the runner.
executor: 'shell'
# Set maximum build log size in kilobytes.
output_limit: 4096
# Maximum number of jobs to run concurrently on this specific runner.
# Defaults to 0, simply means don't limit.
concurrent_specific: '0'
# The default Docker image to use. Required when executor is `docker`.
docker_image: ''
# The tags assigned to the runner.
tags: []
# Indicates whether this runner can pick jobs without tags.
run_untagged: true
# Docker privileged mode
docker_privileged: false
# Runner Locked. When a runner is locked, it cannot be assigned to other projects
locked: 'false'
# Add container to a custom network
docker_network_mode: bridge
# Custom environment variables injected to build environment
env_vars: []
# Sets the clone_url. The default is not set.
# clone_url:
#
# Sets the pre_clone_script. The default is not set.
# pre_clone_script:
#
# Sets the pre_build_script. The default is not set.
# pre_build_script:
#
# Sets the post_build_script. The default is not set.
# post_build_script:
#
# Runner SSH user
# ssh_user: ''
#
# Runner SSH host
# ssh_host: ''
#
# Runner SSH port
# ssh_port: ''
#
# Runner SSH password
# ssh_password: ''
#
# Runner SSH identity file
# ssh_identity_file: ''
#
# Cache type
# cache_type: 's3|gcs'
#
# Cache path
# cache_path: prefix/key
#
# Cache shared
# cache_shared: false
#
# Cache S3 server address
# cache_s3_server_address: "s3.amazonaws.com"
#
# Cache S3 access key
# cache_s3_access_key: "AMAZON_S3_ACCESS_KEY"
#
# Cache S3 secret key
# cache_s3_secret_key: "AMAZON_S3_SECRET_KEY"
#
# Cache S3 bucket name
# cache_s3_bucket_name: "my-bucket"
#
# Cache S3 bucket location
# cache_s3_bucket_location: "eu-west-1"
#
# Cache S3 insecure
# cache_s3_insecure: false
#
# Cache GCS Bucket name
# cache_gcs_bucket_name: "my-bucket"
#
# Cache GCS CredentialsFile
# cache_gcs_credentials_file: "/path/to/key_file.json"
#
# Cache GCS Access ID
# cache_gcs_access_id: "cache-access-account@project.iam.gserviceaccount.com"
#
# Cache GCS Private Key
# cache_gcs_private_key: "-----BEGIN PRIVATE KEY-----\nXXXXXX\n-----END PRIVATE KEY-----\n"
#
# Builds directory
# builds_dir: '/builds_dir'
#
# Cache directory
# cache_dir: '/cache'
#
# Extra registration option
# extra_registration_option: '--maximum-timeout=3600'
#
# Extra configuration options to change in the config.toml file
# This parameter is a dictionary where the first level keys are TOML section names
# Full list of configuration are available on Gitlab Runner documentation:
# See https://docs.gitlab.com/runner/configuration/advanced-configuration.html
#
# extra_configs:
# runners.docker:
# memory: 512m
# allowed_images: ["ruby:*", "python:*", "php:*"]
# runners.docker.sysctls:
# net.ipv4.ip_forward: "1"

View file

@ -1,25 +0,0 @@
---
# non macOS
- name: restart_gitlab_runner
service: name=gitlab-runner state={{ gitlab_runner_restart_state }}
become: yes
when: ansible_os_family != 'Darwin' and ansible_os_family != 'Windows' and not gitlab_runner_container_install
# macOS
- name: restart_gitlab_runner_macos
command: "{{ gitlab_runner_executable }} restart"
become: "{{ gitlab_runner_system_mode }}"
when: ansible_os_family == 'Darwin'
- name: restart_gitlab_runner_windows
win_command: "{{ gitlab_runner_executable }} restart"
args:
chdir: "{{ gitlab_runner_config_file_location }}"
when: ansible_os_family == 'Windows'
# Container
- name: restart_gitlab_runner_container
docker_container:
name: "{{ gitlab_runner_container_name }}"
restart: yes
when: gitlab_runner_container_install

View file

@ -1,28 +0,0 @@
---
galaxy_info:
author: Erik-jan Riemers
description: GitLab Runner
license: MIT
min_ansible_version: 2.0
platforms:
- name: EL
versions:
- all
- name: Ubuntu
versions:
- all
- name: Debian
version:
- all
- name: MacOSX
versions:
- all
- name: Windows
versions:
- all
galaxy_tags:
- gitlab
- runner
- ci
dependencies: []

View file

@ -1,74 +0,0 @@
---
- name: (Container) Install Gitlab Runner
import_tasks: install-container.yml
when: gitlab_runner_container_install
- name: (Container) List configured runners
docker_container:
name: "{{ gitlab_runner_container_name }}"
image: "{{ gitlab_runner_container_image }}:{{ gitlab_runner_container_tag }}"
command: list
mounts:
- type: bind
source: "/srv/{{ gitlab_runner_container_name }}"
target: /etc/gitlab-runner
cleanup: yes
interactive: yes
tty: yes
detach: no
register: configured_runners
changed_when: False
check_mode: no
- name: (Container) Check runner is registered
docker_container:
name: "{{ gitlab_runner_container_name }}"
image: "{{ gitlab_runner_container_image }}:{{ gitlab_runner_container_tag }}"
command: verify
mounts:
- type: bind
source: "/srv/{{ gitlab_runner_container_name }}"
target: /etc/gitlab-runner
cleanup: yes
interactive: yes
tty: yes
detach: no
register: verified_runners
ignore_errors: True
changed_when: False
check_mode: no
- name: configured_runners?
debug:
msg: "{{configured_runners.container.Output}}"
- name: verified_runners?
debug:
msg: "{{verified_runners.container.Output}}"
- name: (Container) Register GitLab Runner
include_tasks: register-runner-container.yml
when: gitlab_runner.token is defined or gitlab_runner_registration_token | string | length > 0 # Ensure value is set
loop: "{{ gitlab_runner_runners }}"
loop_control:
index_var: gitlab_runner_index
loop_var: gitlab_runner
- name: (Container) Set global options
import_tasks: global-setup.yml
- name: (Container) Configure GitLab Runner
import_tasks: config-runners-container.yml
- name: (Container) Start the container
docker_container:
name: "{{ gitlab_runner_container_name }}"
image: "{{ gitlab_runner_container_image }}:{{ gitlab_runner_container_tag }}"
restart_policy: "{{ gitlab_runner_container_restart_policy }}"
mounts:
- type: bind
source: "/srv/{{ gitlab_runner_container_name }}"
target: /etc/gitlab-runner
- type: bind
source: /var/run/docker.sock
target: /var/run/docker.sock

View file

@ -1,40 +0,0 @@
- name: Install GitLab Runner (Debian)
import_tasks: install-debian.yml
when: ansible_os_family == 'Debian'
- name: Install GitLab Runner (RedHat)
import_tasks: install-redhat.yml
when: ansible_os_family == 'RedHat'
- name: Install GitLab Runner (macOS)
import_tasks: install-macos.yml
when: ansible_os_family == 'Darwin'
- name: (Unix) List configured runners
command: "{{ gitlab_runner_executable }} list"
register: configured_runners
changed_when: False
check_mode: no
become: yes
- name: (Unix) Check runner is registered
command: "{{ gitlab_runner_executable }} verify"
register: verified_runners
ignore_errors: True
changed_when: False
check_mode: no
become: yes
- name: (Unix) Register GitLab Runner
include_tasks: register-runner.yml
when: gitlab_runner.token is defined or gitlab_runner_registration_token | string | length > 0 # Ensure value is set
loop: "{{ gitlab_runner_runners }}"
loop_control:
index_var: gitlab_runner_index
loop_var: gitlab_runner
- name: Set global options (macOS/Debian/RedHat)
import_tasks: global-setup.yml
- name: (Unix) Configure GitLab Runner
import_tasks: config-runners.yml

View file

@ -1,38 +0,0 @@
- name: Install GitLab Runner (Windows)
import_tasks: install-windows.yml
- name: (Windows) List configured runners
win_command: "{{ gitlab_runner_executable }} list"
args:
chdir: "{{ gitlab_runner_config_file_location }}"
register: configured_runners
changed_when: False
check_mode: no
- name: (Windows) Check runner is registered
win_command: "{{ gitlab_runner_executable }} verify"
args:
chdir: "{{ gitlab_runner_config_file_location }}"
register: verified_runners
ignore_errors: True
changed_when: False
check_mode: no
- name: (Windows) Register GitLab Runner
include_tasks: register-runner-windows.yml
when: gitlab_runner.token is defined or gitlab_runner_registration_token | string | length > 0 # Ensure value is set
loop: "{{ gitlab_runner_runners }}"
loop_control:
index_var: gitlab_runner_index
loop_var: gitlab_runner
- name: (Windows) Set global options
import_tasks: global-setup-windows.yml
- name: (Windows) Configure GitLab Runner
import_tasks: config-runners-windows.yml
- name: (Windows) Start GitLab Runner
win_command: "{{ gitlab_runner_executable }} start"
args:
chdir: "{{ gitlab_runner_config_file_location }}"

View file

@ -1,37 +0,0 @@
---
- name: Create temporary file
tempfile:
state: file
path: "{{ temp_runner_config_dir.path }}"
prefix: "gitlab-runner.{{ runner_config_index }}."
register: temp_runner_config
check_mode: no
changed_when: false
- name: Isolate runner configuration
copy:
dest: "{{ temp_runner_config.path }}"
content: "{{ runner_config }}"
check_mode: no
changed_when: false
- include_tasks: update-config-runner.yml
when:
- ('name = "'+gitlab_runner.name|default(ansible_hostname+'-'+gitlab_runner_index|string)+'"') in runner_config
- gitlab_runner.state|default('present') == 'present'
loop: "{{ gitlab_runner_runners }}"
loop_control:
index_var: gitlab_runner_index
loop_var: gitlab_runner
- name: Remove runner config
file:
path: "{{ temp_runner_config.path }}"
state: absent
when:
- ('name = "'+gitlab_runner.name|default(ansible_hostname+'-'+gitlab_runner_index|string)+'"') in runner_config
- gitlab_runner.state|default('present') == 'absent'
loop: "{{ gitlab_runner_runners }}"
loop_control:
index_var: gitlab_runner_index
loop_var: gitlab_runner

View file

@ -1,37 +0,0 @@
---
- name: (Windows) Create temporary file
win_tempfile:
state: file
path: "{{ temp_runner_config_dir.path }}"
prefix: "gitlab-runner.{{ runner_config_index }}."
register: temp_runner_config
check_mode: no
changed_when: false
- name: (Windows) Isolate runner configuration
win_copy:
dest: "{{ temp_runner_config.path }}"
content: "{{ runner_config }}"
check_mode: no
changed_when: false
- include_tasks: update-config-runner-windows.yml
when:
- ('name = "'+gitlab_runner.name|default(ansible_hostname+'-'+gitlab_runner_index|string)+'"') in runner_config
- gitlab_runner.state|default('present') == 'present'
loop: "{{ gitlab_runner_runners }}"
loop_control:
index_var: gitlab_runner_index
loop_var: gitlab_runner
- name: (Windows) Remove runner config
win_file:
path: "{{ temp_runner_config.path }}"
state: absent
when:
- ('name = "'+gitlab_runner.name|default(ansible_hostname+'-'+gitlab_runner_index|string)+'"') in runner_config
- gitlab_runner.state|default('present') == 'absent'
loop: "{{ gitlab_runner_runners }}"
loop_control:
index_var: gitlab_runner_index
loop_var: gitlab_runner

View file

@ -1,37 +0,0 @@
---
- name: Create temporary file
tempfile:
state: file
path: "{{ temp_runner_config_dir.path }}"
prefix: "gitlab-runner.{{ runner_config_index }}."
register: temp_runner_config
check_mode: no
changed_when: false
- name: Isolate runner configuration
copy:
dest: "{{ temp_runner_config.path }}"
content: "{{ runner_config }}"
check_mode: no
changed_when: false
- include_tasks: update-config-runner.yml
when:
- ('name = "'+gitlab_runner.name|default(ansible_hostname+'-'+gitlab_runner_index|string)+'"') in runner_config
- gitlab_runner.state|default('present') == 'present'
loop: "{{ gitlab_runner_runners }}"
loop_control:
index_var: gitlab_runner_index
loop_var: gitlab_runner
- name: Remove runner config
file:
path: "{{ temp_runner_config.path }}"
state: absent
when:
- ('name = "'+gitlab_runner.name|default(ansible_hostname+'-'+gitlab_runner_index|string)+'"') in runner_config
- gitlab_runner.state|default('present') == 'absent'
loop: "{{ gitlab_runner_runners }}"
loop_control:
index_var: gitlab_runner_index
loop_var: gitlab_runner

View file

@ -1,36 +0,0 @@
---
- name: Get existing config.toml
slurp:
src: "{{ gitlab_runner_config_file }}"
register: runner_config_file
- name: Get pre-existing runner configs
set_fact:
runner_configs: "{{ (runner_config_file['content'] | b64decode).split('[[runners]]\n') }}"
- name: Create temporary directory
tempfile:
state: directory
suffix: gitlab-runner-config
register: temp_runner_config_dir
check_mode: no
changed_when: false
- name: Write config section for each runner
include_tasks: config-runner-container.yml
loop: "{{ runner_configs }}"
loop_control:
index_var: runner_config_index
loop_var: runner_config
- name: Assemble new config.toml
assemble:
src: "{{ temp_runner_config_dir.path }}"
dest: "{{ gitlab_runner_config_file }}"
delimiter: '[[runners]]\n'
backup: yes
validate: |
docker run -i --rm -v %s:/gitlab-runner.conf
{{ gitlab_runner_container_image }}:{{ gitlab_runner_container_tag }}
verify -c /gitlab-runner.conf
mode: 0600

View file

@ -1,68 +0,0 @@
---
- name: (Windows) Get existing config.toml
slurp:
src: "{{ gitlab_runner_config_file }}"
register: runner_config_file
- name: (Windows) Get pre-existing global config
set_fact:
runner_global_config: "{{ (runner_config_file['content'] | b64decode).split('[[runners]]')[0] }}"
- name: (Windows) Get pre-existing runner configs
set_fact:
runner_configs: "{{ (runner_config_file['content'] | b64decode).split('[[runners]]')[1:] }}"
- name: (Windows) Create temporary directory
win_tempfile:
state: directory
suffix: gitlab-runner-config
register: temp_runner_config_dir
check_mode: no
changed_when: false
- name: (Windows) Write config section for each runner
include_tasks: config-runner-windows.yml
loop: "{{ runner_configs }}"
loop_control:
index_var: runner_config_index
loop_var: runner_config
- name: (Windows) Assemble new config.toml
when: not ansible_check_mode
block:
- name: (Windows) Create temporary file config.toml
win_tempfile:
state: file
suffix: temp
register: config_toml_temp
- name: (Windows) Write global config to file
win_lineinfile:
insertbefore: BOF
path: "{{ config_toml_temp.path }}"
line: "[[runners]]"
- name: (Windows) Write global config to file
win_lineinfile:
insertbefore: BOF
path: "{{ config_toml_temp.path }}"
line: "{{ runner_global_config }}"
- name: (Windows) Create temporary file runners-config.toml
win_tempfile:
state: file
suffix: temp
register: runners_config_toml_temp
- name: (Windows) Assemble runners files in config dir
win_shell: dir -rec | gc | out-file "{{ runners_config_toml_temp.path }}"
args:
chdir: "{{ temp_runner_config_dir.path }}"
- name: (Windows) Assemble new config.toml
win_shell: gc "{{ config_toml_temp.path }}","{{ runners_config_toml_temp.path }}" | Set-Content "{{ gitlab_runner_config_file }}"
- name: (Windows) Verify config
win_command: "{{ gitlab_runner_executable }} verify"
args:
chdir: "{{ gitlab_runner_config_file_location }}"

View file

@ -1,35 +0,0 @@
---
- name: Get existing config.toml
slurp:
src: "{{ gitlab_runner_config_file }}"
register: runner_config_file
become: "{{ gitlab_runner_system_mode }}"
- name: Get pre-existing runner configs
set_fact:
runner_configs: "{{ (runner_config_file['content'] | b64decode).split('[[runners]]\n') }}"
- name: Create temporary directory
tempfile:
state: directory
suffix: gitlab-runner-config
register: temp_runner_config_dir
check_mode: no
changed_when: false
- name: Write config section for each runner
include_tasks: config-runner.yml
loop: "{{ runner_configs }}"
loop_control:
index_var: runner_config_index
loop_var: runner_config
- name: Assemble new config.toml
assemble:
src: "{{ temp_runner_config_dir.path }}"
dest: "{{ gitlab_runner_config_file }}"
delimiter: '[[runners]]\n'
backup: yes
validate: "{{ gitlab_runner_executable }} verify -c %s"
mode: 0600
become: "{{ gitlab_runner_system_mode }}"

View file

@ -1,49 +0,0 @@
---
- name: (Windows) Create .gitlab-runner dir
win_file:
path: "{{ gitlab_runner_config_file_location }}"
state: directory
- name: (Windows) Ensure config.toml exists
win_file:
path: "{{ gitlab_runner_config_file }}"
state: touch
modification_time: preserve
access_time: preserve
- name: (Windows) Set concurrent option
win_lineinfile:
dest: "{{ gitlab_runner_config_file }}"
regexp: '^(\s*)concurrent =.*'
line: '$1concurrent = {{ gitlab_runner_concurrent }}'
state: present
backrefs: yes
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- restart_gitlab_runner_windows
- name: (Windows) Add listen_address to config
win_lineinfile:
dest: "{{ gitlab_runner_config_file }}"
regexp: '^listen_address =.*'
line: 'listen_address = "{{ gitlab_runner_listen_address }}"'
insertafter: '\s*concurrent.*'
state: present
when: gitlab_runner_listen_address | length > 0 # Ensure value is set
notify:
- restart_gitlab_runner
- restart_gitlab_runner_windows
- name: (Windows) Add sentry dsn to config
win_lineinfile:
dest: "{{ gitlab_runner_config_file }}"
regexp: '^sentry_dsn =.*'
line: 'sentry_dsn = "{{ gitlab_runner_sentry_dsn }}"'
insertafter: '\s*concurrent.*'
state: present
when: gitlab_runner_sentry_dsn | length > 0 # Ensure value is set
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- restart_gitlab_runner_windows

View file

@ -1,53 +0,0 @@
---
- name: Create .gitlab-runner dir
file:
path: "{{ gitlab_runner_config_file_location }}"
state: directory
mode: '0755'
become: "{{ gitlab_runner_system_mode }}"
- name: Ensure config.toml exists
file:
path: "{{ gitlab_runner_config_file }}"
state: touch
modification_time: preserve
access_time: preserve
become: "{{ gitlab_runner_system_mode }}"
- name: Set concurrent option
lineinfile:
dest: "{{ gitlab_runner_config_file }}"
regexp: '^(\s*)concurrent ='
line: '\1concurrent = {{ gitlab_runner_concurrent }}'
state: present
backrefs: yes
become: "{{ gitlab_runner_system_mode }}"
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Add listen_address to config
lineinfile:
dest: "{{ gitlab_runner_config_file }}"
regexp: '^listen_address ='
line: 'listen_address = "{{ gitlab_runner_listen_address }}"'
insertafter: '\s*concurrent.*'
state: present
when: gitlab_runner_listen_address | length > 0 # Ensure value is set
become: "{{ gitlab_runner_system_mode }}"
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Add sentry dsn to config
lineinfile:
dest: "{{ gitlab_runner_config_file }}"
regexp: '^sentry_dsn ='
line: 'sentry_dsn = "{{ gitlab_runner_sentry_dsn }}"'
insertafter: '\s*concurrent.*'
state: present
when: gitlab_runner_sentry_dsn | length > 0 # Ensure value is set
become: "{{ gitlab_runner_system_mode }}"
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos

View file

@ -1,10 +0,0 @@
---
- name: (Container) Pull Image from Registry
docker_image:
name: "{{ gitlab_runner_container_image }}:{{ gitlab_runner_container_tag }}"
source: pull
- name: (Container) Define Container volume Path
file:
state: directory
path: "/srv/{{ gitlab_runner_container_name }}"

View file

@ -1,52 +0,0 @@
---
- name: (Debian) Get Gitlab repository installation script
get_url:
url: "https://packages.gitlab.com/install/repositories/runner/{{ gitlab_runner_package_name }}/script.deb.sh"
dest: /tmp/gitlab-runner.script.deb.sh
mode: 0744
when: gitlab_runner_skip_package_repo_install is not defined or not gitlab_runner_skip_package_repo_install
- name: (Debian) Install Gitlab repository
command: bash /tmp/gitlab-runner.script.deb.sh
args:
creates: "/etc/apt/sources.list.d/runner_{{ gitlab_runner_package_name }}.list"
become: true
when: gitlab_runner_skip_package_repo_install is not defined or not gitlab_runner_skip_package_repo_install
- name: (Debian) Update gitlab_runner_package_name
set_fact:
gitlab_runner_package: "{{ gitlab_runner_package_name }}={{ gitlab_runner_package_version }}"
gitlab_runner_package_state: "present"
when: gitlab_runner_package_version is defined
- name: (Debian) Set gitlab_runner_package_name
set_fact:
gitlab_runner_package: "{{ gitlab_runner_package_name }}"
gitlab_runner_package_state: "latest"
when: gitlab_runner_package_version is not defined
- name: (Debian) Install GitLab Runner
apt:
name: "{{ gitlab_runner_package }}"
state: "{{ gitlab_runner_package_state }}"
become: true
environment:
GITLAB_RUNNER_DISABLE_SKEL: "true"
when: ansible_distribution_release in ["buster", "focal"]
- name: (Debian) Install GitLab Runner
apt:
name: "{{ gitlab_runner_package }}"
state: "{{ gitlab_runner_package_state }}"
become: true
when: ansible_distribution_release not in ["buster", "focal"]
- name: (Debian) Remove ~/gitlab-runner/.bash_logout on debian buster and ubuntu focal
file:
path: /home/gitlab-runner/.bash_logout
state: absent
when: ansible_distribution_release in ["buster", "focal"]
- name: Set systemd reload options
import_tasks: systemd-reload.yml

View file

@ -1,69 +0,0 @@
- name: (MacOS) PRE-CHECK GitLab Runner exists
block:
- name: (MacOS) Check gitlab-runner executable exists
stat:
path: "{{ gitlab_runner_executable }}"
register: gitlab_runner_exists
- name: (MacOS) Set fact -> gitlab_runner_exists
set_fact:
gitlab_runner_exists: "{{ gitlab_runner_exists.stat.exists }}"
- name: (MacOS) Get existing version
shell: "{{ gitlab_runner_executable }} --version | awk '/Version: ([\\d\\.]*)/{print $2}'"
register: existing_version_shell
failed_when: no
check_mode: no
changed_when: no
- name: (MacOS) Set fact -> gitlab_runner_existing_version
set_fact:
gitlab_runner_existing_version: "{{ existing_version_shell.stdout if existing_version_shell.rc == 0 else '0' }}"
- name: (MacOS) INSTALL GitLab Runner for macOS
block:
- name: (MacOS) Download GitLab Runner
get_url:
url: "{{ gitlab_runner_download_url }}"
dest: "{{ gitlab_runner_executable }}"
force: yes
- name: (MacOS) Setting Permissions for gitlab-runner executable
file:
path: "{{ gitlab_runner_executable }}"
owner: "{{ ansible_user_id | string }}"
group: "{{ ansible_user_gid | string }}"
mode: '+x'
- name: (MacOS) Install GitLab Runner
command: "{{ gitlab_runner_executable }} install"
- name: (MacOS) Start GitLab Runner
command: "{{ gitlab_runner_executable }} start"
when: (not gitlab_runner_exists)
- name: (MacOS) UPGRADE GitLab Runner for macOS
block:
- name: (MacOS) Stop GitLab Runner
command: "{{ gitlab_runner_executable }} stop"
- name: (MacOS) Download GitLab Runner
get_url:
url: "{{ gitlab_runner_download_url }}"
dest: "{{ gitlab_runner_executable }}"
force: yes
- name: (MacOS) Setting Permissions for gitlab-runner executable
file:
path: "{{ gitlab_runner_executable }}"
owner: "{{ ansible_user_id | string }}"
group: "{{ ansible_user_gid | string }}"
mode: '+x'
become: yes
- name: (MacOS) Start GitLab Runner
command: "{{ gitlab_runner_executable }} start"
when:
- gitlab_runner_exists
- gitlab_runner_existing_version != gitlab_runner_wanted_version or gitlab_runner_wanted_version == 'latest'

View file

@ -1,38 +0,0 @@
---
- name: (RedHat) Get Gitlab repository installation script
get_url:
url: "https://packages.gitlab.com/install/repositories/runner/{{ gitlab_runner_package_name }}/script.rpm.sh"
dest: /tmp/gitlab-runner.script.rpm.sh
mode: 0744
when: gitlab_runner_skip_package_repo_install is not defined or not gitlab_runner_skip_package_repo_install
- name: (RedHat) Install Gitlab repository
shell: >
os=el dist={{ '7' if ansible_distribution_major_version | int == 8 else ansible_distribution_major_version }}
bash /tmp/gitlab-runner.script.rpm.sh
args:
creates: "/etc/yum.repos.d/runner_{{ gitlab_runner_package_name }}.repo"
become: true
when: gitlab_runner_skip_package_repo_install is not defined or not gitlab_runner_skip_package_repo_install
- name: (RedHat) Update gitlab_runner_package_name
set_fact:
gitlab_runner_package: "{{ gitlab_runner_package_name }}-{{ gitlab_runner_package_version }}"
gitlab_runner_package_state: "present"
when: gitlab_runner_package_version is defined
- name: (RedHat) Set gitlab_runner_package_name
set_fact:
gitlab_runner_package: "{{ gitlab_runner_package_name }}"
gitlab_runner_package_state: "latest"
when: gitlab_runner_package_version is not defined
- name: (RedHat) Install GitLab Runner
package:
name: "{{ gitlab_runner_package }}"
state: "{{ gitlab_runner_package_state }}"
become: true
- name: Set systemd reload options
import_tasks: systemd-reload.yml

View file

@ -1,67 +0,0 @@
- name: (Windows) PRE-CHECK GitLab Runner exists
block:
- name: (Windows) Check gitlab-runner executable exists
win_stat:
path: "{{ gitlab_runner_executable }}"
register: gitlab_runner_exists
- name: (Windows) Set fact -> gitlab_runner_exists
set_fact:
gitlab_runner_exists: "{{ gitlab_runner_exists.stat.exists }}"
- name: (Windows) Get existing version
win_shell: "{{ gitlab_runner_executable }} --version | Select-String 'Version:' -CaseSensitive | %{ $_.Line.Split(' ')[-1].Trim(); }"
register: existing_version_shell
failed_when: no
check_mode: no
changed_when: no
- name: (Windows) Set fact -> gitlab_runner_existing_version
set_fact:
gitlab_runner_existing_version: "{{ existing_version_shell.stdout | trim if existing_version_shell.rc == 0 else '0' }}"
- name: (Windows) INSTALL GitLab Runner for Windows
block:
- name: (Windows) Ensure install directory exists
win_file:
path: "{{ gitlab_runner_install_directory }}"
state: directory
- name: (Windows) Download GitLab Runner
win_get_url:
url: "{{ gitlab_runner_download_url }}"
dest: "{{ gitlab_runner_executable }}"
force: yes
- name: (Windows) Install GitLab Runner
win_command: "{{ gitlab_runner_executable }} install"
args:
chdir: "{{ gitlab_runner_config_file_location }}"
when: (gitlab_runner_windows_service_user | length == 0) or (gitlab_runner_windows_service_password | length == 0)
- name: (Windows) Install GitLab Runner
win_command: "{{ gitlab_runner_executable }} install --user \"{{ gitlab_runner_windows_service_user }}\" --password \"{{ gitlab_runner_windows_service_password }}\""
args:
chdir: "{{ gitlab_runner_config_file_location }}"
when:
- gitlab_runner_windows_service_user | length > 0
- gitlab_runner_windows_service_password | length > 0
when: (not gitlab_runner_exists)
- name: (Windows) Make sure runner is stopped
win_command: "{{ gitlab_runner_executable }} stop"
ignore_errors: yes
when:
- gitlab_runner_exists
- name: (Windows) UPGRADE GitLab Runner for Windows
block:
- name: (Windows) Download GitLab Runner
win_get_url:
url: "{{ gitlab_runner_download_url }}"
dest: "{{ gitlab_runner_executable }}"
force: yes
when:
- gitlab_runner_exists
- gitlab_runner_existing_version != gitlab_runner_wanted_version or gitlab_runner_wanted_version == 'latest'

View file

@ -1,14 +0,0 @@
---
- name: (Windows) Ensure section exists
win_lineinfile:
path: "{{ temp_runner_config.path }}"
regexp: '^(\s*)\[{{ section|regex_escape }}\]$'
line: '{{ " " * (section.split(".")|length -1) }}[{{ section }}]'
- name: (Windows) Modify existing line
win_lineinfile:
path: "{{ temp_runner_config.path }}"
insertafter: '\s+\[{{ section | regex_escape }}\]'
regexp: '^(\s*){{ line | to_json | regex_escape }} =.*'
line: '{{ " " * (section.split(".")|length) }}{{ line | to_json }} = {{ gitlab_runner.extra_configs[section][line] | to_json }}'
register: modified_config_line

View file

@ -1,14 +0,0 @@
---
- name: Ensure section exists
lineinfile:
path: "{{ temp_runner_config.path }}"
regexp: '^(\s*)\[{{ section|regex_escape }}\]$'
line: '{{ " " * (section.split(".")|length -1) }}[{{ section }}]'
- name: Modify existing line
lineinfile:
path: "{{ temp_runner_config.path }}"
insertafter: '\s+\[{{ section | regex_escape }}\]'
regexp: '^(\s*){{ line | to_json | regex_escape }} ='
line: '{{ " " * (section.split(".")|length) }}{{ line | to_json }} = {{ gitlab_runner.extra_configs[section][line] | to_json }}'
register: modified_config_line

View file

@ -1,23 +0,0 @@
---
- name: Load platform-specific variables
include_vars: "{{ lookup('first_found', possible_files) }}"
vars:
possible_files:
files:
- '{{ ansible_distribution }}.yml'
- '{{ ansible_os_family }}.yml'
- default.yml
paths:
- 'vars'
- name: Install Gitlab Runner (Container)
import_tasks: Container.yml
when: gitlab_runner_container_install
- name: Install GitLab Runner (Unix)
import_tasks: Unix.yml
when: ansible_os_family != 'Windows' and not gitlab_runner_container_install
- name: Install GitLab Runner (Windows)
import_tasks: Windows.yml
when: ansible_os_family == 'Windows' and not gitlab_runner_container_install

View file

@ -1,114 +0,0 @@
---
- name: Clear Config File
block:
- name: remove config.toml file
file:
path: "{{ gitlab_runner_config_file }}"
state: absent
- name: Ensure config.toml exists
file:
path: "{{ gitlab_runner_config_file }}"
state: touch
modification_time: preserve
access_time: preserve
when: (verified_runners.container.Output.find("Verifying runner... is removed") != -1)
- name: Register runner to GitLab
docker_container:
name: "{{ gitlab_runner_container_name }}"
image: "{{ gitlab_runner_container_image }}:{{ gitlab_runner_container_tag }}"
command: |
register
--non-interactive
--url '{{ gitlab_runner_coordinator_url }}'
--registration-token '{{ gitlab_runner.token|default(gitlab_runner_registration_token) }}'
--description '{{ gitlab_runner.name|default(ansible_hostname+"-"+gitlab_runner_index|string) }}'
--tag-list '{{ gitlab_runner.tags|default([]) | join(",") }}'
{% if gitlab_runner.clone_url|default(false) %}
--clone-url "{{ gitlab_runner.clone_url }}"
{% endif %}
{% if gitlab_runner.run_untagged|default(true) %}
--run-untagged
{% endif %}
--executor '{{ gitlab_runner.executor|default("shell") }}'
--limit '{{ gitlab_runner.concurrent_specific|default(0) }}'
--output-limit '{{ gitlab_runner.output_limit|default(4096) }}'
--locked='{{ gitlab_runner.locked|default(false) }}'
{% for env_var in gitlab_runner.env_vars|default([]) %}
--env '{{ env_var }}'
{% endfor %}
{% if gitlab_runner.pre_clone_script|default(false) %}
--pre-clone-script "{{ gitlab_runner.pre_clone_script }}"
{% endif %}
{% if gitlab_runner.pre_build_script|default(false) %}
--pre-build-script "{{ gitlab_runner.pre_build_script }}"
{% endif %}
{% if gitlab_runner.post_build_script|default(false) %}
--post-build-script "{{ gitlab_runner.post_build_script }}"
{% endif %}
--docker-image '{{ gitlab_runner.docker_image|default("alpine") }}'
{% if gitlab_runner.docker_privileged|default(false) %}
--docker-privileged
{% endif %}
{% if gitlab_runner.docker_tlsverify|default(false) %}
--docker-tlsverify '{{ gitlab_runner.docker_tlsverify|default("true") }}'
{% endif %}
{% if gitlab_runner.docker_dns|default(false) %}
--docker-dns '{{ gitlab_runner.docker_dns|default("1.1.1.1") }}'
{% endif %}
{% for volume in gitlab_runner.docker_volumes | default([]) %}
--docker-volumes "{{ volume }}"
{% endfor %}
--ssh-user '{{ gitlab_runner.ssh_user|default("") }}'
--ssh-host '{{ gitlab_runner.ssh_host|default("") }}'
--ssh-port '{{ gitlab_runner.ssh_port|default("") }}'
--ssh-password '{{ gitlab_runner.ssh_password|default("") }}'
--ssh-identity-file '{{ gitlab_runner.ssh_identity_file|default("") }}'
{% if gitlab_runner.cache_type is defined %}
--cache-type '{{ gitlab_runner.cache_type }}'
{% endif %}
{% if gitlab_runner.cache_shared|default(false) %}
--cache-shared
{% endif %}
{% if gitlab_runner.cache_path is defined %}
--cache-path '{{ gitlab_runner.cache_path }}'
{% endif %}
{% if gitlab_runner.cache_s3_server_address is defined %}
--cache-s3-server-address '{{ gitlab_runner.cache_s3_server_address }}'
{% if gitlab_runner.cache_s3_access_key is defined %}
--cache-s3-access-key '{{ gitlab_runner.cache_s3_access_key }}'
{% endif %}
{% if gitlab_runner.cache_s3_secret_key is defined %}
--cache-s3-secret-key '{{ gitlab_runner.cache_s3_secret_key }}'
{% endif %}
{% endif %}
{% if gitlab_runner.cache_s3_bucket_name is defined %}
--cache-s3-bucket-name '{{ gitlab_runner.cache_s3_bucket_name }}'
{% endif %}
{% if gitlab_runner.cache_s3_bucket_location is defined %}
--cache-s3-bucket-location '{{ gitlab_runner.cache_s3_bucket_location }}'
{% endif %}
{% if gitlab_runner.builds_dir|default(false) %}
--builds-dir '{{ gitlab_runner.builds_dir }}'
{% endif %}
{% if gitlab_runner.cache_dir|default(false) %}
--cache-dir '{{ gitlab_runner.cache_dir }}'
{% endif %}
{% if gitlab_runner.cache_s3_insecure|default(false) %}
--cache-s3-insecure
{% endif %}
{% if gitlab_runner.extra_registration_option is defined %}
{{ gitlab_runner.extra_registration_option }}
{% endif %}
mounts:
- type: bind
source: "/srv/{{ gitlab_runner_container_name }}"
target: /etc/gitlab-runner
cleanup: yes
auto_remove: yes
when: (verified_runners.container.Output.find("Verifying runner... is removed") != -1) or
((configured_runners.container.Output.find('\n' + gitlab_runner.name|default(ansible_hostname+'-'+gitlab_runner_index|string)) == -1) and
(gitlab_runner.state|default('present') == 'present'))
no_log: false

View file

@ -1,118 +0,0 @@
---
- name: (Windows) Clear Config File
block:
- name: (Windows) remove config.toml file
win_file:
path: "{{ gitlab_runner_config_file }}"
state: absent
- name: (Windows) Create .gitlab-runner dir
win_file:
path: "{{ gitlab_runner_config_file_location }}"
state: directory
- name: (Windows) Ensure config.toml exists
win_file:
path: "{{ gitlab_runner_config_file }}"
state: touch
modification_time: preserve
access_time: preserve
when: (verified_runners.stderr.find("Verifying runner... is removed") != -1)
- name: (Windows) Register runner to GitLab
win_shell: >
{{ gitlab_runner_executable }} register
--non-interactive
--url '{{ gitlab_runner.url|default(gitlab_runner_coordinator_url) }}'
--registration-token '{{ gitlab_runner.token|default(gitlab_runner_registration_token) }}'
--description '{{ gitlab_runner.name|default(ansible_hostname+"-"+gitlab_runner_index|string) }}'
--tag-list '{{ gitlab_runner.tags|default([]) | join(",") }}'
{% if gitlab_runner.clone_url|default(false) %}
--clone-url "{{ gitlab_runner.clone_url }}"
{% endif %}
{% if gitlab_runner.run_untagged|default(true) %}
--run-untagged
{% endif %}
--executor '{{ gitlab_runner.executor|default("shell") }}'
{% if gitlab_runner.shell is defined %}
--shell '{{ gitlab_runner.shell }}'
{% endif %}
--limit '{{ gitlab_runner.concurrent_specific|default(0) }}'
--output-limit '{{ gitlab_runner.output_limit|default(4096) }}'
--locked='{{ gitlab_runner.locked|default(false) }}'
{% for env_var in gitlab_runner.env_vars|default([]) %}
--env '{{ env_var }}'
{% endfor %}
{% if gitlab_runner.pre_clone_script|default(false) %}
--pre-clone-script "{{ gitlab_runner.pre_clone_script }}"
{% endif %}
{% if gitlab_runner.pre_build_script|default(false) %}
--pre-build-script "{{ gitlab_runner.pre_build_script }}"
{% endif %}
{% if gitlab_runner.post_build_script|default(false) %}
--post-build-script "{{ gitlab_runner.post_build_script }}"
{% endif %}
--docker-image '{{ gitlab_runner.docker_image|default("alpine") }}'
{% if gitlab_runner.docker_privileged|default(false) %}
--docker-privileged
{% endif %}
{% for volume in gitlab_runner.docker_volumes | default([]) %}
--docker-volumes "{{ volume }}"
{% endfor %}
{% if gitlab_runner.ssh_user is defined %}
--ssh-user '{{ gitlab_runner.ssh_user }}'
{% endif %}
{% if gitlab_runner.ssh_host is defined %}
--ssh-host '{{ gitlab_runner.ssh_host }}'
{% endif %}
{% if gitlab_runner.ssh_port is defined %}
--ssh-port '{{ gitlab_runner.ssh_port }}'
{% endif %}
{% if gitlab_runner.ssh_password is defined %}
--ssh-password '{{ gitlab_runner.ssh_password }}'
{% endif %}
{% if gitlab_runner.ssh_identity_file is defined %}
--ssh-identity-file '{{ gitlab_runner.ssh_identity_file }}'
{% endif %}
{% if gitlab_runner.cache_type is defined %}
--cache-type '{{ gitlab_runner.cache_type }}'
{% endif %}
{% if gitlab_runner.cache_shared|default(false) %}
--cache-shared
{% endif %}
{% if gitlab_runner.cache_path is defined %}
--cache-path '{{ gitlab_runner.cache_path }}'
{% endif %}
{% if gitlab_runner.cache_s3_server_address is defined %}
--cache-s3-server-address '{{ gitlab_runner.cache_s3_server_address }}'
{% endif %}
{% if gitlab_runner.cache_s3_access_key is defined %}
--cache-s3-access-key '{{ gitlab_runner.cache_s3_access_key }}'
{% endif %}
{% if gitlab_runner.cache_s3_secret_key is defined %}
--cache-s3-secret-key '{{ gitlab_runner.cache_s3_secret_key }}'
{% endif %}
{% if gitlab_runner.cache_s3_bucket_name is defined %}
--cache-s3-bucket-name '{{ gitlab_runner.cache_s3_bucket_name }}'
{% endif %}
{% if gitlab_runner.cache_s3_bucket_location is defined %}
--cache-s3-bucket-location '{{ gitlab_runner.cache_s3_bucket_location }}'
{% endif %}
{% if gitlab_runner.builds_dir|default(false) %}
--builds-dir '{{ gitlab_runner.builds_dir }}'
{% endif %}
{% if gitlab_runner.cache_dir|default(false) %}
--cache-dir '{{ gitlab_runner.cache_dir }}'
{% endif %}
{% if gitlab_runner.cache_s3_insecure|default(false) %}
--cache-s3-insecure
{% endif %}
{% if gitlab_runner.extra_registration_option is defined %}
{{ gitlab_runner.extra_registration_option }}
{% endif %}
when: (verified_runners.stderr.find("Verifying runner... is removed") != -1) or
((configured_runners.stderr.find('\n' + gitlab_runner.name|default(ansible_hostname+'-'+gitlab_runner_index|string)) == -1) and
(gitlab_runner.state|default('present') == 'present'))
args:
chdir: "{{ gitlab_runner_config_file_location }}"
#no_log: true

View file

@ -1,117 +0,0 @@
---
- name: Clear Config File
block:
- name: remove config.toml file
file:
path: "{{ gitlab_runner_config_file }}"
state: absent
become: "{{ gitlab_runner_system_mode }}"
- name: Create .gitlab-runner dir
file:
path: "{{ gitlab_runner_config_file_location }}"
state: directory
mode: '0755'
become: "{{ gitlab_runner_system_mode }}"
- name: Ensure config.toml exists
file:
path: "{{ gitlab_runner_config_file }}"
state: touch
modification_time: preserve
access_time: preserve
become: "{{ gitlab_runner_system_mode }}"
when: (verified_runners.stderr.find("Verifying runner... is removed") != -1)
- name: Register runner to GitLab
command: >
{{ gitlab_runner_executable }} register
--non-interactive
--url '{{ gitlab_runner.url|default(gitlab_runner_coordinator_url) }}'
--registration-token '{{ gitlab_runner.token|default(gitlab_runner_registration_token) }}'
--description '{{ gitlab_runner.name|default(ansible_hostname+"-"+gitlab_runner_index|string) }}'
--tag-list '{{ gitlab_runner.tags|default([]) | join(",") }}'
{% if gitlab_runner.clone_url|default(false) %}
--clone-url "{{ gitlab_runner.clone_url }}"
{% endif %}
{% if gitlab_runner.run_untagged|default(true) %}
--run-untagged
{% endif %}
--executor '{{ gitlab_runner.executor|default("shell") }}'
{% if gitlab_runner.shell is defined %}
--shell '{{ gitlab_runner.shell }}'
{% endif %}
--limit '{{ gitlab_runner.concurrent_specific|default(0) }}'
--output-limit '{{ gitlab_runner.output_limit|default(4096) }}'
--locked='{{ gitlab_runner.locked|default(false) }}'
{% for env_var in gitlab_runner.env_vars|default([]) %}
--env '{{ env_var }}'
{% endfor %}
{% if gitlab_runner.pre_clone_script|default(false) %}
--pre-clone-script "{{ gitlab_runner.pre_clone_script }}"
{% endif %}
{% if gitlab_runner.pre_build_script|default(false) %}
--pre-build-script "{{ gitlab_runner.pre_build_script }}"
{% endif %}
{% if gitlab_runner.post_build_script|default(false) %}
--post-build-script "{{ gitlab_runner.post_build_script }}"
{% endif %}
--docker-image '{{ gitlab_runner.docker_image|default("alpine") }}'
{% if gitlab_runner.docker_privileged|default(false) %}
--docker-privileged
{% endif %}
{% if gitlab_runner.docker_tlsverify|default(false) %}
--docker-tlsverify '{{ gitlab_runner.docker_tlsverify|default("true") }}'
{% endif %}
{% if gitlab_runner.docker_dns|default(false) %}
--docker-dns '{{ gitlab_runner.docker_dns|default("1.1.1.1") }}'
{% endif %}
{% for volume in gitlab_runner.docker_volumes | default([]) %}
--docker-volumes "{{ volume }}"
{% endfor %}
--ssh-user '{{ gitlab_runner.ssh_user|default("") }}'
--ssh-host '{{ gitlab_runner.ssh_host|default("") }}'
--ssh-port '{{ gitlab_runner.ssh_port|default("") }}'
--ssh-password '{{ gitlab_runner.ssh_password|default("") }}'
--ssh-identity-file '{{ gitlab_runner.ssh_identity_file|default("") }}'
{% if gitlab_runner.cache_type is defined %}
--cache-type '{{ gitlab_runner.cache_type }}'
{% endif %}
{% if gitlab_runner.cache_shared|default(false) %}
--cache-shared
{% endif %}
{% if gitlab_runner.cache_path is defined %}
--cache-path '{{ gitlab_runner.cache_path }}'
{% endif %}
{% if gitlab_runner.cache_s3_server_address is defined %}
--cache-s3-server-address '{{ gitlab_runner.cache_s3_server_address }}'
{% if gitlab_runner.cache_s3_access_key is defined %}
--cache-s3-access-key '{{ gitlab_runner.cache_s3_access_key }}'
{% endif %}
{% if gitlab_runner.cache_s3_secret_key is defined %}
--cache-s3-secret-key '{{ gitlab_runner.cache_s3_secret_key }}'
{% endif %}
{% endif %}
{% if gitlab_runner.cache_s3_bucket_name is defined %}
--cache-s3-bucket-name '{{ gitlab_runner.cache_s3_bucket_name }}'
{% endif %}
{% if gitlab_runner.cache_s3_bucket_location is defined %}
--cache-s3-bucket-location '{{ gitlab_runner.cache_s3_bucket_location }}'
{% endif %}
{% if gitlab_runner.builds_dir|default(false) %}
--builds-dir '{{ gitlab_runner.builds_dir }}'
{% endif %}
{% if gitlab_runner.cache_dir|default(false) %}
--cache-dir '{{ gitlab_runner.cache_dir }}'
{% endif %}
{% if gitlab_runner.cache_s3_insecure|default(false) %}
--cache-s3-insecure
{% endif %}
{% if gitlab_runner.extra_registration_option is defined %}
{{ gitlab_runner.extra_registration_option }}
{% endif %}
when: (verified_runners.stderr.find("Verifying runner... is removed") != -1) or
((configured_runners.stderr.find('\n' + gitlab_runner.name|default(ansible_hostname+'-'+gitlab_runner_index|string)) == -1) and
(gitlab_runner.state|default('present') == 'present'))
no_log: true
become: "{{ gitlab_runner_system_mode }}"

View file

@ -1,5 +0,0 @@
---
- include: line-config-runner-windows.yml
loop: "{{ gitlab_runner.extra_configs[section] | list }}"
loop_control:
loop_var: line

View file

@ -1,5 +0,0 @@
---
- include: line-config-runner.yml
loop: "{{ gitlab_runner.extra_configs[section] | list }}"
loop_control:
loop_var: line

View file

@ -1,37 +0,0 @@
---
- name: Ensure /etc/systemd/system/gitlab-runner.service.d/ exists
become: yes
file:
path: /etc/systemd/system/gitlab-runner.service.d
state: directory
owner: root
group: root
mode: 0755
- name: Add reload command to GitLab Runner system service
become: yes
copy:
dest: /etc/systemd/system/gitlab-runner.service.d/exec-reload.conf
content: |
[Service]
ExecReload=/bin/kill -HUP $MAINPID
register: gitlab_runner_exec_reload
# https://docs.gitlab.com/runner/configuration/init.html#overriding-systemd
- name: Configure graceful stop for GitLab Runner system service
become: yes
copy:
dest: /etc/systemd/system/gitlab-runner.service.d/kill.conf
content: |
[Service]
TimeoutStopSec={{ gitlab_runner_timeout_stop_seconds }}
KillSignal=SIGQUIT
when: gitlab_runner_timeout_stop_seconds > 0
register: gitlab_runner_kill_timeout
- name: Force systemd to reread configs
become: yes
systemd:
daemon_reload: yes
when: gitlab_runner_exec_reload.changed or gitlab_runner_kill_timeout

View file

@ -1,339 +0,0 @@
---
- name: (Windows) Print "[[runners]]" section
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
line: '[[runners]]'
state: present
insertbefore: BOF
- name: (Windows) Set concurrent limit option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*limit =.*'
line: ' limit = {{ gitlab_runner.concurrent_specific|default(0) }}'
state: present
insertafter: '^\s*name ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set coordinator URL
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*url =.*'
line: ' url = {{ gitlab_runner_coordinator_url | to_json }}'
state: present
insertafter: '^\s*limit ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set clone URL
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*clone_url ='
line: ' clone_url = {{ gitlab_runner.clone_url | to_json }}'
state: present
insertafter: '^\s*url ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner
when: gitlab_runner.clone_url is defined
- name: (Windows) Set environment option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*environment =.*'
line: ' environment = {{ gitlab_runner.env_vars|default([]) | to_json }}'
state: present
insertafter: '^\s*url ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set pre_clone_script
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*pre_clone_script ='
line: ' pre_clone_script = {{ gitlab_runner.pre_clone_script | to_json }}'
state: present
insertafter: '^\s*url ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner
when: gitlab_runner.pre_clone_script is defined
- name: (Windows) Set pre_build_script
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*pre_build_script ='
line: ' pre_build_script = {{ gitlab_runner.pre_build_script | to_json }}'
state: present
insertafter: '^\s*url ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner
when: gitlab_runner.pre_build_script is defined
- name: (Windows) Set post_build_script
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*post_build_script ='
line: ' post_build_script = {{ gitlab_runner.post_build_script | to_json }}'
state: present
insertafter: '^\s*url ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner
when: gitlab_runner.post_build_script is defined
- name: (Windows) Set runner executor option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*executor =.*'
line: ' executor = {{ gitlab_runner.executor|default("shell") | to_json }}'
state: present
insertafter: '^\s*url ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set runner shell option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*shell =.*'
line: ' shell = {{ gitlab_runner.shell|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.shell is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set output_limit option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*output_limit =.*'
line: ' output_limit = {{ gitlab_runner.output_limit|default(4096) }}'
state: present
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set runner docker image option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*image =.*'
line: ' image = {{ gitlab_runner.docker_image|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.docker_image is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set docker privileged option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*privileged =.*'
line: ' privileged = {{ gitlab_runner.docker_privileged|default(false) | lower }}'
state: "{{ 'present' if gitlab_runner.docker_privileged is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set docker volumes option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*volumes =.*'
line: ' volumes = {{ gitlab_runner.docker_volumes|default([])|to_json }}'
state: "{{ 'present' if gitlab_runner.docker_volumes is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set cache type option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*Type =.*'
line: ' Type = {{ gitlab_runner.cache_type|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_type is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set cache path option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*Path =.*'
line: ' Path = {{ gitlab_runner.cache_path|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_path is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set cache s3 server addresss
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*ServerAddress =.*'
line: ' ServerAddress = {{ gitlab_runner.cache_s3_server_address|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_s3_server_address is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.s3\]'
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set cache s3 access key
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*AccessKey =.*'
line: ' AccessKey = {{ gitlab_runner.cache_s3_access_key|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_s3_access_key is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.s3\]'
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set cache s3 secret key
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*SecretKey =.*'
line: ' SecretKey = {{ gitlab_runner.cache_s3_secret_key|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_s3_secret_key is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.s3\]'
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set cache shared option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*Shared =.*'
line: ' Shared = {{ gitlab_runner.cache_shared|default("") | lower }}'
state: "{{ 'present' if gitlab_runner.cache_shared is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set cache s3 bucket name option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*BucketName =.*'
line: ' BucketName = {{ gitlab_runner.cache_s3_bucket_name|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_s3_bucket_name is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.s3\]'
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set cache s3 bucket location option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*BucketLocation =.*'
line: ' BucketLocation = {{ gitlab_runner.cache_s3_bucket_location|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_s3_bucket_location is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.s3\]'
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set cache s3 insecure option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*Insecure =.*'
line: ' Insecure = {{ gitlab_runner.cache_s3_insecure|default("") | lower }}'
state: "{{ 'present' if gitlab_runner.cache_s3_insecure is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.s3\]'
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set ssh user option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*user =.*'
line: ' user = {{ gitlab_runner.ssh_user|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.ssh_user is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set ssh host option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*host =.*'
line: ' host = {{ gitlab_runner.ssh_host|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.ssh_host is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set ssh port option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*port =.*'
line: ' port = {{ gitlab_runner.ssh_port|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.ssh_port is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set ssh password option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*password =.*'
line: ' password = {{ gitlab_runner.ssh_password|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.ssh_password is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set ssh identity file option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*identity_file =.*'
line: ' identity_file = {{ gitlab_runner.ssh_identity_file|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.ssh_identity_file is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set builds dir file option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*builds_dir =.*'
line: ' builds_dir = {{ gitlab_runner.builds_dir|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.builds_dir is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- name: (Windows) Set cache dir file option
win_lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*cache_dir =.*'
line: ' cache_dir = {{ gitlab_runner.cache_dir|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_dir is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify: restart_gitlab_runner_windows
- include: section-config-runner-windows.yml
loop: "{{ gitlab_runner.extra_configs|list }}"
loop_control:
loop_var: section
when:
- gitlab_runner.extra_configs is defined
- gitlab_runner.extra_configs|list|length > 0

View file

@ -1,578 +0,0 @@
---
- name: Set concurrent limit option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*limit ='
line: ' limit = {{ gitlab_runner.concurrent_specific|default(0) }}'
state: present
insertafter: '^\s*name ='
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set coordinator URL
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*url ='
line: ' url = {{ gitlab_runner_coordinator_url | to_json }}'
state: present
insertafter: '^\s*limit ='
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set clone URL
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*clone_url ='
line: ' clone_url = {{ gitlab_runner.clone_url | to_json }}'
state: present
insertafter: '^\s*url ='
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
when: gitlab_runner.clone_url is defined
- name: Set environment option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*environment ='
line: ' environment = {{ gitlab_runner.env_vars|default([]) | to_json }}'
state: present
insertafter: '^\s*url ='
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set pre_clone_script
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*pre_clone_script ='
line: ' pre_clone_script = {{ gitlab_runner.pre_clone_script | to_json }}'
state: present
insertafter: '^\s*url ='
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
when: gitlab_runner.pre_clone_script is defined
- name: Set pre_build_script
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*pre_build_script ='
line: ' pre_build_script = {{ gitlab_runner.pre_build_script | to_json }}'
state: present
insertafter: '^\s*url ='
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
when: gitlab_runner.pre_build_script is defined
- name: Set post_build_script
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*post_build_script ='
line: ' post_build_script = {{ gitlab_runner.post_build_script | to_json }}'
state: present
insertafter: '^\s*url ='
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
when: gitlab_runner.post_build_script is defined
- name: Set runner executor option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*executor ='
line: ' executor = {{ gitlab_runner.executor|default("shell") | to_json }}'
state: present
insertafter: '^\s*url ='
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set runner shell option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*shell ='
line: ' shell = {{ gitlab_runner.shell|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.shell is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set runner executor section
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*\[runners\.{{ gitlab_runner.executor|default("shell") }}\]'
line: ' [runners.{{ gitlab_runner.executor|replace("docker+machine","machine")|default("shell") }}]'
state: "{{ 'absent' if (gitlab_runner.executor|default('shell')) == 'shell' else 'present' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set output_limit option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*output_limit ='
line: ' output_limit = {{ gitlab_runner.output_limit|default(4096) }}'
state: present
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
#### [runners.docker] section ####
- name: Set runner docker image option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*image ='
line: ' image = {{ gitlab_runner.docker_image|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.docker_image is defined else 'absent' }}"
insertafter: '^\s*\[runners\.docker\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set docker privileged option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*privileged ='
line: ' privileged = {{ gitlab_runner.docker_privileged|default(false) | lower }}'
state: "{{ 'present' if gitlab_runner.docker_privileged is defined else 'absent' }}"
insertafter: '^\s*\[runners\.docker\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set docker tlsverify option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*tls_verify ='
line: ' tls_verify = {{ gitlab_runner.docker_tlsverify|default(false) | lower }}'
state: "{{ 'present' if gitlab_runner.docker_tlsverify is defined else 'absent' }}"
insertafter: '^\s*\[runners\.docker\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set docker DNS option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*dns ='
line: ' dns = {{ gitlab_runner.docker_dns|default(false) | to_json }}'
state: "{{ 'present' if gitlab_runner.docker_dns is defined else 'absent' }}"
insertafter: '^\s*\[runners\.docker\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set docker volumes option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*volumes ='
line: ' volumes = {{ gitlab_runner.docker_volumes|default([])|to_json }}'
state: "{{ 'present' if gitlab_runner.docker_volumes is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set runner docker network option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*network_mode ='
line: ' network_mode = {{ gitlab_runner.docker_network_mode|default("bridge") | to_json }}'
state: "{{ 'present' if gitlab_runner.docker_network_mode is defined else 'absent' }}"
insertafter: '^\s*\[runners\.docker\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
#### [runners.cache] section ####
- name: Set cache section
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*\[runners\.cache\]'
line: ' [runners.cache]'
state: present
insertafter: EOF
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set cache s3 section
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*\[runners\.cache\.s3\]'
line: ' [runners.cache.s3]'
state: "{{ 'present' if gitlab_runner.cache_type is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set cache gcs section
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*\[runners\.cache\.gcs\]'
line: ' [runners.cache.gcs]'
state: "{{ 'present' if gitlab_runner.cache_gcs_bucket_name is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set cache type option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*Type ='
line: ' Type = {{ gitlab_runner.cache_type|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_type is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set cache path option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*Path ='
line: ' Path = {{ gitlab_runner.cache_path|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_path is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set cache shared option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*Shared ='
line: ' Shared = {{ gitlab_runner.cache_shared|default("") | lower }}'
state: "{{ 'present' if gitlab_runner.cache_shared is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
#### [runners.cache.s3] section ####
- name: Set cache s3 server addresss
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*ServerAddress ='
line: ' ServerAddress = {{ gitlab_runner.cache_s3_server_address|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_s3_server_address is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.s3\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set cache s3 access key
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*AccessKey ='
line: ' AccessKey = {{ gitlab_runner.cache_s3_access_key|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_s3_access_key is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.s3\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set cache s3 secret key
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*SecretKey ='
line: ' SecretKey = {{ gitlab_runner.cache_s3_secret_key|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_s3_secret_key is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.s3\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set cache s3 bucket name option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*BucketName ='
line: ' BucketName = {{ gitlab_runner.cache_s3_bucket_name|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_s3_bucket_name is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.s3\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
when: gitlab_runner.cache_type is defined and gitlab_runner.cache_type == 's3'
- name: Set cache s3 bucket location option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*BucketLocation ='
line: ' BucketLocation = {{ gitlab_runner.cache_s3_bucket_location|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_s3_bucket_location is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.s3\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set cache s3 insecure option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*Insecure ='
line: ' Insecure = {{ gitlab_runner.cache_s3_insecure|default("") | lower }}'
state: "{{ 'present' if gitlab_runner.cache_s3_insecure is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.s3\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
#### [runners.cache.gcs] section ####
- name: Set cache gcs bucket name
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*BucketName ='
line: ' BucketName = {{ gitlab_runner.cache_gcs_bucket_name|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_gcs_bucket_name is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.gcs\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
when: gitlab_runner.cache_type is defined and gitlab_runner.cache_type == 'gcs'
- name: Set cache gcs credentials file
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*CredentialsFile ='
line: ' CredentialsFile = {{ gitlab_runner.cache_gcs_credentials_file|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_gcs_credentials_file is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.gcs\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set cache gcs access id
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*AccessID ='
line: ' AccessID = {{ gitlab_runner.cache_gcs_access_id|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_gcs_access_id is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.gcs\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set cache gcs private key
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*PrivateKey ='
line: ' PrivateKey = {{ gitlab_runner.cache_gcs_private_key|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_gcs_private_key is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.gcs\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
#### [runners.ssh] section #####
- name: Set ssh user option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*user ='
line: ' user = {{ gitlab_runner.ssh_user|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.ssh_user is defined else 'absent' }}"
insertafter: '^\s*\[runners\.ssh\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set ssh host option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*host ='
line: ' host = {{ gitlab_runner.ssh_host|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.ssh_host is defined else 'absent' }}"
insertafter: '^\s*\[runners\.ssh\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set ssh port option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*port ='
line: ' port = "{{ gitlab_runner.ssh_port|default("") | to_json }}"'
state: "{{ 'present' if gitlab_runner.ssh_port is defined else 'absent' }}"
insertafter: '^\s*\[runners\.ssh\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set ssh password option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*password ='
line: ' password = {{ gitlab_runner.ssh_password|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.ssh_password is defined else 'absent' }}"
insertafter: '^\s*\[runners\.ssh\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set ssh identity file option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*identity_file ='
line: ' identity_file = {{ gitlab_runner.ssh_identity_file|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.ssh_identity_file is defined else 'absent' }}"
insertafter: '^\s*\[runners\.ssh\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set builds dir file option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*builds_dir ='
line: ' builds_dir = {{ gitlab_runner.builds_dir|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.builds_dir is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Set cache dir file option
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*cache_dir ='
line: ' cache_dir = {{ gitlab_runner.cache_dir|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_dir is defined else 'absent' }}"
insertafter: '^\s*executor ='
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos
- name: Ensure directory permissions
file:
dest: "{{ item }}"
state: directory
owner: "{{ gitlab_runner_runtime_owner|default(omit) }}"
group: "{{ gitlab_runner_runtime_group|default(omit) }}"
mode: 0770
modification_time: preserve
access_time: preserve
recurse: yes
loop:
- "{{ gitlab_runner.builds_dir | default(\"\") }}"
- "{{ gitlab_runner.cache_dir | default(\"\") }}"
when: item|length
- name: Ensure directory access test
command: "/usr/bin/test -r {{ item }}"
loop:
- "{{ gitlab_runner.builds_dir | default(\"\") }}"
- "{{ gitlab_runner.cache_dir | default(\"\") }}"
when: item|length
changed_when: False
become: yes
become_user: "{{ gitlab_runner_runtime_owner|default(omit) }}"
register: ensure_directory_access
ignore_errors: true
- name: Ensure directory access fail on error
fail:
msg: "Error: user gitlab-runner failed to test access to {{ item.item }}. Check parent folder(s) permissions"
loop: "{{ ensure_directory_access.results }}"
when:
- item.rc is defined and item.rc != 0
- include: section-config-runner.yml
loop: "{{ gitlab_runner.extra_configs|list }}"
loop_control:
loop_var: section
when:
- gitlab_runner.extra_configs is defined
- gitlab_runner.extra_configs|list|length > 0

View file

@ -1,69 +0,0 @@
from __future__ import print_function
import os
import sys
import logging
import random
from flask import Flask, Blueprint, request, jsonify
app = Flask(__name__)
bp = Blueprint(__name__, 'api', url_prefix='/api/v4')
@bp.route('/runners', methods=['POST'])
def register_runner():
logging.info("Got register_runner request: {!r}".format(request.data))
req = request.json
res = {}
token = req['token']
if token.isalnum() and token.islower():
res['token'] = "{}{}".format(token.upper(), random.randint(100, 999))
status = 201
elif token.isalnum() and token.isupper():
status = 403
else:
status = 400
return jsonify(res), status
@bp.route('/runners/verify', methods=['POST'])
def verify_runner():
logging.info("Got verify_runner request: {!r}".format(request.data))
req = request.json
res = {}
token = req['token']
if token.isalnum() and token.isupper():
status = 200
elif token.isalnum() and token.islower():
status = 403
else:
status = 400
return jsonify(res), status
app.register_blueprint(bp)
if __name__ == '__main__':
pid = str(os.getpid())
pidfile = os.path.expanduser(sys.argv[1])
if os.path.isfile(pidfile):
print("{} already exists, exiting".format(pidfile))
sys.exit(1)
port = int(sys.argv[2])
with open(pidfile, 'w') as f:
f.write(pid)
logging.basicConfig(level=logging.DEBUG)
try:
app.run(port=port, debug=False)
finally:
os.unlink(pidfile)

View file

@ -1 +0,0 @@
localhost ansible_connection=local

View file

@ -1,51 +0,0 @@
---
- hosts: localhost
tasks:
- name: Load platform-specific variables
include_vars: "{{ lookup('first_found', possible_files) }}"
vars:
possible_files:
files:
- '{{ ansible_distribution }}.yml'
- '{{ ansible_os_family }}.yml'
- default.yml
paths:
- 'vars'
- name: Copy the mock gitlab CI server
copy:
src: mock_gitlab_runner_ci.py
dest: "~/mock_gitlab_runner_ci.py"
when: run_mock_server
- name: Ensure mock CI pidfile is absent
file:
path: "~/mock_ci.pid"
state: absent
when: run_mock_server
- name: Start the mock CI
shell: "python ~/mock_gitlab_runner_ci.py ~/mock_ci.pid 6060 >~/mock_ci.log 2>&1"
async: 3600
poll: 0
register: mock_server
when: run_mock_server
- name: Wait for pidfile to be created
wait_for:
host: 127.0.0.1
port: 6060
delay: 1
timeout: 30
when: run_mock_server
- hosts: localhost
roles:
- ansible-gitlab-runner
- hosts: localhost
tasks:
- name: Get pid mock gitlab CI server
slurp:
src: "~/mock_ci.pid"
register: pidfile_b64
when: run_mock_server
- name: kill the mock CI
command: "kill {{ pidfile_b64.content | b64decode }}"
when: run_mock_server

View file

@ -1,18 +0,0 @@
# Creating local ansible user
$secpwd = ConvertTo-SecureString "Ans1ble_User!" -AsPlainText -Force
New-LocalUser "ansible" -Password $secpwd -FullName "ansible" -Description "ansible user"
Add-LocalGroupMember -Group "Administrators" -Member "ansible"
# Install Ubuntu 1804 on WSL
& choco install -y --ignore-checksums wsl-ubuntu-1804
# Install Ansbile
& C:/Windows/System32/bash.exe -c "export DEBIAN_FRONTEND=noninteractive && apt update && apt install -y python3 python3-pip"
& wsl pip3 install ansible pywinrm
# Prepare system that it can be accessed by ansible
$url = "https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
$file = "$env:temp\ConfigureRemotingForAnsible.ps1"
(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)
powershell.exe -ExecutionPolicy ByPass -File $file

View file

@ -1,48 +0,0 @@
gitlab_runner_runners:
- name: "Shell Runner"
tags:
- windows
- shell
executor: shell
state: present
- name: "Shell Bash Runner"
tags:
- windows
- shell
- bash
executor: shell
shell: bash
state: present
- name: "Shell Cmd Runner"
tags:
- windows
- shell
- cmd
executor: shell
shell: cmd
state: present
- name: "Shell Runner S3 Cache"
tags:
- windows
- shell
executor: shell
cache_type: s3
cache_shared: true
cache_s3_server_address: mycache.example.com
cache_s3_access_key: myaccess-key
cache_s3_secret_key: mysecret-key
cache_s3_bucket_name: build-cache-bucket
cache_s3_insecure: false
state: present
- name: "Docker Runner"
tags:
- windows
- docker
executor: docker-windows
state: present
gitlab_runner_listen_address: '0.0.0.0:9001'
run_mock_server: no
gitlab_runner_coordinator_url: "http://localhost:7070/"
gitlab_runner_registration_token: ''

View file

@ -1,57 +0,0 @@
---
gitlab_runner_runners:
- name: 'vagrant-shell'
executor: shell
tags:
- node
- ruby
- mysql
- name: 'vagrant-shell-sh'
executor: shell
shell: sh
tags:
- sh
- name: 'vagrant-docker'
executor: docker
docker_image: 'docker:stable'
tags:
- node
- ruby
- mysql
- name: 'vagrant-docker-cache'
executor: docker
docker_image: 'docker:stable'
tags:
- node
- ruby
- mysql
- cache
cache_type: s3
cache_shared: true
cache_s3_server_address: mycache.example.com
cache_s3_access_key: myaccess-key
cache_s3_secret_key: mysecret-key
cache_s3_bucket_name: build-cache-bucket
cache_s3_insecure: false
- name: 'vagrant-docker-cache-gcs'
executor: docker
docker_image: 'docker:stable'
tags:
- node
- ruby
- mysql
- cache
cache_type: gcs
cache_shared: true
cache_gcs_bucket_name: gcs-cache-bucket
cache_gcs_credentials_file: '/etc/gitlab-runner/credentials.json'
cache_gcs_access_id: 'cache-access-account@project.iam.gserviceaccount.com'
cache_gcs_private_key: "-----BEGIN PRIVATE KEY-----\nXXXXXX\n-----END PRIVATE KEY-----\n"
run_mock_server: yes
gitlab_runner_coordinator_url: "http://localhost:6060/"
gitlab_runner_registration_token: 'notreal'
gitlab_runner_system_mode: yes
...

View file

@ -1,5 +0,0 @@
---
gitlab_runner_download_url: 'https://gitlab-runner-downloads.s3.amazonaws.com/{{ gitlab_runner_wanted_tag }}/binaries/gitlab-runner-darwin-amd64'
gitlab_runner_executable: "/usr/local/bin/{{ gitlab_runner_package_name }}"

View file

@ -1,8 +0,0 @@
---
gitlab_runner_executable: "/usr/bin/{{ gitlab_runner_package_name }}"
gitlab_runner_runtime_owner: gitlab-runner
gitlab_runner_runtime_group: gitlab-runner
gitlab_runner_restart_state: reloaded
gitlab_runner_timeout_stop_seconds: 720

View file

@ -1,8 +0,0 @@
---
gitlab_runner_executable: "/usr/bin/{{ gitlab_runner_package_name }}"
gitlab_runner_runtime_owner: gitlab-runner
gitlab_runner_runtime_group: gitlab-runner
gitlab_runner_restart_state: reloaded
gitlab_runner_timeout_stop_seconds: 7200

View file

@ -1,9 +0,0 @@
---
gitlab_runner_download_url: 'https://gitlab-runner-downloads.s3.amazonaws.com/{{ gitlab_runner_wanted_tag }}/binaries/gitlab-runner-windows-amd64.exe'
gitlab_runner_install_directory: "c:/gitlab-runner/"
gitlab_runner_config_file_location: "{{ gitlab_runner_install_directory }}"
gitlab_runner_config_file: "{{ gitlab_runner_config_file_location }}/config.toml" # on Windows
gitlab_runner_executable: "{{gitlab_runner_install_directory}}/{{ gitlab_runner_package_name }}.exe"

View file

@ -1,7 +0,0 @@
---
gitlab_runner_container_install: false
gitlab_runner_container_image: gitlab/gitlab-runner
gitlab_runner_container_tag: latest
gitlab_runner_container_name: gitlab-runner
gitlab_runner_container_restart_policy: unless-stopped
gitlab_runner_restart_state: restarted

View file

@ -1,6 +0,0 @@
---
# vars file for gitlab-runner
# Useful default paths for config files on Mac/Linux platforms
__gitlab_runner_config_file_system_mode: "/etc/gitlab-runner/config.toml"
__gitlab_runner_config_file_user_mode: "~/.gitlab-runner/config.toml"