community.windows.win_security_policy 模块 – 更改本地安全策略设置

注意

此模块是 community.windows 集合 (版本 2.3.0) 的一部分。

如果您正在使用 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查是否已安装它,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.windows

要在剧本中使用它,请指定:community.windows.win_security_policy

概要

  • 允许您设置由 SecEdit.exe 配置的本地安全策略。

参数

参数

注释

key

字符串 / 必需

要修改的节或策略名称的 ini 密钥。

如果此密钥无效,则模块将返回错误。

section

字符串 / 必需

密钥所在的 ini 节。

如果节不存在,则模块将返回错误。

要使用的示例节包括“帐户策略”、“本地策略”、“事件日志”、“受限组”、“系统服务”、“注册表”和“文件系统”。

如果要编辑 Privilege Rights 节,请改用 ansible.windows.win_user_right 模块。

value

字符串 / 必需

ini 密钥或策略名称的值。

如果密钥采用布尔值,则 0 = False,1 = True。

备注

注意

  • 此模块使用 SecEdit.exe 工具来配置值,此处可以找到有关可以配置的区域和密钥的更多详细信息 https://msdn.microsoft.com/en-us/library/bb742512.aspx

  • 如果您处于域环境中,则这些策略可能由 GPO 策略设置,此模块可以暂时更改这些值,但如果值不同,则 GPO 将覆盖它。

  • 您还可以运行 SecEdit.exe /export /cfg C:\temp\output.ini 来查看系统上设置的当前策略。

  • 分配用户权限时,请改用 ansible.windows.win_user_right 模块。

另请参见

另请参见

ansible.windows.win_user_right

管理 Windows 用户权限。

示例

- 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

返回值

常见的返回值已记录在 此处,以下是此模块特有的字段

描述

import_log

字符串

配置本地策略的 SecEdit.exe /configure 作业的日志。这用于故障排除。

返回:secedit.exe /import 运行并发生更改

示例: "Completed 6 percent (0/15) \\tProcess Privilege Rights area."

key

字符串

传递给模块以修改的节中的键。

返回:成功

示例: "NewGuestName"

rc

整数

运行 SecEdit.exe 时发生故障后的返回代码。

返回:secedit 调用失败

示例: -1

section

字符串

传递给模块以修改的节。

返回:成功

示例: "System Access"

stderr

字符串

运行 SecEdit.exe 时发生故障后 STDERR 缓冲区的输出。

返回:secedit 调用失败

示例: "failed to import security policy"

stdout

字符串

运行 SecEdit.exe 时发生故障后 STDOUT 缓冲区的输出。

返回:secedit 调用失败

示例: "check log for error details"

value

字符串

传递给模块以修改到的值。

返回:成功

示例: "Guest Account"

作者

  • Jordan Borean (@jborean93)