Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runner is not being unregistered from Gitlab instance, when setting state: absent #324

Closed
michaelmell opened this issue Mar 27, 2024 · 2 comments
Labels

Comments

@michaelmell
Copy link

michaelmell commented Mar 27, 2024

Intro

I am having an issue with Gitlab runner not being unregistered correctly from
the Gitlab instance when setting state from present to absent.

Please see the details under Error description.

Info about the environment

Ansible version

$ ansible --version
ansible [core 2.15.8]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/micha/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/micha/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.6 (main, Oct  8 2023, 05:06:43) [GCC 13.2.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Gitlab-runner role version

---
roles:
  # install role to deploy Gitlab runners:
  # https://galaxy.ansible.com/ui/standalone/roles/riemers/gitlab-runner
  - name: riemers.gitlab-runner
    version: "v2.0.3"

Playbook

- name: Install Gitlab runners
  become: true
  hosts: cicd01
  vars_files:
    - vars/gitlab_runners.yml
  roles:
    - riemers.gitlab-runner

Content of vars/gitlab_runners.yml is shown in the following section

Error description

This is the configuration:

gitlab_runner_container_install: true
gitlab_runner_container_image: gitlab/gitlab-runner
gitlab_runner_container_tag: v16.9.1
gitlab_runner_container_name: gitlab-runner
# config-directory that is mounted into the container and store the config.toml
gitlab_runner_container_mount_path: "/etc/gitlab-runner"

gitlab_runner_runners:
- name: "gitlab_runner_1"
	description: "Project: gitlab-runner-dind-tutorial"
	state: present
	url: "{{ gitlab_url }}"
	token: "{{ gitlab_prj_token__gitlab_runner_dind_tutorial }}"
	executor: docker
	docker_image: "docker:stable"

It creates and configures the Gitlab runner in /etc/gitlab/config.toml
and registers it with our self-hosted Gitlab instance (as expected).

When I now change state configuration to absent, i.e.:

state: absent

it removes the runner configuration from /etc/gitlab/config.toml.

But it does not unregister/remove the runner from the Gitlab instance.
(It is still shown under Settings -> CI/CD -> Project runners)

Furthermore, setting state back to present will register the runner again,
so that it now exists twice in the Project runner section of the Gitlab
instance.

Is this expected behavior?

@riemers
Copy link
Owner

riemers commented Apr 24, 2024

I would say no, but check the code if it does a call to 'unregister' if the state is absent. If this is not there you could use the same call to register to unregister and add a task for that.

Copy link

Seems this message did not get a lot of love. This does not mean it was not seen but time wise might not have made it to proper attention. This is just the clean up action ;)

@github-actions github-actions bot added the Stale label May 25, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants