community.windows.win_eventlog 模块 – 管理 Windows 事件日志
注意
此模块是 community.windows 集合(版本 2.3.0)的一部分。
如果您正在使用 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.windows。
要在 playbook 中使用它,请指定:community.windows.win_eventlog。
概要
- 允许添加、清除和删除本地 Windows 事件日志,以及在给定事件日志中创建和删除源。还允许指定每个日志和源的设置。 
参数
| 参数 | 注释 | 
|---|---|
| 对于指定的一个或多个源,自定义类别资源文件的路径。 | |
| 事件日志的最大大小。 值必须介于 64KB 和 4GB 之间,并且可被 64KB 整除。 大小可以以 KB、MB 或 GB 为单位指定(例如 128KB、16MB、2.5GB)。 | |
| 对于指定的一个或多个源,自定义事件消息资源文件的路径。 | |
| 要管理的事件日志的名称。 | |
| 日志达到最大大小时要采取的操作。 对于  对于  对于  选项 
 | |
| 对于指定的一个或多个源,自定义参数资源文件的路径。 | |
| 事件条目必须保留在日志中的最少天数。 此选项仅在  | |
| 要确保在日志中存在/不存在的一个或多个源的列表。 当指定  | |
| 日志和/或源的所需状态。 当填充  当未填充  如果  选项 
 | 
参见
另请参阅
- community.windows.win_eventlog_entry
- 将条目写入 Windows 事件日志。 
示例
- name: Add a new event log with two custom sources
  community.windows.win_eventlog:
    name: MyNewLog
    sources:
      - NewLogSource1
      - NewLogSource2
    state: present
- name: Change the category and message resource files used for NewLogSource1
  community.windows.win_eventlog:
    name: MyNewLog
    sources:
      - NewLogSource1
    category_file: C:\NewApp\CustomCategories.dll
    message_file: C:\NewApp\CustomMessages.dll
    state: present
- name: Change the maximum size and overflow action for MyNewLog
  community.windows.win_eventlog:
    name: MyNewLog
    maximum_size: 16MB
    overflow_action: DoNotOverwrite
    state: present
- name: Clear event entries for MyNewLog
  community.windows.win_eventlog:
    name: MyNewLog
    state: clear
- name: Remove NewLogSource2 from MyNewLog
  community.windows.win_eventlog:
    name: MyNewLog
    sources:
      - NewLogSource2
    state: absent
- name: Remove MyNewLog and all remaining sources
  community.windows.win_eventlog:
    name: MyNewLog
    state: absent
返回值
常见的返回值记录在 此处,以下是此模块独有的字段
| 键 | 描述 | 
|---|---|
| 事件日志中存在的条目计数。 返回: 成功 示例:  | |
| 事件日志是否存在。 返回: 成功 示例:  | |
| 日志的最大大小(以 KB 为单位)。 返回: 成功 示例:  | |
| 事件日志的名称。 返回: 总是 示例:  | |
| 日志达到最大大小时采取的操作。 返回: 成功 示例:  | |
| 日志中保留条目的最少天数。 返回: 成功 示例:  | |
| 日志当前源的列表。 返回: 成功 示例:  | |
| 日志中更改(例如,重新创建、删除)的源的列表;如果没有更改源,则此列表为空。 返回: 总是 示例:  | 
