Skip to content

fix: by_config_toml: duplicate [runners.feature_flags] when an unmanaged - #445

Merged
LoniasGR merged 1 commit into
riemers:masterfrom
FroggitFR:3-by_config_toml-duplicate-runnersfeature_flags-when-an-unmanaged-section-already-exists
Sep 7, 2026
Merged

fix: by_config_toml: duplicate [runners.feature_flags] when an unmanaged#445
LoniasGR merged 1 commit into
riemers:masterfrom
FroggitFR:3-by_config_toml-duplicate-runnersfeature_flags-when-an-unmanaged-section-already-exists

Conversation

@cchaudier

@cchaudier cchaudier commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Fix and closed #444

section already exists

Log before fix

TASK [riemers.ansible-gitlab-runner : Set feature flag options conf[11/14]: runner[1/2]:] ******************************************************
changed: [runner2.int.frogg.it]

(...)

TASK [riemers.ansible-gitlab-runner : Assemble new config.toml] ********************************************************************************
fatal: [runner2.int.frogg.it]: FAILED! => {"changed": false, "msg": "failed to validate: rc:1 error:Runtime platform                                  \u001b[0;m  arch\u001b[0;m=amd64 os\u001b[0;m=linux pid\u001b[0;m=991672 revision\u001b[0;m=6821ab40 version\u001b[0;m=19.2.3\nRunning in system-mode.                           \u001b[0;m \n                                                  \u001b[0;m \n\u001b[31;1mFATAL: decoding configuration file: toml: line 87 (last key \"runners\"): Key 'runners.feature_flags' has already been defined.\u001b[0;m \n"}

Log after fix

TASK [riemers.ansible-gitlab-runner : Remove unmanaged feature flag section conf[12/14]: runner[2/2]:] *****************************************
changed: [runner2.int.frogg.it]

TASK [riemers.ansible-gitlab-runner : Set feature flag options conf[12/14]: runner[2/2]:] ******************************************************
changed: [runner2.int.frogg.it]

(...)

TASK [riemers.ansible-gitlab-runner : Assemble new config.toml] ********************************************************************************
changed: [runner2.int.frogg.it]

The generated file config.toml is correct.

I didn't write the tests because I'm not comfortable with molecules.
But tested on my today's deploy.

@LoniasGR

LoniasGR commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Hi, thank you for your time creating the patch. I just wanted to clarify something. The section [runners.feature_flags] already existed in your config.toml and was unrelated to the role, correct? It wasn't the role that created this configuration in the first place.

I'm asking so to keep in mind if we should tackle this problem elsewhere as well.

@cchaudier

Copy link
Copy Markdown
Contributor Author

Thanks for checking. No, the existing section was not unrelated to the role.

The entire config.toml, including the [runners.feature_flags] sections, was generated and managed by this role. We have been using the role for a long time, and these sections were not added or modified manually.

The issue appeared when I renamed two runners, both in GitLab and in my Ansible configuration. Everything worked correctly before that change.

My understanding is that the rename caused a registration/unregistration operation that rewrote config.toml. GitLab Runner removes comments when rewriting this file, including the # BEGIN/END runners.feature_flags markers, while preserving the [runners.feature_flags] sections themselves.

On the following by_config_toml update, blockinfile could no longer recognize those sections as already managed and appended new ones, resulting in the duplicate TOML tables.

So I think the runner rename and register/unregister paths are indeed worth checking. However, the original configuration and feature flag sections were created by the role, not by an external or manual configuration.

@LoniasGR

LoniasGR commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Thank you for your explanation. This kind of workflow might need a bit of work down the line to be supported, because right now renaming runners does create problems. I am merging this and keeping the problem as a thing to keep in mind.

@LoniasGR
LoniasGR merged commit b4d35c3 into riemers:master Sep 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

by_config_toml: duplicate [runners.feature_flags] when an unmanaged section already exists

2 participants