| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 5 |
|
| 6 |
DOCUMENTATION = r''' |
| 7 |
--- |
| 8 |
module: win_security_policy |
| 9 |
short_description: Change local security policy settings |
| 10 |
description: |
| 11 |
- Allows you to set the local security policies that are configured by |
| 12 |
SecEdit.exe. |
| 13 |
options: |
| 14 |
section: |
| 15 |
description: |
| 16 |
- The ini section the key exists in. |
| 17 |
- If the section does not exist then the module will return an error. |
| 18 |
- Example sections to use are 'Account Policies', 'Local Policies', |
| 19 |
'Event Log', 'Restricted Groups', 'System Services', 'Registry' and |
| 20 |
'File System' |
| 21 |
- If wanting to edit the C(Privilege Rights) section, use the |
| 22 |
M(ansible.windows.win_user_right) module instead. |
| 23 |
type: str |
| 24 |
required: yes |
| 25 |
key: |
| 26 |
description: |
| 27 |
- The ini key of the section or policy name to modify. |
| 28 |
- The module will return an error if this key is invalid. |
| 29 |
type: str |
| 30 |
required: yes |
| 31 |
value: |
| 32 |
description: |
| 33 |
- The value for the ini key or policy name. |
| 34 |
- If the key takes in a boolean value then 0 = False and 1 = True. |
| 35 |
type: str |
| 36 |
required: yes |
| 37 |
notes: |
| 38 |
- This module uses the SecEdit.exe tool to configure the values, more details |
| 39 |
of the areas and keys that can be configured can be found here |
| 40 |
U(https://msdn.microsoft.com/en-us/library/bb742512.aspx). |
| 41 |
- If you are in a domain environment these policies may be set by a GPO policy, |
| 42 |
this module can temporarily change these values but the GPO will override |
| 43 |
it if the value differs. |
| 44 |
- You can also run C(SecEdit.exe /export /cfg C:\temp\output.ini) to view the |
| 45 |
current policies set on your system. |
| 46 |
- When assigning user rights, use the M(ansible.windows.win_user_right) module instead. |
| 47 |
seealso: |
| 48 |
- module: ansible.windows.win_user_right |
| 49 |
author: |
| 50 |
- Jordan Borean (@jborean93) |
| 51 |
''' |
| 52 |
|
| 53 |
EXAMPLES = r''' |
| 54 |
- name: Change the guest account name |
| 55 |
community.windows.win_security_policy: |
| 56 |
section: System Access |
| 57 |
key: NewGuestName |
| 58 |
value: Guest Account |
| 59 |
|
| 60 |
- name: Set the maximum password age |
| 61 |
community.windows.win_security_policy: |
| 62 |
section: System Access |
| 63 |
key: MaximumPasswordAge |
| 64 |
value: 15 |
| 65 |
|
| 66 |
- name: Do not store passwords using reversible encryption |
| 67 |
community.windows.win_security_policy: |
| 68 |
section: System Access |
| 69 |
key: ClearTextPassword |
| 70 |
value: 0 |
| 71 |
|
| 72 |
- name: Enable system events |
| 73 |
community.windows.win_security_policy: |
| 74 |
section: Event Audit |
| 75 |
key: AuditSystemEvents |
| 76 |
value: 1 |
| 77 |
''' |
| 78 |
|
| 79 |
RETURN = r''' |
| 80 |
rc: |
| 81 |
description: The return code after a failure when running SecEdit.exe. |
| 82 |
returned: failure with secedit calls |
| 83 |
type: int |
| 84 |
sample: -1 |
| 85 |
stdout: |
| 86 |
description: The output of the STDOUT buffer after a failure when running |
| 87 |
SecEdit.exe. |
| 88 |
returned: failure with secedit calls |
| 89 |
type: str |
| 90 |
sample: check log for error details |
| 91 |
stderr: |
| 92 |
description: The output of the STDERR buffer after a failure when running |
| 93 |
SecEdit.exe. |
| 94 |
returned: failure with secedit calls |
| 95 |
type: str |
| 96 |
sample: failed to import security policy |
| 97 |
import_log: |
| 98 |
description: The log of the SecEdit.exe /configure job that configured the |
| 99 |
local policies. This is used for debugging purposes on failures. |
| 100 |
returned: secedit.exe /import run and change occurred |
| 101 |
type: str |
| 102 |
sample: Completed 6 percent (0/15) \tProcess Privilege Rights area. |
| 103 |
key: |
| 104 |
description: The key in the section passed to the module to modify. |
| 105 |
returned: success |
| 106 |
type: str |
| 107 |
sample: NewGuestName |
| 108 |
section: |
| 109 |
description: The section passed to the module to modify. |
| 110 |
returned: success |
| 111 |
type: str |
| 112 |
sample: System Access |
| 113 |
value: |
| 114 |
description: The value passed to the module to modify to. |
| 115 |
returned: success |
| 116 |
type: str |
| 117 |
sample: Guest Account |
| 118 |
''' |