W3cubDocs

/Ansible

win_eventlog - Manage Windows event logs

New in version 2.4.

Synopsis

  • Allows the addition, clearing and removal of local Windows event logs, and the creation and removal of sources from a given event log. Also allows the specification of settings per log and source.

Options

parameter required default choices comments
category_file
no
For one or more sources specified, the path to a custom category resource file.
maximum_size
no
The maximum size of the event log.
Value must be between 64KB and 4GB, and divisible by 64KB.
Size can be specified in KB, MB or GB (e.g. 128KB, 16MB, 2.5GB).
message_file
no
For one or more sources specified, the path to a custom event message resource file.
name
yes
Name of the event log to manage.
overflow_action
no
  • OverwriteOlder
  • OverwriteAsNeeded
  • DoNotOverwrite
The action for the log to take once it reaches its maximum size.
For OverwriteOlder, new log entries overwrite those older than the retention_days value.
For OverwriteAsNeeded, each new entry overwrites the oldest entry.
For DoNotOverwrite, all existing entries are kept and new entries are not retained.
parameter_file
no
For one or more sources specified, the path to a custom parameter resource file.
retention_days
no
The minimum number of days event entries must remain in the log.
This option is only used when overflow_action is OverwriteOlder.
sources
no
A list of one or more sources to ensure are present/absent in the log.
When category_file, message_file and/or parameter_file are specified, these values are applied across all sources.
state
no present
  • present
  • clear
  • absent
Desired state of the log and/or sources.
When sources is populated, state is checked for sources.
When sources is not populated, state is checked for the specified log itself.
If state is clear, event log entries are cleared for the target log.

Examples

- name: Add a new event log with two custom sources
  win_eventlog:
    name: MyNewLog
    sources:
      - NewLogSource1
      - NewLogSource2
    state: present

- name: Change the category and message resource files used for NewLogSource1
  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
  win_eventlog:
    name: MyNewLog
    maximum_size: 16MB
    overflow_action: DoNotOverwrite
    state: present

- name: Clear event entries for MyNewLog
  win_eventlog:
    name: MyNewLog
    state: clear

- name: Remove NewLogSource2 from MyNewLog
  win_eventlog:
    name: MyNewLog
    sources:
      - NewLogSource2
    state: absent

- name: Remove MyNewLog and all remaining sources
  win_eventlog:
    name: MyNewLog
    state: absent

Return Values

Common return values are documented here Return Values, the following are the fields unique to this module:

name description returned type sample
name
The name of the event log.
always string MyNewLog
exists
Whether the event log exists or not.
success boolean True
sources_changed
A list of sources changed (e.g. re/created, removed) for the log; this is empty if no sources are changed.
always list ['NewLogSource2']
retention_days
The minimum number of days entries are retained in the log.
success int 7
sources
A list of the current sources for the log.
success list ['MyNewLog', 'NewLogSource1', 'NewLogSource2']
entries
The count of entries present in the event log.
success int 50
maximum_size_kb
Maximum size of the log in KB.
success int 512
overflow_action
The action the log takes once it reaches its maximum size.
success string OverwriteOlder

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.

© 2012–2017 Michael DeHaan
© 2017 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/win_eventlog_module.html