community.general.gitlab_group_members 模块 – 管理 GitLab 服务器上的组成员
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.general。您需要其他要求才能使用此模块,请参阅 要求了解详细信息。
要在 playbook 中使用它,请指定:community.general.gitlab_group_members。
community.general 1.2.0 中的新增功能
概要
- 此模块允许在 GitLab 上向组添加和删除成员,或更改组成员的访问级别。 
要求
以下要求需要在执行此模块的主机上满足。
- GitLab 服务器上的管理员权限 
- python-gitlab python 模块 <= 1.15.0 
- requests(Python 库 https://pypi.ac.cn/project/requests/) 
参数
| 参数 | 注释 | 
|---|---|
| 用户的访问级别。 如果  与  选项 
 | |
| 用于登录的 GitLab CI 作业令牌。 | |
| 用于登录的 GitLab OAuth 令牌。 | |
| 用于 API 身份验证的密码。 | |
| 具有 API 权限的 GitLab 访问令牌。 | |
| API 的可解析端点。 | |
| 用于 API 身份验证的用户名。 | |
| 用于验证 GitLab 服务器证书的 CA 证书捆绑包。 | |
| 要添加/删除成员的 GitLab 组的  自 community.general 6.0.0 起,不允许将其设置为  | |
| 要添加到/从 GitLab 组中删除的用户名或用户名列表。 与  | |
| 提供用户到访问级别映射的列表。 此列表中的每个字典都指定一个用户(通过用户名)以及该用户应具有的访问级别。 与  与  | |
| 用户的访问级别。 如果  选项 
 | |
| 要添加到/从 GitLab 组中删除的用户名或用户名列表。 | |
| 根据给定的  仅在  选项 
 | |
| 组成员在组中的状态。 当为  当为  选项 
 | |
| 当提供 HTTPS 端点时,是否验证 SSL 证书。 选项 
 | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持: 完全 | 可以在  | |
| 支持: 无 | 在 diff 模式下,将会返回已更改(或可能需要在  | 
示例
- name: Add a user to a GitLab Group
  community.general.gitlab_group_members:
    api_url: 'https://gitlab.example.com'
    api_token: 'Your-Private-Token'
    gitlab_group: groupname
    gitlab_user: username
    access_level: developer
    state: present
- name: Remove a user from a GitLab Group
  community.general.gitlab_group_members:
    api_url: 'https://gitlab.example.com'
    api_token: 'Your-Private-Token'
    gitlab_group: groupname
    gitlab_user: username
    state: absent
- name: Add a list of Users to A GitLab Group
  community.general.gitlab_group_members:
    api_url: 'https://gitlab.example.com'
    api_token: 'Your-Private-Token'
    gitlab_group: groupname
    gitlab_user:
      - user1
      - user2
    access_level: developer
    state: present
- name: Add a list of Users with Dedicated Access Levels to A GitLab Group
  community.general.gitlab_group_members:
    api_url: 'https://gitlab.example.com'
    api_token: 'Your-Private-Token'
    gitlab_group: groupname
    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_group_members:
    api_url: 'https://gitlab.example.com'
    api_token: 'Your-Private-Token'
    gitlab_group: groupname
    gitlab_user: username
    access_level: developer
    pruge_users: developer
    state: present
- name: Remove a list of Users with Dedicated Access Levels to A GitLab Group
  community.general.gitlab_group_members:
    api_url: 'https://gitlab.example.com'
    api_token: 'Your-Private-Token'
    gitlab_group: groupname
    gitlab_users_access:
      - name: user1
        access_level: developer
      - name: user2
        access_level: maintainer
    state: absent
