community.windows.win_domain_group_membership 模块 – 管理 Windows 域组成员关系

注意

此模块是 community.windows 集合(版本 2.3.0)的一部分。

如果您使用的是 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.windows

要在 playbook 中使用它,请指定:community.windows.win_domain_group_membership

已弃用

在以下版本中移除:

版本 3.0.0

原因:

此模块已移至 microsoft.ad 集合中。

替代方案:

请改用 microsoft.ad.group 模块。

概要

  • 允许从域组添加和删除域用户和域组。

参数

参数

注释

domain_password

字符串

username 的密码。

domain_server

字符串

指定要连接到的 Active Directory 域服务实例。

可以采用 FQDN 或 NetBIOS 名称的形式。

如果未指定,则该值基于运行 PowerShell 的计算机的域。

domain_username

字符串

与 AD 交互时要使用的用户名。

如果未设置,则在使用 CredSSP 或带有凭据委派的 Kerberos 时,将改为使用 Ansible 用于登录的用户。

members

列表 / 元素=字符串 / 必需

要确保存在/不存在于组中的成员列表。

给定的名称必须是用户、组、服务帐户或计算机的 SamAccountName。

对于计算机,您必须在名称后添加“$”;例如,要将“Mycomputer”添加到组中,请使用“Mycomputer$”作为成员。

如果成员对象是多域林中另一个域的一部分,则必须在名称前面添加域和“\”。

name

字符串 / 必需

要管理成员关系的域组的名称。

state

字符串

组中成员的期望状态。

statepure 时,仅会存在指定的成员,并且会删除所有其他未指定的现有成员。

选择

  • "absent"

  • "present" ← (默认)

  • "pure"

备注

注意

  • 这必须在安装了 ActiveDirectory powershell 模块的主机上运行。

另请参阅

另请参阅

community.windows.win_domain_user

管理 Windows Active Directory 用户帐户。

community.windows.win_domain_group

创建、修改或删除域组。

示例

- name: Add a domain user/group to a domain group
  community.windows.win_domain_group_membership:
    name: Foo
    members:
      - Bar
    state: present

- name: Remove a domain user/group from a domain group
  community.windows.win_domain_group_membership:
    name: Foo
    members:
      - Bar
    state: absent

- name: Ensure only a domain user/group exists in a domain group
  community.windows.win_domain_group_membership:
    name: Foo
    members:
      - Bar
    state: pure

- name: Add a computer to a domain group
  community.windows.win_domain_group_membership:
    name: Foo
    members:
      - DESKTOP$
    state: present

- name: Add a domain user/group from another Domain in the multi-domain forest to a domain group
  community.windows.win_domain_group_membership:
    domain_server: DomainAAA.cloud
    name: GroupinDomainAAA
    members:
      - DomainBBB.cloud\UserInDomainBBB
    state: Present

返回值

常见的返回值记录在 此处,以下是此模块特有的字段

描述

added

列表 / 元素=字符串

statepresentpure 时添加的成员列表;如果未添加成员,则此列表为空。

返回: 成功并且 statepresentpure

示例: ["UserName", "GroupName"]

members

列表 / 元素=字符串

完成时所有域组成员的列表;如果组不包含任何成员,则此列表为空。

返回: 成功

示例: ["UserName", "GroupName"]

name

字符串

目标域组的名称。

返回: 始终

示例: "Domain-Admins"

removed

列表 / 元素=字符串

stateabsentpure 时删除的成员列表;如果未删除成员,则此列表为空。

返回: 成功并且 stateabsentpure

示例: ["UserName", "GroupName"]

状态

  • 此模块将在版本 3.0.0 中移除。[已弃用]

  • 有关更多信息,请参阅已弃用

作者

  • Marius Rieder (@jiuka)