Debian Codegraph @

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

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright 2026 Red Hat Inc.
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_notes
10 short_description: Manage notes for findings, investigations, and response plan tasks
11 description:
12 - This module allows for creation, update, and deletion of notes in Splunk Enterprise Security.
13 - Notes can be created for findings, investigations, or response plan tasks.
14 - Use C(target_type) to specify where the note should be attached.
15 - When C(state=present) without C(note_id), a new note is created.
16 - When C(state=present) with C(note_id), the existing note is updated.
17 - When C(state=absent) with C(note_id), the note is deleted.
18 - Note creation (without C(note_id)) is B(NOT idempotent). Each call creates a new note,
19 even if the content is identical. This is by design, as notes are meant to be additive
20 and multiple notes with the same content may be intentional.
21 - Note updates (with C(note_id)) B(ARE idempotent). The module compares the existing note's
22 content with the desired state and only updates if there are differences.
23 version_added: "5.1.0"
24 options:
25 target_type:
26 description:
27 - The type of object to attach the note to.
28 - Use C(finding) to attach a note to a security finding.
29 - Use C(investigation) to attach a note to an investigation.
30 - Use C(response_plan_task) to attach a note to a task within an applied response plan.
31 type: str
32 required: true
33 choices:
34 - finding
35 - investigation
36 - response_plan_task
37 state:
38 description:
39 - The desired state of the note.
40 - Use C(present) to create or update a note.
41 - Use C(absent) to delete a note (requires C(note_id)).
42 type: str
43 choices:
44 - present
45 - absent
46 default: present
47 note_id:
48 description:
49 - The ID of an existing note.
50 - Required when updating or deleting a note.
51 - When C(state=present) and C(note_id) is provided, the note is updated.
52 - When C(state=absent), C(note_id) is required to identify the note to delete.
53 type: str
54 content:
55 description:
56 - The content/body of the note.
57 - Required when C(state=present) (creating or updating a note).
58 type: str
59 finding_ref_id:
60 description:
61 - The reference ID of the finding to attach the note to.
62 - Required when C(target_type=finding).
63 - Format is typically C(uuid@@notable@@time{timestamp}).
64 type: str
65 investigation_ref_id:
66 description:
67 - The investigation UUID.
68 - Required when C(target_type=investigation) or C(target_type=response_plan_task).
69 type: str
70 response_plan_id:
71 description:
72 - The ID of the applied response plan.
73 - Required when C(target_type=response_plan_task).
74 type: str
75 phase_id:
76 description:
77 - The ID of the phase containing the task.
78 - Required when C(target_type=response_plan_task).
79 type: str
80 task_id:
81 description:
82 - The ID of the task to attach the note to.
83 - Required when C(target_type=response_plan_task).
84 type: str
85 api_namespace:
86 description:
87 - The namespace portion of the Splunk API path.
88 - Override this if your environment uses a different namespace.
89 type: str
90 default: servicesNS
91 api_user:
92 description:
93 - The user portion of the Splunk API path.
94 - Override this if your environment requires a different user context.
95 type: str
96 default: nobody
97 api_app:
98 description:
99 - The app portion of the Splunk API path.
100 - Override this if your environment uses a different app name.
101 type: str
102 default: missioncontrol
103
104 author: Ron Gershburg (@rgershbu)
105 """
106
107 EXAMPLES = """
108 # Create a note on a finding
109 - name: Add note to a finding
110 splunk.es.splunk_notes:
111 target_type: finding
112 finding_ref_id: "2008e99d-af14-4fec-89da-b9b17a81820a@@notable@@time1768225865"
113 content: "Initial investigation shows suspicious activity from external IP."
114
115 # Create a note on an investigation
116 - name: Add note to an investigation
117 splunk.es.splunk_notes:
118 target_type: investigation
119 investigation_ref_id: "590afa9c-23d5-4377-b909-cd2cfa1bc0f1"
120 content: "Escalating to security team for further analysis."
121
122 # Create a note on a response plan task
123 - name: Add note to a response plan task
124 splunk.es.splunk_notes:
125 target_type: response_plan_task
126 investigation_ref_id: "590afa9c-23d5-4377-b909-cd2cfa1bc0f1"
127 response_plan_id: "b9ef7dce-6dcd-4900-b5d5-982fc194554a"
128 phase_id: "phase-001"
129 task_id: "task-001"
130 content: "Completed isolation of affected systems."
131
132 # Update an existing note
133 - name: Update a note on a finding
134 splunk.es.splunk_notes:
135 target_type: finding
136 finding_ref_id: "2008e99d-af14-4fec-89da-b9b17a81820a@@notable@@time1768225865"
137 note_id: "note-abc123"
138 content: "Updated analysis: confirmed malicious activity."
139
140 # Delete a note from an investigation
141 - name: Delete a note from an investigation
142 splunk.es.splunk_notes:
143 target_type: investigation
144 investigation_ref_id: "590afa9c-23d5-4377-b909-cd2cfa1bc0f1"
145 note_id: "note-abc123"
146 state: absent
147
148 # Create note with custom API configuration
149 - name: Add note with custom API path
150 splunk.es.splunk_notes:
151 target_type: investigation
152 investigation_ref_id: "590afa9c-23d5-4377-b909-cd2cfa1bc0f1"
153 content: "Note content here"
154 api_namespace: "{{ es_namespace | default('servicesNS') }}"
155 api_user: "{{ es_user | default('nobody') }}"
156 api_app: "{{ es_app | default('missioncontrol') }}"
157 """
158
159 RETURN = """
160 note:
161 description: The note result containing before/after states.
162 returned: always
163 type: dict
164 contains:
165 before:
166 description: The note state before module execution (if existed).
167 type: dict
168 returned: when note existed (update/delete operations)
169 after:
170 description: The note state after module execution.
171 type: dict
172 returned: when state is present
173 contains:
174 note_id:
175 description: The unique identifier of the note.
176 type: str
177 content:
178 description: The content of the note.
179 type: str
180 sample:
181 before: null
182 after:
183 note_id: "note-abc123"
184 content: "Investigation shows suspicious activity."
185 changed:
186 description: Whether any changes were made.
187 returned: always
188 type: bool
189 sample: true
190 msg:
191 description: Message describing the result.
192 returned: always
193 type: str
194 sample: "Note created successfully"
195 """