almaops.ct_gitlab_runner

almaops.ct_gitlab_runner

This role installs the GitLab runner using a Docker container and registers it with GitLab.

Role Variables

  • ct_gitlab_runner_name: Name displayed on the runners page. Default is "{{ inventory_hostname }}".

  • ct_gitlab_runner_ct_name: Name of the container. Default is "gitlab-runner". Change this if you plan to run multiple runners on the same host.

  • ct_gitlab_runner_registration_token: Token required for registration. Obtain it from the project for specific runners or from the admin panel for shared runners. This is a required parameter, no default.

  • ct_gitlab_runner_coordinator_url: URL of your GitLab instance. Default is "https://gitlab.com/ci". Change it if you’re using a self-hosted GitLab.

  • ct_gitlab_runner_tags: Tags for the runner. Default is [].

  • ct_gitlab_runner_executor: Executor type. Default is "docker", which is the easiest option. Other executors haven’t been tested.

  • ct_gitlab_runner_parallel_builds_number: Default is "1".

  • ct_gitlab_runner_run_untagged: Set if the runner should handle untagged jobs. Default is "true".

  • ct_gitlab_runner_docker_image: Default is "alpine".

  • ct_gitlab_runner_path_srv_dir: Base directory for service configs. Default is "/srv".

  • ct_gitlab_runner_path_cfg_dir: Directory where service configs are stored. Default is "{{ ct_gitlab_runner_path_srv_dir }}/{{ ct_gitlab_runner_ct_name }}/config".

  • ct_gitlab_runner_path_cfg: Runner config file. Default is "{{ ct_gitlab_runner_path_cfg_dir }}/config.toml". Do not change this; it really is config.toml.

  • ct_gitlab_runner_ct_image_tag: Version of the runner (GitLab runner's image tag). Default is "alpine".

  • ct_gitlab_runner_ct_image: Container image for the GitLab runner. Default is "gitlab/gitlab-runner:{{ ct_gitlab_runner_ct_image_tag }}". Change it only for a custom build of the GitLab runner.

  • ct_gitlab_runner_ct_restart_policy: Policy for restarting the container. Default is "always".

  • ct_gitlab_runner_ct_state: State of the container after deployment. Default is "started".

  • ct_gitlab_runner_ct_restart: Whether to restart the container after deployment. Default is "false".

  • ct_gitlab_runner_ct_pull: Whether to pull the image when deploying. Default is "false".

  • ct_gitlab_runner_ct_recreate: Whether to recreate the container. Default is "false".

  • ct_gitlab_runner_cache_s3_enabled: Indicates if S3/Minio is used for caching. Default is false.

  • ct_gitlab_runner_cache_s3_server_address: Address of the S3 server. Required if S3 is enabled, no default.

  • ct_gitlab_runner_cache_s3_access_key: Access key for S3. Required if S3 is enabled, no default.

  • ct_gitlab_runner_cache_s3_secret_key: Secret key for S3. Required if S3 is enabled, no default.

  • ct_gitlab_runner_force_reg: Whether to force re-registration of this runner. Default is false.

  • ct_gitlab_runner_docker_volumes: Additional mounts for containers run by the Docker executor. Default is [], useful for passing docker.sock or mounting /cache volume.

  • ct_gitlab_runner_dind_enabled: Set to true if Docker containers need to run in privileged mode. Default is false.

  • ct_gitlab_runner_ct_volumes: Mounts the config directory into the runner container by default, i.e. [ "{{ ct_gitlab_runner_path_cfg_dir }}:/etc/gitlab-runner:rw" ].

  • ct_gitlab_runner_dond_enabled: If set to true (which is the default), it also shares /var/run/docker.sock with the runner container.

There are more interesting variables to explore. Check them out in: defaults/main.yml.

Example Playbook

- hosts:
    - gitlab_runners
  become: true
  vars:
    # common configuration
    ct_gitlab_runner_ct_image_tag: "v14.8.1"
    ct_gitlab_runner_cache_s3_enabled: true
    ct_gitlab_runner_cache_s3_server_address: "{{ minio_bind_ip }}:{{ minio_bind_port }}"
    ct_gitlab_runner_cache_s3_access_key: "{{ minio_access_key }}"
    ct_gitlab_runner_cache_s3_secret_key: "{{ minio_secret_key }}"
    ct_gitlab_runner_name: "{{ runner_name }}_{{ inventory_hostname }}"
    gitlab_runner_ct_name: "gitlab-runner_{{ runner_name }}"
    # tokens
    main_registration_token: "<...>"
    proj_registration_token: "<...>"
  roles:
    - role: almaops.ct_gitlab_runner
      tags:
        - runner-tag-common
      vars:
        runner_name: "common"
        ct_gitlab_runner_registration_token: "{{ main_registration_token }}"
        ct_gitlab_runner_parallel_builds_number: "3"
        ct_gitlab_runner_tags:
          - common
    - role: almaops.ct_gitlab_runner
      tags:
        - runner-tag-proj
      vars:
        runner_name: "proj"
        ct_gitlab_runner_registration_token: "{{ proj_registration_token }}"
        ct_gitlab_runner_parallel_builds_number: "1"
        ct_gitlab_runner_run_untagged: "false"
        ct_gitlab_runner_tags:
          - proj

License

MIT

Author Information

Dmitrii Kashin, freehck@freehck.com

Informazioni sul progetto

deploy gitlab-runner in docker container and register it

Installa
ansible-galaxy install almaops.ct_gitlab_runner
Licenza
Unknown
Download
668
Proprietario
Premium IT Consulting