ansible.windows.win_domain_membership 模块 – 管理 Windows 主机的域/工作组隶属关系
注意
此模块是 ansible.windows 集合(版本 2.5.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用: ansible-galaxy collection install ansible.windows
。
要在 playbook 中使用它,请指定: ansible.windows.win_domain_membership
。
已弃用
- 在以下版本中删除:
3.0.0 版本
- 原因:
此模块已移至
microsoft.ad
集合中。- 替代方案:
请改用 microsoft.ad.membership 模块。
概要
管理 Windows 主机的域隶属关系或工作组隶属关系。还支持主机名更改。
如果进行了更改,此模块可能需要在后续使用 ansible.windows.win_reboot 操作。
参数
参数 |
注释 |
---|---|
当 |
|
指定 |
|
目标域的域管理员的用户名(加入或离开域是必需的)。 |
|
用于添加计算机对象的所需 OU 路径。 这仅在将目标主机添加到域时使用,如果它已经是成员,则会忽略它。 |
|
Windows 主机的所需主机名。 |
|
目标主机应该是域的成员还是工作组的成员。 选项
|
|
当 |
另请参阅
另请参阅
- ansible.windows.win_domain
确保 Windows 域的存在。
- ansible.windows.win_domain_controller
管理 Windows 主机的域控制器/成员服务器状态。
- community.windows.win_domain_computer
管理 Active Directory 中的计算机。
- community.windows.win_domain_group
创建、修改或删除域组。
- community.windows.win_domain_user
管理 Windows Active Directory 用户帐户。
- ansible.windows.win_group
添加和删除本地组。
- ansible.windows.win_group_membership
管理 Windows 本地组成员资格。
- ansible.windows.win_user
管理本地 Windows 用户帐户。
示例
# host should be a member of domain ansible.vagrant; module will ensure the hostname is mydomainclient
# and will use the passed credentials to join domain if necessary.
# Ansible connection should use local credentials if possible.
# If a reboot is required, the second task will trigger one and wait until the host is available.
- name: Play to join the hosts to a domain
hosts: winclient
gather_facts: false
tasks:
- name: Join host to the ansible.vagrant domain
ansible.windows.win_domain_membership:
dns_domain_name: ansible.vagrant
hostname: mydomainclient
domain_admin_user: [email protected]
domain_admin_password: password123!
domain_ou_path: "OU=Windows,OU=Servers,DC=ansible,DC=vagrant"
state: domain
register: domain_state
- name: Reboot host after domain join
ansible.windows.win_reboot:
when: domain_state.reboot_required
# Host should be in workgroup mywg- module will use the passed credentials to clean-unjoin domain if possible.
# Ansible connection should use local credentials if possible.
# The domain admin credentials can be sourced from a vault-encrypted variable
- name: Play to set the hosts workgroup
hosts: winclient
gather_facts: false
tasks:
- name: Set workgroup to mywg
ansible.windows.win_domain_membership:
workgroup_name: mywg
domain_admin_user: '{{ win_domain_admin_user }}'
domain_admin_password: '{{ win_domain_admin_password }}'
state: workgroup
返回值
常见返回值记录在 此处,以下是此模块独有的字段
键 |
描述 |
---|---|
如果进行了需要重新启动的更改,则为 True。 返回: 始终 示例: |
状态
此模块将在 3.0.0 版本中删除。[已弃用]
有关更多信息,请参阅 已弃用。