Debian Codegraph @

ansible_collections/splunk/es/plugins/modules/splunk_data_inputs_network.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright 2022 Red Hat
5 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 DOCUMENTATION = """
8 ---
9 module: splunk_data_inputs_network
10 short_description: Manage Splunk Data Inputs of type TCP or UDP resource module
11 description:
12 - Module that allows to add/update or delete of TCP and UDP Data Inputs in Splunk.
13 version_added: "2.1.0"
14 options:
15 config:
16 description:
17 - Manage and preview protocol input data.
18 type: list
19 elements: dict
20 suboptions:
21 name:
22 description:
23 - The input port which receives raw data.
24 required: true
25 type: str
26 protocol:
27 description:
28 - Choose whether to manage TCP or UDP inputs
29 required: true
30 choices:
31 - 'tcp'
32 - 'udp'
33 type: str
34 connection_host:
35 description:
36 - Set the host for the remote server that is sending data.
37 - C(ip) sets the host to the IP address of the remote server sending data.
38 - C(dns) sets the host to the reverse DNS entry for the IP address of the remote server sending data.
39 - C(none) leaves the host as specified in inputs.conf, which is typically the Splunk system hostname.
40 type: str
41 choices:
42 - "ip"
43 - "dns"
44 - "none"
45 datatype:
46 description:
47 - C(cooked) lets one access cooked TCP input information and create new containers for managing cooked data.
48 - C(raw) lets one manage raw tcp inputs from forwarders.
49 - C(splunktcptoken) lets one manage receiver access using tokens.
50 - C(ssl) Provides access to the SSL configuration of a Splunk server.
51 This option does not support states I(deleted) and I(replaced).
52 choices:
53 - "cooked"
54 - "raw"
55 - "splunktcptoken"
56 - "ssl"
57 required: false
58 type: str
59 disabled:
60 description:
61 - Indicates whether the input is disabled.
62 type: bool
63 host:
64 description:
65 - Host from which the indexer gets data.
66 type: str
67 index:
68 description:
69 - default Index to store generated events.
70 type: str
71 no_appending_timestamp:
72 description:
73 - If set to true, prevents Splunk software from prepending a timestamp and hostname to incoming events.
74 - Only for UDP data input configuration.
75 type: bool
76 no_priority_stripping:
77 description:
78 - If set to true, Splunk software does not remove the priority field from incoming syslog events.
79 - Only for UDP data input configuration.
80 type: bool
81 queue:
82 description:
83 - Specifies where the input processor should deposit the events it reads. Defaults to parsingQueue.
84 - Set queue to parsingQueue to apply props.conf and other parsing rules to your data. For more
85 information about props.conf and rules for timestamping and linebreaking, refer to props.conf and
86 the online documentation at "Monitor files and directories with inputs.conf"
87 - Set queue to indexQueue to send your data directly into the index.
88 - Only applicable for "/tcp/raw" and "/udp" APIs
89 choices:
90 - "parsingQueue"
91 - "indexQueue"
92 type: str
93 raw_tcp_done_timeout:
94 description:
95 - Specifies in seconds the timeout value for adding a Done-key.
96 - If a connection over the port specified by name remains idle after receiving data for specified
97 number of seconds, it adds a Done-key. This implies the last event is completely received.
98 - Only for TCP raw input configuration.
99 type: int
100 restrict_to_host:
101 description:
102 - Allows for restricting this input to only accept data from the host specified here.
103 type: str
104 ssl:
105 description:
106 - Enable or disble ssl for the data stream
107 type: bool
108 source:
109 description:
110 - Sets the source key/field for events from this input. Defaults to the input file path.
111 - Sets the source key initial value. The key is used during parsing/indexing, in particular to set
112 the source field during indexing. It is also the source field used at search time. As a convenience,
113 the chosen string is prepended with 'source::'.
114 - Note that Overriding the source key is generally not recommended. Typically, the input layer provides a
115 more accurate string to aid in problem analysis and investigation, accurately recording the file from
116 which the data was retrieved. Consider use of source types, tagging, and search wildcards before
117 overriding this value.
118 type: str
119 sourcetype:
120 description:
121 - Set the source type for events from this input.
122 - '"sourcetype=" is automatically prepended to <string>.'
123 - Defaults to audittrail (if signedaudit=true) or fschange (if signedaudit=false).
124 type: str
125 token:
126 description:
127 - Token value to use for SplunkTcpToken. If unspecified, a token is generated automatically.
128 type: str
129 password:
130 description:
131 - Server certificate password, if any.
132 - Only for TCP SSL configuration.
133 type: str
134 require_client_cert:
135 description:
136 - Determines whether a client must authenticate.
137 - Only for TCP SSL configuration.
138 type: str
139 root_ca:
140 description:
141 - Certificate authority list (root file).
142 - Only for TCP SSL configuration.
143 type: str
144 server_cert:
145 description:
146 - Full path to the server certificate.
147 - Only for TCP SSL configuration.
148 type: str
149 cipher_suite:
150 description:
151 - Specifies list of acceptable ciphers to use in ssl.
152 - Only obtained for TCP SSL configuration present on device.
153 type: str
154
155 running_config:
156 description:
157 - The module, by default, will connect to the remote device and retrieve the current
158 running-config to use as a base for comparing against the contents of source.
159 There are times when it is not desirable to have the task get the current running-config
160 for every task in a playbook. The I(running_config) argument allows the implementer
161 to pass in the configuration to use as the base config for comparison. This
162 value of this option should be the output received from device by executing
163 command.
164 type: str
165 state:
166 description:
167 - The state the configuration should be left in
168 type: str
169 choices:
170 - merged
171 - replaced
172 - deleted
173 - gathered
174 default: merged
175
176 author: Ansible Security Automation Team (@pranav-bhatt) <https://github.com/ansible-security>
177 """
178
179 EXAMPLES = """
180
181 # Using gathered
182 # --------------
183
184 - name: Gathering information about TCP Cooked Inputs
185 splunk.es.splunk_data_inputs_network:
186 config:
187 - protocol: tcp
188 datatype: cooked
189 state: gathered
190
191 # RUN output:
192 # -----------
193
194 # "gathered": [
195 # {
196 # "connection_host": "ip",
197 # "disabled": true,
198 # "host": "$decideOnStartup",
199 # "index": "default",
200 # "name": "8101"
201 # },
202 # {
203 # "disabled": false,
204 # "host": "$decideOnStartup",
205 # "index": "default",
206 # "name": "9997"
207 # },
208 # {
209 # "connection_host": "ip",
210 # "disabled": true,
211 # "host": "$decideOnStartup",
212 # "index": "default",
213 # "name": "default:8101",
214 # "restrict_to_host": "default"
215 # }
216 # ]
217
218
219 - name: Gathering information about TCP Cooked Inputs by Name
220 splunk.es.splunk_data_inputs_network:
221 config:
222 - protocol: tcp
223 datatype: cooked
224 name: 9997
225 state: gathered
226
227 # RUN output:
228 # -----------
229
230 # "gathered": [
231 # {
232 # "datatype": "cooked",
233 # "disabled": false,
234 # "host": "$decideOnStartup",
235 # "name": "9997",
236 # "protocol": "tcp"
237 # }
238 # ]
239
240
241 - name: Gathering information about TCP Raw Inputs
242 splunk.es.splunk_data_inputs_network:
243 config:
244 - protocol: tcp
245 datatype: raw
246 state: gathered
247
248 # RUN output:
249 # -----------
250
251 # "gathered": [
252 # {
253 # "connection_host": "ip",
254 # "disabled": false,
255 # "host": "$decideOnStartup",
256 # "index": "default",
257 # "name": "8099",
258 # "queue": "parsingQueue",
259 # "raw_tcp_done_timeout": 10
260 # },
261 # {
262 # "connection_host": "ip",
263 # "disabled": true,
264 # "host": "$decideOnStartup",
265 # "index": "default",
266 # "name": "default:8100",
267 # "queue": "parsingQueue",
268 # "raw_tcp_done_timeout": 10,
269 # "restrict_to_host": "default",
270 # "source": "test_source",
271 # "sourcetype": "test_source_type"
272 # }
273 # ]
274
275 - name: Gathering information about TCP Raw inputs by Name
276 splunk.es.splunk_data_inputs_network:
277 config:
278 - protocol: tcp
279 datatype: raw
280 name: 8099
281 state: gathered
282
283 # RUN output:
284 # -----------
285
286 # "gathered": [
287 # {
288 # "connection_host": "ip",
289 # "datatype": "raw",
290 # "disabled": false,
291 # "host": "$decideOnStartup",
292 # "index": "default",
293 # "name": "8099",
294 # "protocol": "tcp",
295 # "queue": "parsingQueue",
296 # "raw_tcp_done_timeout": 10
297 # }
298 # ]
299
300 - name: Gathering information about TCP SSL configuration
301 splunk.es.splunk_data_inputs_network:
302 config:
303 - protocol: tcp
304 datatype: ssl
305 state: gathered
306
307 # RUN output:
308 # -----------
309
310 # "gathered": [
311 # {
312 # "cipher_suite": <cipher-suites>,
313 # "disabled": true,
314 # "host": "$decideOnStartup",
315 # "index": "default",
316 # "name": "test_host"
317 # }
318 # ]
319
320 - name: Gathering information about TCP SplunkTcpTokens
321 splunk.es.splunk_data_inputs_network:
322 config:
323 - protocol: tcp
324 datatype: splunktcptoken
325 state: gathered
326
327 # RUN output:
328 # -----------
329
330 # "gathered": [
331 # {
332 # "disabled": false,
333 # "host": "$decideOnStartup",
334 # "index": "default",
335 # "name": "splunktcptoken://test_token1",
336 # "token": <token1>
337 # },
338 # {
339 # "disabled": false,
340 # "host": "$decideOnStartup",
341 # "index": "default",
342 # "name": "splunktcptoken://test_token2",
343 # "token": <token2>
344 # }
345 # ]
346
347 # Using merged
348 # ------------
349
350 - name: To add the TCP raw config
351 splunk.es.splunk_data_inputs_network:
352 config:
353 - protocol: tcp
354 datatype: raw
355 name: 8100
356 connection_host: ip
357 disabled: true
358 raw_tcp_done_timeout: 9
359 restrict_to_host: default
360 queue: parsingQueue
361 source: test_source
362 sourcetype: test_source_type
363 state: merged
364
365 # RUN output:
366 # -----------
367
368 # "after": [
369 # {
370 # "connection_host": "ip",
371 # "datatype": "raw",
372 # "disabled": true,
373 # "host": "$decideOnStartup",
374 # "index": "default",
375 # "name": "default:8100",
376 # "protocol": "tcp",
377 # "queue": "parsingQueue",
378 # "raw_tcp_done_timeout": 9,
379 # "restrict_to_host": "default",
380 # "source": "test_source",
381 # "sourcetype": "test_source_type"
382 # }
383 # ],
384 # "before": [
385 # {
386 # "connection_host": "ip",
387 # "datatype": "raw",
388 # "disabled": true,
389 # "host": "$decideOnStartup",
390 # "index": "default",
391 # "name": "default:8100",
392 # "protocol": "tcp",
393 # "queue": "parsingQueue",
394 # "raw_tcp_done_timeout": 10,
395 # "restrict_to_host": "default",
396 # "source": "test_source",
397 # "sourcetype": "test_source_type"
398 # }
399 # ]
400
401 - name: To add the TCP cooked config
402 splunk.es.splunk_data_inputs_network:
403 config:
404 - protocol: tcp
405 datatype: cooked
406 name: 8101
407 connection_host: ip
408 disabled: false
409 restrict_to_host: default
410 state: merged
411
412 # RUN output:
413 # -----------
414
415 # "after": [
416 # {
417 # "connection_host": "ip",
418 # "datatype": "cooked",
419 # "disabled": false,
420 # "host": "$decideOnStartup",
421 # "name": "default:8101",
422 # "protocol": "tcp",
423 # "restrict_to_host": "default"
424 # }
425 # ],
426 # "before": [
427 # {
428 # "connection_host": "ip",
429 # "datatype": "cooked",
430 # "disabled": true,
431 # "host": "$decideOnStartup",
432 # "name": "default:8101",
433 # "protocol": "tcp",
434 # "restrict_to_host": "default"
435 # }
436 # ],
437
438 - name: To add the Splunk TCP token
439 splunk.es.splunk_data_inputs_network:
440 config:
441 - protocol: tcp
442 datatype: splunktcptoken
443 name: test_token
444 state: merged
445
446 # RUN output:
447 # -----------
448
449 # "after": [
450 # {
451 # "datatype": "splunktcptoken",
452 # "name": "splunktcptoken://test_token",
453 # "protocol": "tcp",
454 # "token": <token>
455 # }
456 # ],
457 # "before": [],
458
459 - name: To add the Splunk SSL
460 splunk.es.splunk_data_inputs_network:
461 config:
462 - protocol: tcp
463 datatype: ssl
464 name: test_host
465 root_ca: {root CA directory}
466 server_cert: {server cretificate directory}
467 state: merged
468
469 # RUN output:
470 # -----------
471
472 # "after": [
473 # {
474 # "cipher_suite": <cipher suite>,
475 # "datatype": "ssl",
476 # "disabled": true,
477 # "host": "$decideOnStartup",
478 # "index": "default",
479 # "name": "test_host",
480 # "protocol": "tcp"
481 # }
482 # ],
483 # "before": []
484
485
486 # Using deleted
487 # -------------
488
489 - name: To Delete TCP Raw
490 splunk.es.splunk_data_inputs_network:
491 config:
492 - protocol: tcp
493 datatype: raw
494 name: default:8100
495 state: deleted
496
497 # RUN output:
498 # -----------
499
500 # "after": [],
501 # "before": [
502 # {
503 # "connection_host": "ip",
504 # "datatype": "raw",
505 # "disabled": true,
506 # "host": "$decideOnStartup",
507 # "index": "default",
508 # "name": "default:8100",
509 # "protocol": "tcp",
510 # "queue": "parsingQueue",
511 # "raw_tcp_done_timeout": 9,
512 # "restrict_to_host": "default",
513 # "source": "test_source",
514 # "sourcetype": "test_source_type"
515 # }
516 # ]
517
518 # Using replaced
519 # --------------
520
521 - name: Replace existing data inputs networks configuration
522 register: result
523 splunk.es.splunk_data_inputs_network:
524 state: replaced
525 config:
526 - protocol: tcp
527 datatype: raw
528 name: 8100
529 connection_host: ip
530 disabled: true
531 host: "$decideOnStartup"
532 index: default
533 queue: parsingQueue
534 raw_tcp_done_timeout: 10
535 restrict_to_host: default
536 source: test_source
537 sourcetype: test_source_type
538
539 # RUN output:
540 # -----------
541
542 # "after": [
543 # {
544 # "connection_host": "ip",
545 # "datatype": "raw",
546 # "disabled": true,
547 # "host": "$decideOnStartup",
548 # "index": "default",
549 # "name": "default:8100",
550 # "protocol": "tcp",
551 # "queue": "parsingQueue",
552 # "raw_tcp_done_timeout": 9,
553 # "restrict_to_host": "default",
554 # "source": "test_source",
555 # "sourcetype": "test_source_type"
556 # }
557 # ],
558 # "before": [
559 # {
560 # "connection_host": "ip",
561 # "datatype": "raw",
562 # "disabled": true,
563 # "host": "$decideOnStartup",
564 # "index": "default",
565 # "name": "default:8100",
566 # "protocol": "tcp",
567 # "queue": "parsingQueue",
568 # "raw_tcp_done_timeout": 10,
569 # "restrict_to_host": "default",
570 # "source": "test_source",
571 # "sourcetype": "test_source_type"
572 # }
573 # ],
574 """
575
576 RETURN = """
577 before:
578 description: The configuration prior to the module execution.
579 returned: when state is I(merged), I(replaced), I(deleted)
580 type: list
581 sample: >
582 This output will always be in the same format as the
583 module argspec.
584 after:
585 description: The resulting configuration after module execution.
586 returned: when changed
587 type: list
588 sample: >
589 This output will always be in the same format as the
590 module argspec.
591 gathered:
592 description: Facts about the network resource gathered from the remote device as structured data.
593 returned: when state is I(gathered)
594 type: dict
595 sample: >
596 This output will always be in the same format as the
597 module argspec.
598 """