ansible.windows.win_user module – Manages local Windows user accounts
Note
This module is part of the ansible.windows collection (version 2.5.0).
You might already have this collection installed if you are using the ansible
package. It is not included in ansible-core
. To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install ansible.windows
.
To use it in a playbook, specify: ansible.windows.win_user
.
Synopsis
- Manages local Windows user accounts.
- For non-Windows targets, use the ansible.builtin.user module instead.
Parameters
Parameter | Comments |
---|---|
account_disabled boolean |
Choices:
|
account_expires string added in ansible.windows 2.4.0 | Set the account expiration date for the user. This value should be in the format Set the value to |
account_locked boolean | Only Choices:
|
description string | Description of the user. |
fullname string | Full name of the user. |
groups list / elements=string | Adds or removes the user from this comma-separated list of groups, depending on the value of groups_action. When groups_action is Since |
groups_action string | If If If Choices:
|
home_directory string added in ansible.windows 1.0.0 | The designated home directory of the user. |
login_script string added in ansible.windows 1.0.0 | The login script of the user. |
name string / required | Name of the user to create, remove or modify. |
password string | Optionally set the user’s password to this (plain text) value. |
password_expired boolean |
Choices:
|
password_never_expires boolean |
Choices:
|
profile string added in ansible.windows 1.0.0 | The profile path of the user. |
state string | When When When Choices:
|
update_password string |
Choices:
|
user_cannot_change_password boolean |
Choices:
|
Notes
Note
- The return values are based on the user object after the module options have been set. When running in check mode the values will still reflect the existing user settings and not what they would have been changed to.
See Also
See also
- ansible.builtin.user
-
Manage user accounts.
- ansible.windows.win_domain_membership
-
Manage domain/workgroup membership for a Windows host.
- community.windows.win_domain_user
-
Manages Windows Active Directory user accounts.
- ansible.windows.win_group
-
Add and remove local groups.
- ansible.windows.win_group_membership
-
Manage Windows local group membership.
- community.windows.win_user_profile
-
Manages the Windows user profiles.
Examples
- name: Ensure user bob is present ansible.windows.win_user: name: bob password: B0bP4ssw0rd state: present groups: - Users - name: Ensure user bob is absent ansible.windows.win_user: name: bob state: absent - name: Set an account expiration date to the 27th of October 2024 at 2:30PM UTC ansible.windows.win_user: name: bob state: present account_expires: '2024-10-27T14:30:00Z' - name: Set an account expiration 30 days in the future ansible.windows.win_user: name: bob state: present account_expires: '{{ "%Y-%m-%dT%H:%M:%S%z" | ansible.builtin.strftime(now().timestamp() + (60 * 60 * 24 * 30)) }}' - name: Remove account expiration date ansible.windows.win_user: name: bob state: present account_expires: never
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Description |
---|---|
account_disabled boolean | Whether the user is disabled. Returned: user exists Sample: |
account_locked boolean | Whether the user is locked. Returned: user exists Sample: |
description string | The description set for the user. Returned: user exists Sample: |
fullname string | The full name set for the user. Returned: user exists Sample: |
groups list / elements=string | A list of groups and their ADSI path the user is a member of. Returned: user exists Sample: |
name string | The name of the user Returned: always Sample: |
password_expired boolean | Whether the password is expired. Returned: user exists Sample: |
password_never_expires boolean | Whether the password is set to never expire. Returned: user exists Sample: |
path string | The ADSI path for the user. Returned: user exists Sample: |
sid string | The SID for the user. Returned: user exists Sample: |
user_cannot_change_password boolean | Whether the user can change their own password. Returned: user exists Sample: |
Collection links
© 2012–2018 Michael DeHaan
© 2018–2024 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_user_module.html