summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/windows/win_eventlog.py
blob: 85cb948701771485ec4f329a9228eedf1a5c3339 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Copyright: (c) 2017, Andrew Saraceni <andrew.saraceni@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

# this is a windows documentation stub.  actual code lives in the .ps1
# file of the same name

ANSIBLE_METADATA = {'metadata_version': '1.1',
                    'status': ['preview'],
                    'supported_by': 'community'}

DOCUMENTATION = r'''
---
module: win_eventlog
version_added: "2.4"
short_description: Manage Windows event logs
description:
     - 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:
  name:
    description:
      - Name of the event log to manage.
    type: str
    required: yes
  state:
    description:
      - Desired state of the log and/or sources.
      - When C(sources) is populated, state is checked for sources.
      - When C(sources) is not populated, state is checked for the specified log itself.
      - If C(state) is C(clear), event log entries are cleared for the target log.
    type: str
    choices: [ absent, clear, present ]
    default: present
  sources:
    description:
      - A list of one or more sources to ensure are present/absent in the log.
      - When C(category_file), C(message_file) and/or C(parameter_file) are specified,
        these values are applied across all sources.
    type: list
  category_file:
    description:
      - For one or more sources specified, the path to a custom category resource file.
    type: path
  message_file:
    description:
      - For one or more sources specified, the path to a custom event message resource file.
    type: path
  parameter_file:
    description:
      - For one or more sources specified, the path to a custom parameter resource file.
    type: path
  maximum_size:
    description:
      - 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).
    type: str
  overflow_action:
    description:
      - The action for the log to take once it reaches its maximum size.
      - For C(DoNotOverwrite), all existing entries are kept and new entries are not retained.
      - For C(OverwriteAsNeeded), each new entry overwrites the oldest entry.
      - For C(OverwriteOlder), new log entries overwrite those older than the C(retention_days) value.
    type: str
    choices: [ DoNotOverwrite, OverwriteAsNeeded, OverwriteOlder ]
  retention_days:
    description:
      - The minimum number of days event entries must remain in the log.
      - This option is only used when C(overflow_action) is C(OverwriteOlder).
    type: int
seealso:
- module: win_eventlog_entry
author:
    - Andrew Saraceni (@andrewsaraceni)
'''

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