Debian Codegraph @

ansible_collections/microsoft/ad/plugins/modules/membership.yml

raw
1 # Copyright (c) 2022 Ansible Project
2 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
3
4 DOCUMENTATION:
5 module: membership
6 short_description: Manage domain/workgroup membership for a Windows host
7 description:
8 - Manages domain membership or workgroup membership for a Windows host. Also
9 supports hostname changes.
10 - This module may require subsequent use of the
11 M(ansible.windows.win_reboot) action if changes are made.
12 options:
13 dns_domain_name:
14 description:
15 - When I(state=domain), this is the DNS name of the domain to which the
16 targeted Windows host should be joined.
17 - This cannot be set when I(offline_join_blob) is specified.
18 type: str
19 domain_admin_user:
20 description:
21 - Username of a domain admin for the target domain (required to join or
22 leave the domain).
23 - This must be set unless I(offline_join_blob) is specified.
24 type: str
25 domain_admin_password:
26 description:
27 - Password for the specified C(domain_admin_user).
28 - This must be set unless I(offline_join_blob) is specified.
29 type: str
30 domain_ou_path:
31 description:
32 - The desired OU path for adding the computer object.
33 - This is only used when adding the target host to a domain, if it is
34 already a member then it is ignored.
35 - This cannot be set when I(offline_join_blob) is specified.
36 type: str
37 domain_server:
38 description:
39 - Specifies the domain controller to use when joining the domain.
40 type: str
41 version_added: 1.7.0
42 hostname:
43 description:
44 - The desired hostname for the Windows host.
45 - This cannot be set when I(offline_join_blob) is specified.
46 type: str
47 offline_join_blob:
48 description:
49 - The base64 string of the domain offline join blob to use when joining
50 the host to a domain.
51 - This blob can been generated by the
52 M(microsoft.ad.offline_join) module.
53 - This is mutually exclusive with I(domain_admin_user),
54 I(dns_domain_name), and I(domain_ou_path).
55 - It also cannot be used with I(hostname).
56 type: str
57 state:
58 description:
59 - Whether the target host should be a member of a domain or workgroup.
60 - When I(state=domain), I(dns_domain_name), I(domain_admin_user), and
61 I(domain_admin_password) or I(offline_join_blob) must be set.
62 - When I(state=workgroup), I(workgroup_name) must be set.
63 choices:
64 - domain
65 - workgroup
66 required: true
67 type: str
68 workgroup_name:
69 description:
70 - When I(state=workgroup), this is the name of the workgroup that the
71 Windows host should be in.
72 type: str
73 notes:
74 - This module must be run on a Windows target host.
75 - If using I(reboot=true) and changing from a domain to workgroup, the
76 connection account must be a local user that can connect to the host after
77 it has unjoined the domain. Also ensure the fully qualified module name is
78 used in the task or the I(collections) keyword includes this collection.
79 extends_documentation_fragment:
80 - ansible.builtin.action_common_attributes
81 - ansible.builtin.action_common_attributes.flow
82 - microsoft.ad.action_reboot
83 attributes:
84 check_mode:
85 support: full
86 diff_mode:
87 support: full
88 platform:
89 platforms:
90 - windows
91 action:
92 support: full
93 async:
94 support: partial
95 details: Supported for all scenarios except with I(reboot=True).
96 bypass_host_loop:
97 support: none
98 seealso:
99 - module: microsoft.ad.domain
100 - module: microsoft.ad.domain_controller
101 - module: microsoft.ad.group
102 - module: microsoft.ad.offline_join
103 - module: microsoft.ad.user
104 - module: microsoft.ad.computer
105 - module: ansible.windows.win_group
106 - module: ansible.windows.win_group_membership
107 - module: ansible.windows.win_user
108 - ref: Migration guide <ansible_collections.microsoft.ad.docsite.guide_migration.migrated_modules.win_domain_membership>
109 description: This module replaces C(ansible.windows.win_domain_membership). See the migration guide for details.
110 - module: ansible.windows.win_domain_membership
111 author:
112 - Matt Davis (@nitzmahone)
113 - Jordan Borean (@jborean93)
114
115 EXAMPLES: |
116 - name: join host to ansible.vagrant with automatic reboot
117 microsoft.ad.membership:
118 dns_domain_name: ansible.vagrant
119 hostname: mydomainclient
120 domain_admin_user: [email protected]
121 domain_admin_password: password123!
122 domain_ou_path: "OU=Windows,OU=Servers,DC=ansible,DC=vagrant"
123 state: domain
124 reboot: true
125
126 - name: join host to workgroup with manual reboot in later task
127 microsoft.ad.membership:
128 workgroup_name: mywg
129 domain_admin_user: '{{ win_domain_admin_user }}'
130 domain_admin_password: '{{ win_domain_admin_password }}'
131 state: workgroup
132 register: workgroup_res
133
134 - name: reboot host after joining workgroup
135 ansible.windows.win_reboot:
136 when: workgroup_res.reboot_required
137
138 RETURN:
139 reboot_required:
140 description: True if changes were made that require a reboot.
141 returned: always
142 type: bool
143 sample: true