runner is re-registered on subsequent plays (system vs user mode)
Hi, I am having issues with my runner getting re-registered every time I run my playbook. This is kinda related to issue https://github.com/riemers/ansible-gitlab-runner/issues/89.
Setup: macos riemers v1.6.29 ansible 2.10.3
In my case, I don't want to run in system mode so I have defined:
gitlab_runner_system_mode: no (from https://github.com/riemers/ansible-gitlab-runner/pull/113)
When I run my playbook there are some checks (in Unix.yml) that show it is looking at the config.toml in the system path and not the user path:
TASK [riemers.gitlab-runner : (Unix) List configured runners] **************************************************************** ok: [my-runner] => { "changed": false, "cmd": [ "/usr/local/bin/gitlab-runner", "list" ], "delta": "0:00:00.019475", "end": "2021-03-09 13:54:14.513810", "invocation": { "module_args": { "_raw_params": "/usr/local/bin/gitlab-runner list", "_uses_shell": false, "argv": null, "chdir": null, "creates": null, "executable": null, "removes": null, "stdin": null, "stdin_add_newline": true, "strip_empty_ends": true, "warn": true } }, "rc": 0, "start": "2021-03-09 13:54:14.494335", "stderr": "Runtime platform \u001b[0;m arch\u001b[0;m=amd64 os\u001b[0;m=darwin pid\u001b[0;m=2143 revision\u001b[0;m=2ebc4dc4 version\u001b[0;m=13.9.0\nListing configured runners \u001b[0;m ConfigFile\u001b[0;m=**/etc/gitlab-runner/config.toml**", "stderr_lines": [ "Runtime platform \u001b[0;m arch\u001b[0;m=amd64 os\u001b[0;m=darwin pid\u001b[0;m=2143 revision\u001b[0;m=2ebc4dc4 version\u001b[0;m=13.9.0", "Listing configured runners \u001b[0;m ConfigFile\u001b[0;m=/etc/gitlab-runner/config.toml" ], "stdout": "", "stdout_lines": [] }
TASK [riemers.gitlab-runner : (Unix) Check runner is registered] ******************************************************************* ok: [my-runner] => { "changed": false, "cmd": [ "/usr/local/bin/gitlab-runner", "verify" ], "delta": "0:00:00.021603", "end": "2021-03-09 13:54:16.491628", "invocation": { "module_args": { "_raw_params": "/usr/local/bin/gitlab-runner verify", "_uses_shell": false, "argv": null, "chdir": null, "creates": null, "executable": null, "removes": null, "stdin": null, "stdin_add_newline": true, "strip_empty_ends": true, "warn": true } }, "rc": 0, "start": "2021-03-09 13:54:16.470025", "stderr": "Runtime platform \u001b[0;m arch\u001b[0;m=amd64 os\u001b[0;m=darwin pid\u001b[0;m=2166 revision\u001b[0;m=2ebc4dc4 version\u001b[0;m=13.9.0\n**Running in system-mode**. \u001b[0;m \n \u001b[0;m ", "stderr_lines": [ "Runtime platform \u001b[0;m arch\u001b[0;m=amd64 os\u001b[0;m=darwin pid\u001b[0;m=2166 revision\u001b[0;m=2ebc4dc4 version\u001b[0;m=13.9.0", "Running in system-mode. \u001b[0;m ", " \u001b[0;m " ], "stdout": "", "stdout_lines": [] }
If I am not mistaken, I think the fix for this would be to change become: yes to become: "{{ gitlab_runner_system_mode }}" in tasks/Unix.yml. If this makes sense to others please let me know and I'd be glad to submit a PR.
Thanks!
I did a quick test by modifying the 2 tasks as mentioned above and then re-running my playbook and my runner was not registered all over again as expected
If you tested it and it now works ok, then just do a PR. Only way to find out for sure ;)
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 ;)