win_domain_membership – Manage domain/workgroup membership for a Windows host¶
Synopsis¶
Manages domain membership or workgroup membership for a Windows host. Also supports hostname changes.
This module may require subsequent use of the win_reboot action if changes are made.
Parameters¶
See Also¶
See also
- win_domain – Ensures the existence of a Windows domain
The official documentation on the win_domain module.
- win_domain_controller – Manage domain controller/member server state for a Windows host
The official documentation on the win_domain_controller module.
- win_domain_computer – Manage computers in Active Directory
The official documentation on the win_domain_computer module.
- win_domain_group – Creates, modifies or removes domain groups
The official documentation on the win_domain_group module.
- win_domain_user – Manages Windows Active Directory user accounts
The official documentation on the win_domain_user module.
- win_group – Add and remove local groups
The official documentation on the win_group module.
- win_group_membership – Manage Windows local group membership
The official documentation on the win_group_membership module.
- win_user – Manages local Windows user accounts
The official documentation on the win_user module.
Examples¶
# 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.
- hosts: winclient
gather_facts: no
tasks:
- win_domain_membership:
dns_domain_name: ansible.vagrant
hostname: mydomainclient
domain_admin_user: testguy@ansible.vagrant
domain_admin_password: password123!
domain_ou_path: "OU=Windows,OU=Servers,DC=ansible,DC=vagrant"
state: domain
register: domain_state
- 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
- hosts: winclient
gather_facts: no
tasks:
- win_domain_membership:
workgroup_name: mywg
domain_admin_user: '{{ win_domain_admin_user }}'
domain_admin_password: '{{ win_domain_admin_password }}'
state: workgroup
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
reboot_required
boolean
|
always |
True if changes were made that require a reboot.
Sample:
True
|
Status¶
This module is not guaranteed to have a backwards compatible interface. [preview]
This module is maintained by the Ansible Core Team. [core]
Red Hat Support¶
More information about Red Hat’s support of this module is available from this Red Hat Knowledge Base article.
Authors¶
Matt Davis (@nitzmahone)
Hint
If you notice any issues in this documentation, you can edit this document to improve it.