ansible.windows.win_user 模块 – 管理本地 Windows 用户帐户
注意
此模块是 ansible.windows 集合(版本 2.5.0)的一部分。
如果您正在使用 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install ansible.windows。
要在 playbook 中使用它,请指定:ansible.windows.win_user。
概要
管理本地 Windows 用户帐户。
对于非 Windows 目标,请改用 ansible.builtin.user 模块。
参数
参数 |
注释 |
|---|---|
选择
|
|
设置用户的帐户过期日期。 此值应采用 将值设置为 |
|
只能设置 选择
|
|
用户的描述。 |
|
用户的全名。 |
|
根据 groups_action 的值,从此逗号分隔的组列表中添加或删除用户。 当 groups_action 为 自 |
|
如果为 如果为 如果为 选择
|
|
用户的指定主目录。 |
|
用户的登录脚本。 |
|
要创建、删除或修改的用户的名称。 |
|
可以选择将用户的密码设置为此(纯文本)值。 |
|
选择
|
|
选择
|
|
用户的配置文件路径。 |
|
当为 当为 当为 选择
|
|
选择
|
|
选择
|
备注
注意
返回值基于设置模块选项后的用户对象。在检查模式下运行时,这些值仍然反映现有用户设置,而不是它们将被更改为什么。
另请参阅
另请参阅
- ansible.builtin.user
管理用户帐户。
- ansible.windows.win_domain_membership
管理 Windows 主机的域/工作组会员资格。
- community.windows.win_domain_user
管理 Windows Active Directory 用户帐户。
- ansible.windows.win_group
添加和删除本地组。
- ansible.windows.win_group_membership
管理 Windows 本地组成员资格。
- community.windows.win_user_profile
管理 Windows 用户配置文件。
示例
- 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
返回值
常见返回值记录在此处,以下是此模块独有的字段
键 |
描述 |
|---|---|
用户是否被禁用。 返回: 用户存在 示例: |
|
用户是否被锁定。 返回: 用户存在 示例: |
|
为用户设置的描述。 返回: 用户存在 示例: |
|
为用户设置的全名。 返回: 用户存在 示例: |
|
用户所属的组列表及其 ADSI 路径。 返回: 用户存在 示例: |
|
用户名 返回: 总是 示例: |
|
密码是否已过期。 返回: 用户存在 示例: |
|
密码是否设置为永不过期。 返回: 用户存在 示例: |
|
用户的 ADSI 路径。 返回: 用户存在 示例: |
|
用户的 SID。 返回: 用户存在 示例: |
|
用户是否可以更改自己的密码。 返回: 用户存在 示例: |