community.general.gitlab_project_members (8.5.0) — module

Manage project members on GitLab Server

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

Authors: Sergey Mikhaltsov (@metanovii), Zainab Alsaffar (@zanssa)

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

This module allows to add and remove members to/from a project, or change a member's access level in a project on GitLab.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add a user to a GitLab Project
  community.general.gitlab_project_members:
    api_url: 'https://gitlab.example.com'
    api_token: 'Your-Private-Token'
    validate_certs: true
    project: projectname
    gitlab_user: username
    access_level: developer
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove a user from a GitLab project
  community.general.gitlab_project_members:
    api_url: 'https://gitlab.example.com'
    api_token: 'Your-Private-Token'
    project: projectname
    gitlab_user: username
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add a list of Users to A GitLab project
  community.general.gitlab_project_members:
    api_url: 'https://gitlab.example.com'
    api_token: 'Your-Private-Token'
    gitlab_project: projectname
    gitlab_user:
      - user1
      - user2
    access_level: developer
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add a list of Users with Dedicated Access Levels to A GitLab project
  community.general.gitlab_project_members:
    api_url: 'https://gitlab.example.com'
    api_token: 'Your-Private-Token'
    project: projectname
    gitlab_users_access:
      - name: user1
        access_level: developer
      - name: user2
        access_level: maintainer
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add a user, remove all others which might be on this access level
  community.general.gitlab_project_members:
    api_url: 'https://gitlab.example.com'
    api_token: 'Your-Private-Token'
    project: projectname
    gitlab_user: username
    access_level: developer
    purge_users: developer
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove a list of Users with Dedicated Access Levels to A GitLab project
  community.general.gitlab_project_members:
    api_url: 'https://gitlab.example.com'
    api_token: 'Your-Private-Token'
    project: projectname
    gitlab_users_access:
      - name: user1
        access_level: developer
      - name: user2
        access_level: maintainer
    state: absent

Inputs

    
state:
    choices:
    - present
    - absent
    default: present
    description:
    - State of the member in the project.
    - On V(present), it adds a user to a GitLab project.
    - On V(absent), it removes a user from a GitLab project.
    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

project:
    description:
    - The name (or full path) of the GitLab project the member is added to/removed from.
    required: true
    type: str

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

gitlab_user:
    description:
    - A username or a list of usernames to add to/remove from the GitLab project.
    - Mutually exclusive with O(gitlab_users_access).
    elements: str
    type: list

purge_users:
    choices:
    - guest
    - reporter
    - developer
    - maintainer
    description:
    - Adds/remove users of the given access_level to match the given O(gitlab_user)/O(gitlab_users_access)
      list. If omitted do not purge orphaned members.
    - Is only used when O(state=present).
    elements: str
    type: list
    version_added: 3.7.0
    version_added_collection: community.general

access_level:
    choices:
    - guest
    - reporter
    - developer
    - maintainer
    description:
    - The access level for the user.
    - Required if O(state=present), user state is set to present.
    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

gitlab_users_access:
    description:
    - Provide a list of user to access level mappings.
    - Every dictionary in this list specifies a user (by username) and the access level
      the user should have.
    - Mutually exclusive with O(gitlab_user) and O(access_level).
    - Use together with O(purge_users) to remove all users not specified here from the
      project.
    elements: dict
    suboptions:
      access_level:
        choices:
        - guest
        - reporter
        - developer
        - maintainer
        description:
        - The access level for the user.
        - Required if O(state=present), user state is set to present.
        required: true
        type: str
      name:
        description: A username or a list of usernames to add to/remove from the GitLab
          project.
        required: true
        type: str
    type: list
    version_added: 3.7.0
    version_added_collection: community.general