Skip to content

Commit b29fae9

Browse files
authored
add auditd filtering tasks/vars (splunk#207)
* add auditd filtering tasks/vars
1 parent c507480 commit b29fae9

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ Note: Any task with an **adhoc** prefix means that it can be used independently
134134
- **check_splunk.yml** - Check if Splunk is installed. If Splunk is not installed, it will be installed on the host. If Splunk is already installed, the task will execute a "splunk version" command on the host, and then compare the version and build number of Splunk to the version and build number of the expected version of Splunk. Note that the expected version of Splunk does not need to be statically defined; The expected Splunk version and build are automatically extracted from the value of splunk_package_url_full or splunk_package_url_uf using Jinja regex filters. This task will work for both the Universal Forwarder and full Splunk Enterprise packages. You define which host uses what package by organizing it under the appropriate group ('full' or 'uf') in your Ansible inventory.
135135
- **check_decrypted_secret.yml** - Check the decrypted value of a given `pass4SymmKey`. This can be called by a task to compare the desired value with the currently configured value to see if they match. This pervents unnessecary changes to be applied.
136136
- **configure_apps.yml** - This task should be called directly from a playbook in order to deploy apps or configurations (from git repositories) to Splunk hosts. Tip: Add a this task to a playbook after the check_splunk.yml play. Doing so will perform a "install (or upgrade) and deploy apps" run, all in one playbook.
137+
- **configure_auditd.yml** - Configure auditd filtering rules to exclude splunk launched executables. Disabled by default, but can be enabled by setting `splunk_auditd_configure` to `true`.
137138
- **configure_authentication.yml** - Uses the template identified by the `splunk_authenticationconf` variable to install an authentication.conf file to $SPLUNK_HOME/etc/system/local/authentication.conf. We are including this task here since Ansible is able to securely deploy an authentication.conf configuration by using ansible-vault to encrypt sensitive values such as the value of the `ad_bind_password` variable. Note: If you are using a common splunk.secret file, you can omit this task and instead use configure_apps.yml to deploy an authentication.conf file from a Git repository containing an authentication.conf app with pre-hashed credentials.
138139
- **configure_bash.yml** - Configures bashrc and bash_profile files for the splunk user. Please note that the templates included with this role will overwrite any existing files for the splunk user (if they exist). The templates will define a custom PS1 at the bash prompt, configure the $SPLUNK_HOME environment variable so that you can issue "splunk <command>" without specifying the full path to the Splunk binary, and will enable auto-completion of Splunk CLI commands in bash.
139140
- **configure_deploymentclient.yml** - Generates a new deploymentclient.conf file from the deploymentclient.conf.j2 template and installs it to $SPLUNK_HOME/etc/system/local/deploymentclient.conf. This task is included automatically during new installations when values have been configured for the `clientName` and `splunk_uri_ds` variables.

roles/splunk/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ git_project: undefined
5151
git_version: master # Configure default version to clone, overridable inside the git_apps dictionary within host_vars
5252
app_relative_path: # set a sub-path you want to sync within a repo. If the repo contains multiple apps in the root directory, just set this to a trailing slash.
5353
splunk_app_deploy_path: undefined # Path under $SPLUNK_HOME/ to deploy apps to - Note that this may be set in group_vars, host_vars, playbook vars, or inside the git_apps dictionary within host_vars
54+
splunk_auditd_configure: false # Whether or not to install auditd filtering rules for splunk launched executables
5455
# IDXC Vars
5556
splunk_idxc_key: mypass4symmkey
5657
splunk_idxc_rf: 2

roles/splunk/tasks/check_splunk.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
- name: Configure license
1616
include_tasks: configure_license.yml
1717

18+
# Configure auditd for both fresh and old installs
19+
- name: Configure Auditd
20+
include_tasks: configure_auditd.yml
21+
when: splunk_auditd_configure
22+
1823
- name: Execute this block only if splunk is already installed
1924
block:
2025

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
- name: "get {{ splunk_nix_user }} user uid"
3+
getent:
4+
database: passwd
5+
key: "{{ splunk_nix_user }}"
6+
7+
- name: auditd - set 20-splunk.rules
8+
become: true
9+
template:
10+
src: 20-splunk.rules.j2
11+
dest: /etc/audit/rules.d/20-splunk.rules
12+
mode: 0600
13+
owner: root
14+
group: root
15+
register: splunk_rule
16+
17+
- name: Get auditd enabled level
18+
become: true
19+
shell: auditctl -s | grep enabled | cut -d" " -f2
20+
changed_when: false
21+
check_mode: false
22+
register: auditctl_enabled
23+
24+
# restart auditd if not immutable
25+
- name: restart auditd if not immutable
26+
become: true
27+
service:
28+
name: auditd
29+
state: restarted
30+
use: service
31+
when:
32+
- splunk_rule is changed
33+
- auditctl_enabled.stdout != '2'
34+
tags: molecule-notest
35+
36+
# if immutable output "auditd immutable - OS REBOOT REQUIRED"
37+
- name: auditd immutable # noqa no-handler
38+
debug:
39+
msg: "auditd immutable - OS REBOOT REQUIRED"
40+
when:
41+
- splunk_rule is changed
42+
- auditctl_enabled.stdout == '2'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-a never,exit -F path={{ splunk_home }}/bin/splunkd -F uid={{ ansible_facts.getent_passwd[splunk_user][1] }}
2+
-a never,exit -F path={{ splunk_home }}/var/run/splunk -F uid={{ ansible_facts.getent_passwd[splunk_user][1] }}

0 commit comments

Comments
 (0)