community.windows.win_domain_ou 模块 – 管理 Active Directory 组织单元
注意
此模块是 community.windows 集合(版本 2.3.0)的一部分。
如果您使用的是 ansible 包,您可能已经安装了此集合。 它不包含在 ansible-core 中。 要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.windows。 您需要进一步的要求才能使用此模块,请参阅 要求 了解详细信息。
要在 playbook 中使用它,请指定:community.windows.win_domain_ou。
community.windows 1.8.0 中的新增功能
已弃用
- 在以下版本中移除:
- 3.0.0 版 
- 原因:
- 此模块已移动到 - microsoft.ad集合中。
- 替代方案:
- 请改用 microsoft.ad.ou 模块。 
概要
- 管理 Active Directory 组织单元 
- 添加、删除和修改 Active Directory 组织单元 
- 任务应委托给 Windows Active Directory 域控制器 
要求
执行此模块的主机需要满足以下要求。
- 此模块需要 Windows Server 2012 或更高版本 
- Powershell ActiveDirectory 模块 
参数
| 参数 | 注释 | 
|---|---|
| 您正在访问的域的密码 | |
| 指定要连接的 Active Directory 域服务实例。 可以是 FQDN 或 NetBIOS 名称的形式。 如果未指定,则该值基于运行 PowerShell 的计算机的域。 | |
| 与 AD 交互时使用的用户名。 如果未设置此项,则在使用 CredSSP 或 Kerberos 进行凭据委派时,将改为使用 Ansible 用于登录的用户。 | |
| 用于查找 OU 的过滤器。 默认:  | |
| 组织单元的名称 | |
| 指定在其中创建新对象的 OU 或容器的 X.500 路径。 默认为在连接的域的根目录添加 OU。 | |
| 组织单元属性的自由格式字典。遵循 LDAP 属性名称,如  | |
| 指示是否阻止删除对象。当此 protected=true 时,如果不更改属性的值,则无法删除相应的对象。 选项 
 | |
| 删除 OU 及其包含的任何子项。 必须指定此参数才能删除非空的 OU。 选项 
 | |
| 指定 OU 的所需状态。 当 state=present 时,如果指定的 OU 尚不存在,则模块将尝试创建它。 当 state=absent 时,模块将删除指定的 OU。 当 state=absent 且 recursive=true 时,模块将删除所有 OU 以及所有子 OU。 选项 
 | 
示例
---
- name: Ensure OU is present & protected
  community.windows.win_domain_ou:
    name: AnsibleFest
    state: present
- name: Ensure OU is present & protected
  community.windows.win_domain_ou:
    name: EUC Users
    path: "DC=euc,DC=vmware,DC=lan"
    state: present
    protected: true
  delegate_to: win-ad1.euc.vmware.lab
- name: Ensure OU is absent
  community.windows.win_domain_ou:
    name: EUC Users
    path: "DC=euc,DC=vmware,DC=lan"
    state: absent
  delegate_to: win-ad1.euc.vmware.lab
- name: Ensure OU is present with specific properties
  community.windows.win_domain_ou:
    name: WS1Users
    path: "CN=EUC Users,DC=euc,DC=vmware,DC=lan"
    protected: true
    properties:
      city: Sandy Springs
      state: Georgia
      StreetAddress: 1155 Perimeter Center West
      country: US
      description: EUC Business Unit
      PostalCode: 30189
  delegate_to: win-ad1.euc.vmware.lab
- name: Ensure OU updated with new properties
  community.windows.win_domain_ou:
    name: WS1Users
    path: DC=euc,DC=vmware,DC=lan
    protected: false
    properties:
      city: Atlanta
      state: Georgia
      managedBy: jzollo@vmware.com
  delegate_to: win-ad1.euc.vmware.lab
返回值
常见的返回值已在此处记录,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| 新的/更新的组织单元参数 返回值: 当 state=present 时 示例:  | |
| 模块使用的基础组织单元路径,当提供 path=DC=Ansible,DC=Test 或由模块派生时。 返回值: 总是 示例:  | 
状态
- 此模块将在 3.0.0 版本中移除。 [已弃用] 
- 有关更多信息,请参阅已弃用。 
