From f8bfd5df0dfb46afd23bf29a0c5f8c3e7c1d264c Mon Sep 17 00:00:00 2001
From: KBjorndal-VizRT <83645484+KBjorndal-VizRT@users.noreply.github.com>
Date: Mon, 30 Dec 2024 12:48:25 +0100
Subject: [PATCH] gitlab_instance_variable: Add support for 'raw' property
 (#9425)

* gitlab_instance_variable: Add support for 'raw' property

* Changelog fragment

* Add missing punctuation

Co-authored-by: Felix Fontein <felix@fontein.de>

* Add version_added

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
---
 .../fragments/9425-gitlab-instance-raw-variable.yml   |  2 ++
 plugins/modules/gitlab_instance_variable.py           | 11 +++++++++++
 2 files changed, 13 insertions(+)
 create mode 100644 changelogs/fragments/9425-gitlab-instance-raw-variable.yml

diff --git a/changelogs/fragments/9425-gitlab-instance-raw-variable.yml b/changelogs/fragments/9425-gitlab-instance-raw-variable.yml
new file mode 100644
index 0000000000..c9d6ec7d4b
--- /dev/null
+++ b/changelogs/fragments/9425-gitlab-instance-raw-variable.yml
@@ -0,0 +1,2 @@
+minor_changes:
+  - gitlab_instance_variable - add support for ``raw`` variables suboption (https://github.com/ansible-collections/community.general/pull/9425).
diff --git a/plugins/modules/gitlab_instance_variable.py b/plugins/modules/gitlab_instance_variable.py
index be89238eb4..2023b0ad7d 100644
--- a/plugins/modules/gitlab_instance_variable.py
+++ b/plugins/modules/gitlab_instance_variable.py
@@ -74,6 +74,13 @@ options:
           - Whether variable value is protected or not.
         type: bool
         default: false
+      raw:
+        description:
+          - Whether variable value is raw or not.
+          - Support for raw values requires GitLab >= 15.7.
+        type: bool
+        default: false
+        version_added: 10.2.0
       variable_type:
         description:
           - Whether a variable is an environment variable (V(env_var)) or a file (V(file)).
@@ -160,6 +167,7 @@ class GitlabInstanceVariables(object):
             "value": var_obj.get('value'),
             "masked": var_obj.get('masked'),
             "protected": var_obj.get('protected'),
+            "raw": var_obj.get('raw'),
             "variable_type": var_obj.get('variable_type'),
         }
 
@@ -227,6 +235,8 @@ def native_python_main(this_gitlab, purge, requested_variables, state, module):
             item['protected'] = False
         if item.get('masked') is None:
             item['masked'] = False
+        if item.get('raw') is None:
+            item['raw'] = False
         if item.get('variable_type') is None:
             item['variable_type'] = 'env_var'
 
@@ -297,6 +307,7 @@ def main():
             value=dict(type='str', no_log=True),
             masked=dict(type='bool', default=False),
             protected=dict(type='bool', default=False),
+            raw=dict(type='bool', default=False),
             variable_type=dict(type='str', default='env_var', choices=["env_var", "file"])
         )),
         state=dict(type='str', default="present", choices=["absent", "present"]),