Sort parameters in gitlab_group to aid in adding more params (#8899)
parent
8ef77d8664
commit
ab84f1632f
|
@ -33,66 +33,21 @@ attributes:
|
||||||
support: none
|
support: none
|
||||||
|
|
||||||
options:
|
options:
|
||||||
name:
|
|
||||||
description:
|
|
||||||
- Name of the group you want to create.
|
|
||||||
required: true
|
|
||||||
type: str
|
|
||||||
path:
|
|
||||||
description:
|
|
||||||
- The path of the group you want to create, this will be api_url/group_path
|
|
||||||
- If not supplied, the group_name will be used.
|
|
||||||
type: str
|
|
||||||
description:
|
|
||||||
description:
|
|
||||||
- A description for the group.
|
|
||||||
type: str
|
|
||||||
state:
|
|
||||||
description:
|
|
||||||
- create or delete group.
|
|
||||||
- Possible values are present and absent.
|
|
||||||
default: present
|
|
||||||
type: str
|
|
||||||
choices: ["present", "absent"]
|
|
||||||
parent:
|
|
||||||
description:
|
|
||||||
- Allow to create subgroups
|
|
||||||
- Id or Full path of parent group in the form of group/name
|
|
||||||
type: str
|
|
||||||
visibility:
|
|
||||||
description:
|
|
||||||
- Default visibility of the group
|
|
||||||
choices: ["private", "internal", "public"]
|
|
||||||
default: private
|
|
||||||
type: str
|
|
||||||
project_creation_level:
|
|
||||||
description:
|
|
||||||
- Determine if developers can create projects in the group.
|
|
||||||
choices: ["developer", "maintainer", "noone"]
|
|
||||||
type: str
|
|
||||||
version_added: 3.7.0
|
|
||||||
auto_devops_enabled:
|
auto_devops_enabled:
|
||||||
description:
|
description:
|
||||||
- Default to Auto DevOps pipeline for all projects within this group.
|
- Default to Auto DevOps pipeline for all projects within this group.
|
||||||
type: bool
|
type: bool
|
||||||
version_added: 3.7.0
|
version_added: 3.7.0
|
||||||
subgroup_creation_level:
|
|
||||||
description:
|
|
||||||
- Allowed to create subgroups.
|
|
||||||
choices: ["maintainer", "owner"]
|
|
||||||
type: str
|
|
||||||
version_added: 3.7.0
|
|
||||||
require_two_factor_authentication:
|
|
||||||
description:
|
|
||||||
- Require all users in this group to setup two-factor authentication.
|
|
||||||
type: bool
|
|
||||||
version_added: 3.7.0
|
|
||||||
avatar_path:
|
avatar_path:
|
||||||
description:
|
description:
|
||||||
- Absolute path image to configure avatar. File size should not exceed 200 kb.
|
- Absolute path image to configure avatar. File size should not exceed 200 kb.
|
||||||
- This option is only used on creation, not for updates.
|
- This option is only used on creation, not for updates.
|
||||||
type: path
|
type: path
|
||||||
version_added: 4.2.0
|
version_added: 4.2.0
|
||||||
|
description:
|
||||||
|
description:
|
||||||
|
- A description for the group.
|
||||||
|
type: str
|
||||||
force_delete:
|
force_delete:
|
||||||
description:
|
description:
|
||||||
- Force delete group even if projects in it.
|
- Force delete group even if projects in it.
|
||||||
|
@ -100,6 +55,51 @@ options:
|
||||||
type: bool
|
type: bool
|
||||||
default: false
|
default: false
|
||||||
version_added: 7.5.0
|
version_added: 7.5.0
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- Name of the group you want to create.
|
||||||
|
required: true
|
||||||
|
type: str
|
||||||
|
parent:
|
||||||
|
description:
|
||||||
|
- Allow to create subgroups
|
||||||
|
- Id or Full path of parent group in the form of group/name
|
||||||
|
type: str
|
||||||
|
path:
|
||||||
|
description:
|
||||||
|
- The path of the group you want to create, this will be api_url/group_path
|
||||||
|
- If not supplied, the group_name will be used.
|
||||||
|
type: str
|
||||||
|
project_creation_level:
|
||||||
|
description:
|
||||||
|
- Determine if developers can create projects in the group.
|
||||||
|
choices: ["developer", "maintainer", "noone"]
|
||||||
|
type: str
|
||||||
|
version_added: 3.7.0
|
||||||
|
require_two_factor_authentication:
|
||||||
|
description:
|
||||||
|
- Require all users in this group to setup two-factor authentication.
|
||||||
|
type: bool
|
||||||
|
version_added: 3.7.0
|
||||||
|
state:
|
||||||
|
description:
|
||||||
|
- create or delete group.
|
||||||
|
- Possible values are present and absent.
|
||||||
|
default: present
|
||||||
|
type: str
|
||||||
|
choices: ["present", "absent"]
|
||||||
|
subgroup_creation_level:
|
||||||
|
description:
|
||||||
|
- Allowed to create subgroups.
|
||||||
|
choices: ["maintainer", "owner"]
|
||||||
|
type: str
|
||||||
|
version_added: 3.7.0
|
||||||
|
visibility:
|
||||||
|
description:
|
||||||
|
- Default visibility of the group
|
||||||
|
choices: ["private", "internal", "public"]
|
||||||
|
default: private
|
||||||
|
type: str
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
|
@ -207,13 +207,13 @@ class GitLabGroup(object):
|
||||||
parent_id = self.get_group_id(parent)
|
parent_id = self.get_group_id(parent)
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
'name': name,
|
|
||||||
'path': options['path'],
|
|
||||||
'parent_id': parent_id,
|
|
||||||
'visibility': options['visibility'],
|
|
||||||
'project_creation_level': options['project_creation_level'],
|
|
||||||
'auto_devops_enabled': options['auto_devops_enabled'],
|
'auto_devops_enabled': options['auto_devops_enabled'],
|
||||||
|
'name': name,
|
||||||
|
'parent_id': parent_id,
|
||||||
|
'path': options['path'],
|
||||||
|
'project_creation_level': options['project_creation_level'],
|
||||||
'subgroup_creation_level': options['subgroup_creation_level'],
|
'subgroup_creation_level': options['subgroup_creation_level'],
|
||||||
|
'visibility': options['visibility'],
|
||||||
}
|
}
|
||||||
if options.get('description'):
|
if options.get('description'):
|
||||||
payload['description'] = options['description']
|
payload['description'] = options['description']
|
||||||
|
@ -230,13 +230,13 @@ class GitLabGroup(object):
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
changed, group = self.update_group(self.group_object, {
|
changed, group = self.update_group(self.group_object, {
|
||||||
'name': name,
|
|
||||||
'description': options['description'],
|
|
||||||
'visibility': options['visibility'],
|
|
||||||
'project_creation_level': options['project_creation_level'],
|
|
||||||
'auto_devops_enabled': options['auto_devops_enabled'],
|
'auto_devops_enabled': options['auto_devops_enabled'],
|
||||||
'subgroup_creation_level': options['subgroup_creation_level'],
|
'description': options['description'],
|
||||||
|
'name': name,
|
||||||
|
'project_creation_level': options['project_creation_level'],
|
||||||
'require_two_factor_authentication': options['require_two_factor_authentication'],
|
'require_two_factor_authentication': options['require_two_factor_authentication'],
|
||||||
|
'subgroup_creation_level': options['subgroup_creation_level'],
|
||||||
|
'visibility': options['visibility'],
|
||||||
})
|
})
|
||||||
|
|
||||||
self.group_object = group
|
self.group_object = group
|
||||||
|
@ -322,28 +322,28 @@ def main():
|
||||||
argument_spec = basic_auth_argument_spec()
|
argument_spec = basic_auth_argument_spec()
|
||||||
argument_spec.update(auth_argument_spec())
|
argument_spec.update(auth_argument_spec())
|
||||||
argument_spec.update(dict(
|
argument_spec.update(dict(
|
||||||
name=dict(type='str', required=True),
|
|
||||||
path=dict(type='str'),
|
|
||||||
description=dict(type='str'),
|
|
||||||
state=dict(type='str', default="present", choices=["absent", "present"]),
|
|
||||||
parent=dict(type='str'),
|
|
||||||
visibility=dict(type='str', default="private", choices=["internal", "private", "public"]),
|
|
||||||
project_creation_level=dict(type='str', choices=['developer', 'maintainer', 'noone']),
|
|
||||||
auto_devops_enabled=dict(type='bool'),
|
auto_devops_enabled=dict(type='bool'),
|
||||||
subgroup_creation_level=dict(type='str', choices=['maintainer', 'owner']),
|
|
||||||
require_two_factor_authentication=dict(type='bool'),
|
|
||||||
avatar_path=dict(type='path'),
|
avatar_path=dict(type='path'),
|
||||||
|
description=dict(type='str'),
|
||||||
force_delete=dict(type='bool', default=False),
|
force_delete=dict(type='bool', default=False),
|
||||||
|
name=dict(type='str', required=True),
|
||||||
|
parent=dict(type='str'),
|
||||||
|
path=dict(type='str'),
|
||||||
|
project_creation_level=dict(type='str', choices=['developer', 'maintainer', 'noone']),
|
||||||
|
require_two_factor_authentication=dict(type='bool'),
|
||||||
|
state=dict(type='str', default="present", choices=["absent", "present"]),
|
||||||
|
subgroup_creation_level=dict(type='str', choices=['maintainer', 'owner']),
|
||||||
|
visibility=dict(type='str', default="private", choices=["internal", "private", "public"]),
|
||||||
))
|
))
|
||||||
|
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=argument_spec,
|
argument_spec=argument_spec,
|
||||||
mutually_exclusive=[
|
mutually_exclusive=[
|
||||||
['api_username', 'api_token'],
|
|
||||||
['api_username', 'api_oauth_token'],
|
|
||||||
['api_username', 'api_job_token'],
|
|
||||||
['api_token', 'api_oauth_token'],
|
|
||||||
['api_token', 'api_job_token'],
|
['api_token', 'api_job_token'],
|
||||||
|
['api_token', 'api_oauth_token'],
|
||||||
|
['api_username', 'api_job_token'],
|
||||||
|
['api_username', 'api_oauth_token'],
|
||||||
|
['api_username', 'api_token'],
|
||||||
],
|
],
|
||||||
required_together=[
|
required_together=[
|
||||||
['api_username', 'api_password'],
|
['api_username', 'api_password'],
|
||||||
|
@ -357,18 +357,18 @@ def main():
|
||||||
# check prerequisites and connect to gitlab server
|
# check prerequisites and connect to gitlab server
|
||||||
gitlab_instance = gitlab_authentication(module)
|
gitlab_instance = gitlab_authentication(module)
|
||||||
|
|
||||||
|
auto_devops_enabled = module.params['auto_devops_enabled']
|
||||||
|
avatar_path = module.params['avatar_path']
|
||||||
|
description = module.params['description']
|
||||||
|
force_delete = module.params['force_delete']
|
||||||
group_name = module.params['name']
|
group_name = module.params['name']
|
||||||
group_path = module.params['path']
|
group_path = module.params['path']
|
||||||
description = module.params['description']
|
|
||||||
state = module.params['state']
|
|
||||||
parent_identifier = module.params['parent']
|
|
||||||
group_visibility = module.params['visibility']
|
group_visibility = module.params['visibility']
|
||||||
|
parent_identifier = module.params['parent']
|
||||||
project_creation_level = module.params['project_creation_level']
|
project_creation_level = module.params['project_creation_level']
|
||||||
auto_devops_enabled = module.params['auto_devops_enabled']
|
|
||||||
subgroup_creation_level = module.params['subgroup_creation_level']
|
|
||||||
require_two_factor_authentication = module.params['require_two_factor_authentication']
|
require_two_factor_authentication = module.params['require_two_factor_authentication']
|
||||||
avatar_path = module.params['avatar_path']
|
state = module.params['state']
|
||||||
force_delete = module.params['force_delete']
|
subgroup_creation_level = module.params['subgroup_creation_level']
|
||||||
|
|
||||||
# Define default group_path based on group_name
|
# Define default group_path based on group_name
|
||||||
if group_path is None:
|
if group_path is None:
|
||||||
|
@ -395,14 +395,14 @@ def main():
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if gitlab_group.create_or_update_group(group_name, parent_group, {
|
if gitlab_group.create_or_update_group(group_name, parent_group, {
|
||||||
"path": group_path,
|
|
||||||
"description": description,
|
|
||||||
"visibility": group_visibility,
|
|
||||||
"project_creation_level": project_creation_level,
|
|
||||||
"auto_devops_enabled": auto_devops_enabled,
|
"auto_devops_enabled": auto_devops_enabled,
|
||||||
"subgroup_creation_level": subgroup_creation_level,
|
|
||||||
"require_two_factor_authentication": require_two_factor_authentication,
|
|
||||||
"avatar_path": avatar_path,
|
"avatar_path": avatar_path,
|
||||||
|
"description": description,
|
||||||
|
"path": group_path,
|
||||||
|
"project_creation_level": project_creation_level,
|
||||||
|
"require_two_factor_authentication": require_two_factor_authentication,
|
||||||
|
"subgroup_creation_level": subgroup_creation_level,
|
||||||
|
"visibility": group_visibility,
|
||||||
}):
|
}):
|
||||||
module.exit_json(changed=True, msg="Successfully created or updated the group %s" % group_name, group=gitlab_group.group_object._attrs)
|
module.exit_json(changed=True, msg="Successfully created or updated the group %s" % group_name, group=gitlab_group.group_object._attrs)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue