community.general.gitlab_group_access_token (8.5.0) — module

Manages GitLab group access tokens

| "added in version" 8.4.0 of community.general"

Authors: Zoran Krleza (@pixslx)

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

Creates and revokes group access tokens.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Creating a group access token"
  community.general.gitlab_group_access_token:
    api_url: https://gitlab.example.com/
    api_token: "somegitlabapitoken"
    group: "my_group/my_subgroup"
    name: "group_token"
    expires_at: "2024-12-31"
    access_level: developer
    scopes:
      - api
      - read_api
      - read_repository
      - write_repository
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Revoking a group access token"
  community.general.gitlab_group_access_token:
    api_url: https://gitlab.example.com/
    api_token: "somegitlabapitoken"
    group: "my_group/my_group"
    name: "group_token"
    expires_at: "2024-12-31"
    scopes:
      - api
      - read_api
      - read_repository
      - write_repository
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Change (recreate) existing token if its actual state is different than desired state"
  community.general.gitlab_group_access_token:
    api_url: https://gitlab.example.com/
    api_token: "somegitlabapitoken"
    group: "my_group/my_group"
    name: "group_token"
    expires_at: "2024-12-31"
    scopes:
      - api
      - read_api
      - read_repository
      - write_repository
    recreate: state_change
    state: present

Inputs

    
name:
    description:
    - Access token's name.
    required: true
    type: str

group:
    description:
    - ID or full path of group in the form of group/subgroup.
    required: true
    type: str

state:
    choices:
    - present
    - absent
    default: present
    description:
    - When V(present) the access token will be added to the group if it does not exist.
    - When V(absent) it will be removed from the group if it exists.
    type: str

scopes:
    aliases:
    - scope
    choices:
    - api
    - read_api
    - read_registry
    - write_registry
    - read_repository
    - write_repository
    - create_runner
    - ai_features
    - k8s_proxy
    description:
    - Scope of the access token.
    elements: str
    required: true
    type: list

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

recreate:
    choices:
    - never
    - always
    - state_change
    default: never
    description:
    - Whether the access token will be recreated if it already exists.
    - When V(never) the token will never be recreated.
    - When V(always) the token will always be recreated.
    - When V(state_change) the token will be recreated if there is a difference between
      desired state and actual state.
    type: str

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

expires_at:
    description:
    - Expiration date of the access token in C(YYYY-MM-DD) format.
    - Make sure to quote this value in YAML to ensure it is kept as a string and not interpreted
      as a YAML date.
    required: true
    type: str

access_level:
    choices:
    - guest
    - reporter
    - developer
    - maintainer
    - owner
    default: maintainer
    description:
    - Access level of the access token.
    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

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

Outputs

access_token:
  description:
  - API object.
  - Only contains the value of the token if the token was created or recreated.
  returned: success and O(state=present)
  type: dict