community.general.gitlab_group (8.5.0) — module

Creates/updates/deletes GitLab Groups

Authors: Werner Dijkerman (@dj-wasabi), Guillaume Martinez (@Lunik)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

When the group does not exist in GitLab, it will be created.

When the group does exist and state=absent, the group will be deleted.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Delete GitLab Group"
  community.general.gitlab_group:
    api_url: https://gitlab.example.com/
    api_token: "{{ access_token }}"
    name: my_first_group
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Create GitLab Group"
  community.general.gitlab_group:
    api_url: https://gitlab.example.com/
    validate_certs: true
    api_username: dj-wasabi
    api_password: "MySecretPassword"
    name: my_first_group
    path: my_first_group
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# The group will by created at https://gitlab.dj-wasabi.local/super_parent/parent/my_first_group
- name: "Create GitLab SubGroup"
  community.general.gitlab_group:
    api_url: https://gitlab.example.com/
    validate_certs: true
    api_username: dj-wasabi
    api_password: "MySecretPassword"
    name: my_first_group
    path: my_first_group
    state: present
    parent: "super_parent/parent"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Other group which only allows sub-groups - no projects
- name: "Create GitLab Group for SubGroups only"
  community.general.gitlab_group:
    api_url: https://gitlab.example.com/
    validate_certs: true
    api_username: dj-wasabi
    api_password: "MySecretPassword"
    name: my_main_group
    path: my_main_group
    state: present
    project_creation_level: noone
    auto_devops_enabled: false
    subgroup_creation_level: maintainer

Inputs

    
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

state:
    choices:
    - present
    - absent
    default: present
    description:
    - create or delete group.
    - Possible values are present and absent.
    type: str

parent:
    description:
    - Allow to create subgroups
    - Id or Full path of parent group in the form of group/name
    type: str

api_url:
    description:
    - The resolvable endpoint for the API.
    type: str

ca_path:
    description:
    - The CA certificates bundle to use to verify GitLab server certificate.
    type: str
    version_added: 8.1.0
    version_added_collection: community.general

api_token:
    description:
    - GitLab access token with API permissions.
    type: str

visibility:
    choices:
    - private
    - internal
    - public
    default: private
    description:
    - Default visibility of the group
    type: str

avatar_path:
    description:
    - Absolute path image to configure avatar. File size should not exceed 200 kb.
    - This option is only used on creation, not for updates.
    type: path
    version_added: 4.2.0
    version_added_collection: community.general

description:
    description:
    - A description for the group.
    type: str

api_password:
    description:
    - The password to use for authentication against the API.
    type: str

api_username:
    description:
    - The username to use for authentication against the API.
    type: str

force_delete:
    default: false
    description:
    - Force delete group even if projects in it.
    - Used only when O(state=absent).
    type: bool
    version_added: 7.5.0
    version_added_collection: community.general

api_job_token:
    description:
    - GitLab CI job token for logging in.
    type: str
    version_added: 4.2.0
    version_added_collection: community.general

validate_certs:
    default: true
    description:
    - Whether or not to validate SSL certs when supplying a HTTPS endpoint.
    type: bool

api_oauth_token:
    description:
    - GitLab OAuth token for logging in.
    type: str
    version_added: 4.2.0
    version_added_collection: community.general

auto_devops_enabled:
    description:
    - Default to Auto DevOps pipeline for all projects within this group.
    type: bool
    version_added: 3.7.0
    version_added_collection: community.general

project_creation_level:
    choices:
    - developer
    - maintainer
    - noone
    description:
    - Determine if developers can create projects in the group.
    type: str
    version_added: 3.7.0
    version_added_collection: community.general

subgroup_creation_level:
    choices:
    - maintainer
    - owner
    description:
    - Allowed to create subgroups.
    type: str
    version_added: 3.7.0
    version_added_collection: community.general

require_two_factor_authentication:
    description:
    - Require all users in this group to setup two-factor authentication.
    type: bool
    version_added: 3.7.0
    version_added_collection: community.general

Outputs

error:
  description: the error message returned by the GitLab API
  returned: failed
  sample: '400: path is already in use'
  type: str
group:
  description: API object
  returned: always
  type: dict
msg:
  description: Success or failure message
  returned: always
  sample: Success
  type: str
result:
  description: json parsed response from the server
  returned: always
  type: dict