Skip to content

Instalacja Gitlab Runner

W tym wpisie pokażę krok po kroku, jak instaluję GitLab Runnera w praktycznym, produkcyjnym scenariuszu. Skupię się na sprawdzonym podejściu, które stosuję na co dzień — bez zbędnej teorii, za to z naciskiem na poprawną konfigurację, bezpieczeństwo i typowe pułapki, na które łatwo trafić przy pierwszym uruchomieniu runnera.

Jeśli korzystasz z GitLaba do automatyzacji procesów CI/CD i chcesz mieć pełną kontrolę nad tym, gdzie i jak wykonywane są joby, ten materiał jest właśnie dla Ciebie.


  1. Definicja hostów

    ---
    all:
      children:
        gitlab_runner:
          children:
            nodes:
              hosts:
                ct01002:
                ct01003:
                ct01004:

    ost_vars/ct01002/gitlab-runner.yml

    ---
    inv_host_gitlab_runner_configuration:
      concurrent: 100
      check_interval: 0
      shutdown_timeout: 0
      session_timeout: 3600
      runners:
        - name: "{{ inventory_hostname }}.gitlab"
          url: "https://gitlab.com"
          register_runner:
            id: 50857897
            token: "{{ lookup('community.hashi_vault.vault_kv2_get', 'pl.rachuna-net/infrastructure/gitlab-rachuna-net/ansible', engine_mount_point='kv-gitlab')['secret']['ct01002.gitlab.com'] }}"
            register_gitlab_api_token: "{{ lookup('community.hashi_vault.vault_kv2_get', 'pl.rachuna-net/auth/gitlab-com', engine_mount_point='kv-gitlab')['secret']['GITLAB_TOKEN'] }}"
            description: "GitLab Runner for pl.rachuna-net"
            tag_list: ["gitlab-rnp"]
            runner_type: "group_type"
            group_id: 105046057
            access_level: "not_protected"
          executor: "docker"
          docker:
            tls_verify: false
            image: "docker:latest"
            privileged: true
            disable_entrypoint_overwrite: false
            oom_kill_disable: false
            disable_cache: false
            volumes:
              - "/cache:/cache"
              - "/var/run/docker.sock:/var/run/docker.sock"
            shm_size: 0
            network_mode: "host"