community.general.gitlab_project_members module – Manage project members on GitLab Server
Note
This module is part of the community.general collection (version 8.6.8).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.gitlab_project_members
.
New in community.general 2.2.0
Synopsis
This module allows to add and remove members to/from a project, or change a member’s access level in a project on GitLab.
Aliases: source_control.gitlab.gitlab_project_members
Requirements
The below requirements are needed on the host that executes this module.
owner or maintainer rights to project on the GitLab server
python-gitlab python module <= 1.15.0
requests (Python library https://pypi.org/project/requests/)
Parameters
Parameter |
Comments |
---|---|
The access level for the user. Required if Choices:
|
|
GitLab CI job token for logging in. |
|
GitLab OAuth token for logging in. |
|
The password to use for authentication against the API. |
|
GitLab access token with API permissions. |
|
The resolvable endpoint for the API. |
|
The username to use for authentication against the API. |
|
The CA certificates bundle to use to verify GitLab server certificate. |
|
A username or a list of usernames to add to/remove from the GitLab project. Mutually exclusive with |
|
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 Use together with |
|
The access level for the user. Required if Choices:
|
|
A username or a list of usernames to add to/remove from the GitLab project. |
|
The name (or full path) of the GitLab project the member is added to/removed from. |
|
Adds/remove users of the given access_level to match the given Is only used when Choices:
|
|
State of the member in the project. On On Choices:
|
|
Whether or not to validate SSL certs when supplying a HTTPS endpoint. Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Examples
- 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
- 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
- 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
- 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
- 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
- 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