All Projects → riemers → Ansible Gitlab Runner

riemers / Ansible Gitlab Runner

Licence: mit
Ansible role to install gitlab-runner

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Ansible Gitlab Runner

Ansible Role Gitlab
Ansible Role - GitLab
Stars: ✭ 459 (+220.98%)
Mutual labels:  ansible, role, gitlab
Ansible Role Seafile
An ansible role to deploy Seafile, an Open Source Cloud Storage. http://seafile.com/
Stars: ✭ 38 (-73.43%)
Mutual labels:  ansible, role
Ansible Role Php Xdebug
Ansible Role - PHP Xdebug
Stars: ✭ 34 (-76.22%)
Mutual labels:  ansible, role
Ansible Role Memcached
Ansible Role - Memcached
Stars: ✭ 54 (-62.24%)
Mutual labels:  ansible, role
Ansible Transmission
🕹 A TransmissionBT installation role for Ansible
Stars: ✭ 8 (-94.41%)
Mutual labels:  ansible, role
Ansible Role Docker
Ansible Role - Docker
Stars: ✭ 845 (+490.91%)
Mutual labels:  ansible, role
Ansible Role Dotfiles
Ansible Role - Easy and flexible dotfile installation.
Stars: ✭ 133 (-6.99%)
Mutual labels:  ansible, role
Ansible Ssh Hardening
This Ansible role provides numerous security-related ssh configurations, providing all-round base protection.
Stars: ✭ 746 (+421.68%)
Mutual labels:  ansible, role
Aws Securitygroup Grapher
This ansible role gets information from an AWS VPC and generate a graphical representation of security groups
Stars: ✭ 93 (-34.97%)
Mutual labels:  ansible, role
Ansible Role Logstash
Ansible Role - Logstash
Stars: ✭ 136 (-4.9%)
Mutual labels:  ansible, role
Ansible Role Nfs
Ansible Role - NFS
Stars: ✭ 141 (-1.4%)
Mutual labels:  ansible, role
Ansible Role Htpasswd
Ansible Role - htpasswd
Stars: ✭ 17 (-88.11%)
Mutual labels:  ansible, role
Ansible Role Mysql
Ansible Role - MySQL
Stars: ✭ 826 (+477.62%)
Mutual labels:  ansible, role
Ansible Role Munin
Ansible Role - Munin
Stars: ✭ 27 (-81.12%)
Mutual labels:  ansible, role
Opscloud
运维管理平台(阿里云),自动同步阿里云配置信息,堡垒机(容器),批量运维,Kubernetes,Zabbix管理等功能
Stars: ✭ 788 (+451.05%)
Mutual labels:  ansible, gitlab
Ansible Role Packer rhel
Ansible Role - Packer RHEL/CentOS Configuration for Vagrant VirtualBox
Stars: ✭ 45 (-68.53%)
Mutual labels:  ansible, role
Ansible Role Haproxy
Ansible Role - HAProxy
Stars: ✭ 112 (-21.68%)
Mutual labels:  ansible, role
Ansible Role Jenkins
Ansible Role - Jenkins CI
Stars: ✭ 689 (+381.82%)
Mutual labels:  ansible, role
Op Note
当我有服务器时我做了什么 · 个人服务器运维指南
Stars: ✭ 733 (+412.59%)
Mutual labels:  ansible, gitlab
Ansible Role Ruby
Ansible Role - Ruby
Stars: ✭ 77 (-46.15%)
Mutual labels:  ansible, role

GitLab Runner Build Status Ansible Role

This role will install the official 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 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:

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 we’re 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:

See the config for more options

Example Playbook

- hosts: all
  become: true
  vars_files:
    - vars/main.yml
  roles:
    - { role: riemers.gitlab-runner }

Inside vars/main.yml

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:

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 you’re using Docker Machine, it’s 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 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

  • Gastrofix for adding Mac Support
  • Matthias Schmieder for adding Windows Support
  • dniwdeus & rosenstrauch for adding AWS autoscale option
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].