voxpupuli / puppet-gitlab_ci_runner

Module to mange gitlab CI runners. Extracted from https://github.com/voxpupuli/puppet-gitlab
Apache License 2.0
14 stars 52 forks source link

unable to add runners after module upgrade. #126

Closed madelaney closed 2 years ago

madelaney commented 2 years ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

gitlab_ci_runner.yaml

---
gitlab_ci_runner::check_interval: 4
gitlab_ci_runner::concurrent: 4
gitlab_ci_runner::config_path: "/etc/gitlab-runner/config.toml"
gitlab_ci_runner::manage_docker: true
gitlab_ci_runner::metrics_server: localhost:8888
gitlab_ci_runner::runner_defaults:
  builds_dir: "/var/run/gitlab-runner/builds"
  cache_dir: "/var/run/gitlab-runner/cache"
  docker: 
    image: ubuntu:focal
  executor: docker
  registration-token: "%{hiera('gitlab::runner::token')}"
  tag-list: docker,%{::datacenter}
  url: https://gitlab.<domain>.com/ci
gitlab_ci_runner::runners:
  0ca6ceb2-9d56-4413-8fe7-60d9fc3110fb: {}
  4c156b10-5934-4843-a766-e39a1439f5c7: {}
  b9361143-8141-41ec-a1a8-c7843f2e5d24: {}
  e2139a8c-eb16-4a2d-ac09-2b48a0825ca2: {}
  e44c3545-e110-420d-85fe-7a42eb2d4c42: {}

glrunnr01.yml

---
classes:
- gitlab_ci_runner

What are you seeing

When puppet tried to apply and thus create the runner in the application.log of Gitlab, I see:

Completed 200 OK in 88ms (Views: 0.4ms | ActiveRecord: 13.7ms | Elasticsearch: 0.0ms | Allocations: 27723)
Started POST "/ci/api/v4/runners" for 10.5.200.10 at 2021-09-17 11:58:30 -0400
Processing by Gitlab::RequestForgeryProtection::Controller#index as HTML
Can't verify CSRF token authenticity.
Completed 422 Unprocessable Entity in 1ms (ActiveRecord: 0.0ms | Elasticsearch: 0.0ms | Allocations: 151)

In the puppet run, I see:

Error: Failed to apply catalog: Gitlab runner failed to register: Unprocessable Entity

What behaviour did you expect instead

I expect that the runners get applied.

Output log

Any additional information you'd like to impart

If I revert the module to v3.0.0, and change hiera (back to the old format), the runners are created.

This is the hiera that is working under v3.0.0 of the module:

---
gitlab_ci_runner::check_interval: 4
gitlab_ci_runner::concurrent: 4
gitlab_ci_runner::config_path: "/etc/gitlab-runner/config.toml"
gitlab_ci_runner::manage_docker: true
gitlab_ci_runner::metrics_server: localhost:8888
gitlab_ci_runner::runner_defaults:
  builds_dir: "/var/run/gitlab-runner/builds"
  cache_dir: "/var/run/gitlab-runner/cache"
  docker-image: ubuntu:focal
  executor: docker
  registration-token: "%{hiera('gitlab::runner::token')}"
  tag-list: docker,%{::datacenter}
  url: https://gitlab.<domain>.com/ci
gitlab_ci_runner::runners:
  0ca6ceb2-9d56-4413-8fe7-60d9fc3110fb: {}
  4c156b10-5934-4843-a766-e39a1439f5c7: {}
  b9361143-8141-41ec-a1a8-c7843f2e5d24: {}
  e2139a8c-eb16-4a2d-ac09-2b48a0825ca2: {}
  e44c3545-e110-420d-85fe-7a42eb2d4c42: {}
dimov-cz commented 2 years ago

https://gitlab.<domain>.com/ci

You have wrong URL. The "ci" in path to API was deprecated. https://gitlab.com/gitlab-org/gitlab-foss/-/issues/27585

smortex commented 2 years ago

@dimov-cz good catch! @madelaney have you tried this? I had a similar error and fixing the url did the trick in my case. Please reopen if it does not fix your issue.