Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit 8687b26

Browse files
Merge pull request #84 from tobiashuste/feature-flags
Allow to set GitLab feature flags
2 parents d2ee1c0 + ddb12c5 commit 8687b26

File tree

5 files changed

+56
-2
lines changed

5 files changed

+56
-2
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,24 @@ Choose whether GitLab's web-server Nginx redirects HTTP requests to HTTPS:
198198
nginx_redirect_http_to_https: 'false'
199199
```
200200
201+
#### Set GitLab feature flags
202+
203+
Set [GitLab feature flags](https://docs.gitlab.com/ee/user/feature_flags.html)
204+
to enable or disable additional features.
205+
The variable is a list of key-value pairs which requires the `name` of the
206+
feature flag and its boolean state `enabled`.
207+
The default value is set to an empty list `[]`.
208+
209+
```yaml
210+
gitlab_feature_flags:
211+
- name: "vscode_web_ide"
212+
enabled: true
213+
- name: "chatops"
214+
enabled: true
215+
- name: "webauthn"
216+
enabled: false
217+
```
218+
201219
#### Mattermost only use case
202220

203221
This role can be used to run Mattermost without deploying GitLab. In this

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,6 @@ gitlab_registry_external_url: "http://localhost:5005"
8686
# Whether GitLab Omnibus is used to run Mattermost only without GitLab
8787
gitlab_mattermost_only_context: "false"
8888

89+
gitlab_feature_flags: []
90+
8991
...

molecule/default/molecule.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,19 @@ provisioner:
3333
host_vars:
3434
instancegitlab:
3535
gitlab_edition: "gitlab-ce"
36-
# gitlab_version: "14.5.2"
37-
# gitlab_release: "ce.0"
3836
gitlab_additional_configurations:
3937
- package:
4038
- key: "modify_kernel_parameters"
4139
type: "plain"
4240
value: "false"
41+
gitlab_feature_flags:
42+
# See https://docs.gitlab.com/ee/user/feature_flags.html
43+
- name: "vscode_web_ide"
44+
enabled: true
45+
- name: "chatops"
46+
enabled: true
47+
- name: "webauthn"
48+
enabled: false
4349
verifier:
4450
name: ansible
4551
scenario:

tasks/feature-flag.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-FileCopyrightText: 2023 Helmholtz Centre for Environmental Research (UFZ)
2+
# SPDX-FileCopyrightText: 2023 Helmholtz-Zentrum Dresden-Rossendorf (HZDR)
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
---
7+
8+
- name: "Check if feature flag is already enabled for {{ gitlab_feature_flag.name }}"
9+
ansible.builtin.command:
10+
cmd: "gitlab-rails runner 'is_feature_enabled = Feature.enabled?(:{{ gitlab_feature_flag.name }}); puts is_feature_enabled'"
11+
register: "is_feature_enabled"
12+
changed_when: false
13+
14+
- name: "Enable or disable feature flag {{ gitlab_feature_flag.name }}"
15+
ansible.builtin.command:
16+
cmd: "gitlab-rails runner 'Feature.{{ 'enable' if gitlab_feature_flag.enabled else 'disable' }}(:{{ gitlab_feature_flag.name }})'"
17+
when: "(is_feature_enabled.stdout == 'true' and not gitlab_feature_flag.enabled) or (is_feature_enabled.stdout == 'false' and gitlab_feature_flag.enabled)"
18+
19+
...

tasks/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,13 @@
3535
ansible.builtin.import_tasks: configure.yml
3636
become: yes
3737

38+
- name: "Force all notified handlers to run at this point. Required for feature flags."
39+
ansible.builtin.meta: "flush_handlers"
40+
41+
- name: "Set feature flags"
42+
ansible.builtin.include_tasks: "feature-flag.yml"
43+
loop: "{{ gitlab_feature_flags }}"
44+
loop_control:
45+
loop_var: "gitlab_feature_flag"
46+
3847
...

0 commit comments

Comments
 (0)