Repository: ansible-collections/community.general

Issue:
gitlab_group module ignores group description on group creation
##### SUMMARY
The gitlab_group module ignores the description parameter for creating the group in GitLab. However, the description parameter is considered for updating the group. The module has to be executed twice in order to have the group properly created.

[See the code.](https://github.com/ansible/ansible/blob/9e3ccd64b6a233390cd70c314193b6ba1aacfe21/lib/ansible/modules/source_control/gitlab_group.py#L180)

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
gitlab_group

##### ANSIBLE VERSION
```
ansible 2.9.6
  config file = /c/Users/142936/projects/op/dai/config/ansible.cfg
  configured module search path = ['/home/gustavomcarmo/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/gustavomcarmo/.local/lib/python3.6/site-packages/ansible
  executable location = /home/gustavomcarmo/.local/bin/ansible
  python version = 3.6.9 (default, Nov  7 2019, 10:44:02) [GCC 8.3.0]
```

##### CONFIGURATION
```
DEFAULT_CALLBACK_WHITELIST(/c/Users/142936/projects/op/dai/config/ansible.cfg) = ['profile_tasks']
DEFAULT_HOST_LIST(/c/Users/142936/projects/op/dai/config/ansible.cfg) = ['/c/Users/142936/projects/op/dai/config/inventory.yml']
DEFAULT_VAULT_PASSWORD_FILE(/c/Users/142936/projects/op/dai/config/ansible.cfg) = /c/Users/142936/projects/op/dai/config/vault-password-file
INVENTORY_ENABLED(/c/Users/142936/projects/op/dai/config/ansible.cfg) = ['yaml']
```

##### OS / ENVIRONMENT
```
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.3 LTS"
```

##### STEPS TO REPRODUCE
```yaml
- name: "Create GitLab Group"
  gitlab_group:
    server_url: https://gitlab.example.com/
    validate_certs: True
    api_username: dj-wasabi
    api_password: "MySecretPassword"
    name: my_first_group
    path: my_first_group
    description: My First Group
    state: present
```

##### EXPECTED RESULTS
Group created with the description: "My First Group".

##### ACTUAL RESULTS
Group created with no description.



Discussion:
cc @Lunik @dj-wasabi
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
cc @Shaps @marwatk @waheedi
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/plugins/modules/source_control/gitlab/gitlab_group.py b/plugins/modules/source_control/gitlab/gitlab_group.py
--- a/plugins/modules/source_control/gitlab/gitlab_group.py
+++ b/plugins/modules/source_control/gitlab/gitlab_group.py
@@ -162,11 +162,15 @@ def createOrUpdateGroup(self, name, parent, options):
         if self.groupObject is None:
             parent_id = self.getGroupId(parent)
 
-            group = self.createGroup({
+            payload = {
                 'name': name,
                 'path': options['path'],
                 'parent_id': parent_id,
-                'visibility': options['visibility']})
+                'visibility': options['visibility']
+            }
+            if options.get('description'):
+                payload['description'] = options['description']
+            group = self.createGroup(payload)
             changed = True
         else:
             changed, group = self.updateGroup(self.groupObject, {


Test patch:
diff --git a/tests/integration/targets/gitlab_group/tasks/main.yml b/tests/integration/targets/gitlab_group/tasks/main.yml
--- a/tests/integration/targets/gitlab_group/tasks/main.yml
+++ b/tests/integration/targets/gitlab_group/tasks/main.yml
@@ -10,18 +10,18 @@
 
 - name: Cleanup GitLab Group
   gitlab_group:
-    server_url: "{{ gitlab_host }}"
+    api_url: "{{ gitlab_host }}"
     validate_certs: false
-    login_token: "{{ gitlab_login_token }}"
+    api_token: "{{ gitlab_login_token }}"
     name: ansible_test_group
     path: ansible_test_group
     state: absent
 
 - name: Create GitLab Group
   gitlab_group:
-    server_url: "{{ gitlab_host }}"
+    api_url: "{{ gitlab_host }}"
     validate_certs: false
-    login_token: "{{ gitlab_login_token }}"
+    api_token: "{{ gitlab_login_token }}"
     name: ansible_test_group
     path: ansible_test_group
     state: present
@@ -35,9 +35,9 @@
 
 - name: Create GitLab Group ( Idempotency test )
   gitlab_group:
-    server_url: "{{ gitlab_host }}"
+    api_url: "{{ gitlab_host }}"
     validate_certs: false
-    login_token: "{{ gitlab_login_token }}"
+    api_token: "{{ gitlab_login_token }}"
     name: ansible_test_group
     path: ansible_test_group
     state: present
@@ -47,3 +47,28 @@
   assert:
     that:
       - gitlab_group_state_again is not changed
+
+- name: Cleanup GitLab Group for Description Test
+  gitlab_group:
+    api_url: "{{ gitlab_host }}"
+    validate_certs: false
+    api_token: "{{ gitlab_login_token }}"
+    name: ansible_test_group
+    path: ansible_test_group
+    state: absent
+
+- name: Create GitLab Group for Description Test
+  gitlab_group:
+    api_url: "{{ gitlab_host }}"
+    validate_certs: false
+    api_token: "{{ gitlab_login_token }}"
+    name: ansible_test_group
+    path: ansible_test_group
+    description: My Test Group
+    state: present
+  register: gitlab_group_state_desc
+
+- name: Test group created with Description
+  assert:
+    that:
+      - gitlab_group_state_desc.group.description == "My Test Group"
diff --git a/tests/unit/plugins/modules/source_control/gitlab/test_gitlab_group.py b/tests/unit/plugins/modules/source_control/gitlab/test_gitlab_group.py
--- a/tests/unit/plugins/modules/source_control/gitlab/test_gitlab_group.py
+++ b/tests/unit/plugins/modules/source_control/gitlab/test_gitlab_group.py
@@ -66,11 +66,14 @@ def test_exist_group(self):
 
     @with_httmock(resp_create_group)
     def test_create_group(self):
-        group = self.moduleUtil.createGroup({'name': "Foobar Group", 'path': "foo-bar"})
+        group = self.moduleUtil.createGroup({'name': "Foobar Group",
+                                             'path': "foo-bar",
+                                             'description': "An interesting group"})
 
         self.assertEqual(type(group), Group)
         self.assertEqual(group.name, "Foobar Group")
         self.assertEqual(group.path, "foo-bar")
+        self.assertEqual(group.description, "An interesting group")
         self.assertEqual(group.id, 1)
 
     @with_httmock(resp_create_subgroup)