Note
This module is part of the community.windows collection (version 2.4.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 community.windows.
To use it in a playbook, specify: community.windows.win_security_policy.
Parameter | Comments |
|---|---|
key string / required | The ini key of the section or policy name to modify. The module will return an error if this key is invalid. |
section string / required | The ini section the key exists in. If the section does not exist then the module will return an error. Example sections to use are ‘Account Policies’, ‘Local Policies’, ‘Event Log’, ‘Restricted Groups’, ‘System Services’, ‘Registry’ and ‘File System’ If wanting to edit the |
value string / required | The value for the ini key or policy name. If the key takes in a boolean value then 0 = False and 1 = True. |
Note
SecEdit.exe /export /cfg C:\temp\output.ini to view the current policies set on your system.See also
Manage Windows User Rights.
- name: Change the guest account name
community.windows.win_security_policy:
section: System Access
key: NewGuestName
value: Guest Account
- name: Set the maximum password age
community.windows.win_security_policy:
section: System Access
key: MaximumPasswordAge
value: 15
- name: Do not store passwords using reversible encryption
community.windows.win_security_policy:
section: System Access
key: ClearTextPassword
value: 0
- name: Enable system events
community.windows.win_security_policy:
section: Event Audit
key: AuditSystemEvents
value: 1
Common return values are documented here, the following are the fields unique to this module:
Key | Description |
|---|---|
import_log string | The log of the SecEdit.exe /configure job that configured the local policies. This is used for debugging purposes on failures. Returned: secedit.exe /import run and change occurred Sample: |
key string | The key in the section passed to the module to modify. Returned: success Sample: |
rc integer | The return code after a failure when running SecEdit.exe. Returned: failure with secedit calls Sample: |
section string | The section passed to the module to modify. Returned: success Sample: |
stderr string | The output of the STDERR buffer after a failure when running SecEdit.exe. Returned: failure with secedit calls Sample: |
stdout string | The output of the STDOUT buffer after a failure when running SecEdit.exe. Returned: failure with secedit calls Sample: |
value string | The value passed to the module to modify to. Returned: success Sample: |
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/windows/win_security_policy_module.html