Skip to content

Commit 0156009

Browse files
authored
Merge branch 'master' into decrypted_check
2 parents 95fee8c + a84800c commit 0156009

35 files changed

+443
-94
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 
44
[![GitHub release](https://img.shields.io/github/v/tag/splunk/ansible-role-for-splunk?sort=semver&label=Version)](https://github.com/splunk/ansible-role-for-splunk/releases)
55

6-
This repository contains Splunk's official Ansible role for performing Splunk administration of remote hosts over SSH. This role can manage Splunk Enterprise and Universal Forwarders that are on Linux-based platforms (CentOS/Redhat/Ubuntu), as well as deploy configurations from Git repositories. Example playbooks and inventory files are also provided to help new Ansible users make the most out of this project.
6+
This repository contains Splunk's official Ansible role for performing Splunk administration of remote hosts over SSH. This role can manage Splunk Enterprise and Universal Forwarders that are on Linux-based platforms (CentOS/Redhat/Ubuntu/Amazon Linux/OpenSUSE), as well as deploy configurations from Git repositories. Example playbooks and inventory files are also provided to help new Ansible users make the most out of this project.
77

88
ansible-role-for-splunk is used by the Splunk@Splunk team to manage Splunk's corporate deployment of Splunk.
99

@@ -125,7 +125,7 @@ This section contains additional reference documentation.
125125

126126
Note: Any task with an **adhoc** prefix means that it can be used independently as a `deployment_task` in a playbook. You can use the tasks to resolve various Splunk problems or perform one-time activities, such as decommissioning an indexer from an indexer cluster.
127127

128-
- **adhoc_clean_dispatch.yml** - This task is intended to be used for restoring service to search heads should the dispatch directory become full. You should need to use this task in a healthy environment, but it is at your disposal should the need arise. The task will stop splunk, remove all files in the dispatch directory, and then start splunk.
128+
- **adhoc_clean_dispatch.yml** - This task is intended to be used for restoring service to search heads should the dispatch directory become full. You should not need to use this task in a healthy environment, but it is at your disposal should the need arise. The task will stop splunk, remove all files in the dispatch directory, and then start splunk.
129129
- **adhoc_configure_hostname** - Configure a Splunk server's hostname using the value from inventory_hostname. It configures the system hostname, serverName in server.conf and host in inputs.conf. All Splunk configuration changes are made using the ini_file module, which will preserve any other existing configurations that may exist in server.conf and/or inputs.conf.
130130
- **adhoc_decom_indexer.yml** - Executes a splunk offline --enforce-counts command. This is useful when decommissioning one or more indexers from an indexer cluster.
131131
- **adhoc_fix_mongo.yml** - Use when Splunk is in a stopped state to fix mongodb/kvstore issues. This task ensures that permissions are set correctly on mongo's splunk.key file and deletes mongod.lock if it exists.
@@ -152,7 +152,10 @@ Note: Any task with an **adhoc** prefix means that it can be used independently
152152
- **configure_splunk_secret.yml** - Configures a common splunk.secret file from the files/authentication/splunk.secret so that pre-hashed passwords can be securely deployed. Note that changing splunk.secret will require re-encryption of any passwords that were encrypted using the previous splunk.secret since Splunk will no longer be able to decrypt them successfully.
153153
- **configure_systemd.yml** - Updates Splunk's systemd file using best practices and tips from the community. Also allows Splunk to start successfully using systemd after an upgrade without the need to run `splunk ftr --accept-license`.
154154
- **configure_thp.yml** - Installs a new systemd service (disable-thp) that disables THP for RedHat|CentOS systems 6.0+. This task is automatically called by the configure_os.yml task. Optionally, you can set `use_tuned_thp` to configure THP via `tuned` instead of a service. Default is `false`. Mote: Make sure your host does not require a specific `tuned` profile before applying this one.
155-
- **download_and_unarchive.yml** - Downloads the appropriate Splunk package to the Ansible host using `splunk_package_url` (derived automatically from the values of `splunk_package_url_full` or `splunk_package_url_uf` variables). The package is then installed to `splunk_install_path` (derived automatically in main.yml using the `splunk_install_path` and the host's membership of either a `uf` or `full` group in the inventory).
155+
- **download_and_unarchive.yml** - Downloads the appropriate Splunk package using `splunk_package_url` (derived automatically from the values of `splunk_package_url_full` or `splunk_package_url_uf` variables). The package is then installed to `splunk_install_path` (derived automatically in main.yml using the `splunk_install_path` and the host's membership of either a `uf` or `full` group in the inventory).
156+
You can set if the download/unarchive process uses the Ansible host or if each host downloads and unarchives the package individually by setting `splunk_download_local`.
157+
Default is `true` which will download the package to the Ansible host once and unarchive to each host from there.
158+
If set to `false` the package will be downloaded and unarchived to each host individually. Immediately after unarchive the package will be removed from the host.
156159
- **install_apps.yml** - *Do not call install_apps.yml directly! Use configure_apps.yml* - Called by configure_apps.yml to perform app installation on the Splunk host.
157160
- **install_splunk.yml** - *Do not call install_splunk.yml directly! Use check_splunk.yml* - Called by check_splunk.yml to install/upgrade Splunk and Splunk Universal Forwarders, as well as perform any initial configurations. This task is called by check_splunk.yml when the check determines that Splunk is not currently installed. This task will create the splunk user and splunk group, configure the bash profile for the splunk user (by calling configure_bash.yml), configure THP and ulimits (by calling configure_os.ym), download and install the appropriate Splunk package (by calling download_and_unarchive.yml), configure a common splunk.secret (by calling configure_splunk_secret.yml, if configure_secret is defined), create a deploymentclient.conf file with the splunk_ds_uri and clientName (by calling configure_deploymentclient.yml, if clientName is defined), install a user-seed.conf with a prehashed admin password (if used_seed is defined), and will then call the post_install.yml task. See post_install.yml entry for details on post-installation tasks.
158161
- **install_utilities.yml** - Installs Linux packages that are useful for troubleshooting Splunk-related issues when `install_utilities: true` and `linux_packages` is defined with a list of packages to install.
@@ -165,7 +168,7 @@ Note: Any task with an **adhoc** prefix means that it can be used independently
165168
- **splunk_restart.yml** - Restarts splunk via the service module. Used when waiting for a handler to run at the end of the play would be inappropriate.
166169
- **splunk_start.yml** - Starts splunk via the service module. Used when waiting for a handler to run at the end of the play would be inappropriate.
167170
- **splunk_stop.yml** - Stops splunk via the service module. Used when waiting for a handler to run at the end of the play would be inappropriate.
168-
- **upgrade_splunk.yml** - *Do not call upgrade_splunk.yml directly! Use check_splunk.yml* - Called by check_splunk.yml. Performs an upgrade of an existing splunk installation. Configures .bash_profile and .bashrc for splunk user (by calling configure_bash.yml), disables THP and increases ulimits (by calling configure_os.yml), kills any stale splunkd processes present (by calling adhoc_kill_splunkd.yml). Note: You should NOT run the upgrade_splunk.yml task directly from a playbook. check_splunk.yml will call upgrade_splunk.yml if it determines that an upgrade is needed; It will then download and unarchive the new version of Splunk (by calling download_and_unarchive.yml), ensure that mongod is in a good stopped state (by calling adhoc_fix_mongo.yml), and will then perform post-installation tasks using the post_install.yml task.
171+
- **upgrade_splunk.yml** - *Do not call upgrade_splunk.yml directly! Use check_splunk.yml* - Called by check_splunk.yml. Performs an upgrade of an existing splunk installation. Configures .bash_profile and .bashrc for splunk user (by calling configure_bash.yml), disables THP and increases ulimits (by calling configure_os.yml), kills any stale splunkd processes present when `splunk_force_kill` is set to `True` (by calling adhoc_kill_splunkd.yml). Note: You should NOT run the upgrade_splunk.yml task directly from a playbook. check_splunk.yml will call upgrade_splunk.yml if it determines that an upgrade is needed; It will then download and unarchive the new version of Splunk (by calling download_and_unarchive.yml), ensure that mongod is in a good stopped state (by calling adhoc_fix_mongo.yml), and will then perform post-installation tasks using the post_install.yml task.
169172

170173
## Frequently Asked Questions
171174
**Q:** What is the difference between this and splunk-ansible?
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
splunk_firewall_ports:
3+
- "{{ splunkweb_port }}"
4+
- "{{ splunkapi_port }}"
5+
- "{{ splunktcpin_port }}"
6+
- "{{ splunkhec_port }}"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
splunk_firewall_ports:
3+
- "{{ splunkweb_port }}"
4+
- "{{ splunkapi_port }}"
5+
- "{{ splunktcpin_port }}"
6+
- "{{ splunkhec_port }}"
7+
- "{{ splunkidxcrep_port }}"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
splunk_firewall_ports:
3+
- "{{ splunkweb_port }}"
4+
- "{{ splunkapi_port }}"
5+
- "{{ splunkshcrep_port }}"

roles/splunk/defaults/main.yml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ slack_token: undefined
66
splunk_home: auto_determined # This gets set by main.yml but we have to define it here or Ansible will complain that it is undefined
77
splunk_package_url: auto_determined # This gets set by main.yml but we have to define it here or Ansible will complain that it is undefined
88
splunk_package_path: ~/
9-
splunk_package_version: 9.0.0.1 # The default version to install or update to. This can be set in `group_vars` or `host_vars`.
10-
build_id: 9e907cedecb1 # The default build to install or update to. This can be set in `group_vars` or `host_vars`.
9+
splunk_package_version: 9.0.4 # The default version to install or update to. This can be set in `group_vars` or `host_vars`.
10+
build_id: de405f4a7979 # The default build to install or update to. This can be set in `group_vars` or `host_vars`.
1111
splunk_package_url_full: "https://download.splunk.com/products/splunk/releases/{{ splunk_package_version }}/linux/splunk-{{ splunk_package_version }}-{{ build_id }}-Linux-x86_64.tgz"
1212
splunk_package_url_uf: "https://download.splunk.com/products/universalforwarder/releases/{{ splunk_package_version }}/linux/splunkforwarder-{{ splunk_package_version }}-{{ build_id }}-Linux-x86_64.tgz"
13+
splunk_download_local: true # This defines how the download process works. If `true` it will download to localhost and copy around to hosts from there. If `false` each host will download the package individually.
1314
splunk_install_type: undefined # There are two ways to configure this. The easiest way is to nest hosts under either a "full" group or a "uf" group in your inventory and main.yml will handle it for you. Or, you can also set the value via a group_vars or host_vars file.
1415
splunk_install_path: /opt # Base directory on the operating system to which splunk should be installed
1516
least_privileged: false # Do not change. This get automatically set in `tasks/main.yml` based on the version and install type.
1617
splunk_nix_user: splunk
1718
splunk_nix_group: splunk
19+
local_os_user: false # Whenther or not to force creation of a user using the `luseradd` or not.
20+
local_os_group: false # Whether or not to force creation of a group using the `lgroupadd` or not.
1821
splunk_uri_lm: undefined
1922
splunk_license_file: [] # This can be a list of license files to copy to the host.
2023
splunk_license_group: Trial # The default matches with the group splunk ships with. You can also set the value via a group_vars or host_vars file.
@@ -35,6 +38,7 @@ splunk_authenticationconf: authentication.conf.j2
3538
splunk_create_polkit: 0 # If set to 1 `enable boot-start` will create a polkit rules file allowing the 'splunk_nix_user' to restart the splunk service without authentication.
3639
splunk_use_initd: false # If set to true, the system will use init.d. Default false
3740
splunk_use_systemd: true # DO NOT EDIT. To use init.d, set `splunk_use_initd` to true.
41+
splunk_force_kill: False
3842
systemd_unit_full: Splunkd # You can change this in `host_vars` or `group_vars` to customize the service name.
3943
systemd_unit_uf: SplunkForwarder # You can change this in `host_vars` or `group_vars` to customize the service name.
4044
splunk_disable_mgmt_port: false # If set to true, will disable splunkd management port during installation
@@ -72,19 +76,16 @@ add_pstack_script: false # Set to true to install a pstack generation script for
7276
configure_dmesg: false
7377
install_utilities: false # Set to true to install the list of packages defined in the linux_packages var after installing splunk
7478
use_tuned_thp: false
75-
linux_packages:
76-
- nload
77-
- iotop
78-
- iftop
79-
- sysstat
80-
- telnet
81-
- tcpdump
82-
- htop
83-
- atop
84-
- lsof
85-
- policycoreutils-python
86-
- policycoreutils
87-
- setroubleshoot
88-
- nethogs
89-
- gdb
90-
- bind-utils
79+
# Firewall configs
80+
configure_firewall: false # Whether or not to configure the firewall service on your machine, if set to true, opens firewall ports using UFW (default) or Firewalld depending on OS
81+
splunk_firewall_service: splunk # The name of the Splunk firewall service to install for firewalld
82+
# Firewall port presets - reference these in group_vars to assign them to splunk
83+
splunkweb_port: {desc: "Splunk Web", protocol: "tcp", number: 8000}
84+
splunkhec_port: {desc: "Splunk HEC", protocol: "tcp", number: 8088}
85+
splunktcpin_port: {desc: "Splunk TCPIN", protocol: "tcp", number: 9997}
86+
splunkapi_port: {desc: "Splunk API", protocol: "tcp", number: "{{ splunkd_port }}"}
87+
splunkidxcrep_port: {desc: "Splunk Indexer Clustering Replication", protocol: "tcp", number: "{{ splunk_idxc_rep_port }}"}
88+
splunkshcrep_port: {desc: "Splunk Search Head Clustering Replication", protocol: "tcp", number: "{{ splunk_shc_rep_port }}"}
89+
splunk_firewall_ports: # List of ports to allow through local firewall in dict form
90+
- "{{ splunkweb_port }}"
91+
- "{{ splunkapi_port }}"

roles/splunk/handlers/main.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
when: splunk_use_initd and ansible_os_family == "RedHat" and ansible_distribution_major_version|int > 6
1717

1818
- name: reload systemctl daemon
19+
when: ansible_service_mgr == "systemd"
1920
systemd:
2021
daemon_reload: true
2122
become: true
@@ -72,7 +73,9 @@
7273
when: not start_splunk_handler_fired
7374

7475
- name: restart redhat auditd service
75-
command: service auditd condrestart
76+
shell: |
77+
service auditd stop
78+
service auditd start
7679
become: true
7780
when: ansible_os_family == 'RedHat'
7881

@@ -88,3 +91,7 @@
8891
port: "{{ splunkd_port }}"
8992
state: started
9093
delay: 5
94+
95+
- name: reload firewalld
96+
command: firewall-cmd --reload
97+
become: true

roles/splunk/tasks/configure_authentication.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
- splunk_authenticationconf is defined
1111
- ad_bind_password != 'undefined'
1212
notify: restart splunk
13+
no_log: true

roles/splunk/tasks/configure_deploymentclient.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@
5959
when:
6060
- splunk_ds_key != 'undefined'
6161
- encrypted_secret_value.stdout == "" or (splunk_ds_key != decrypted_secret_value.stdout | default(''))
62+
no_log: true

roles/splunk/tasks/configure_dmc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
loop: "{{ query('inventory_hostnames', 'all:!indexer') }}"
1313
become: true
1414
become_user: "{{ splunk_nix_user }}"
15+
no_log: true
1516

1617
- name: Configure monitoring console in auto mode
1718
community.general.ini_file:

roles/splunk/tasks/configure_facl.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
---
22
- name: Configure file access control list (facl) settings for splunk user
33
block:
4+
- name: Install acl package
5+
package:
6+
name: "acl"
7+
state: present
8+
become: True
49
- name: Set default facl to allow splunk user to read /var/log
510
acl:
611
path: /var/log
@@ -15,13 +20,12 @@
1520
- true
1621
- false
1722

18-
- name: Add logrotate script to enforce splunk user facls
19-
template:
20-
src: splunk_facl.j2
21-
dest: /etc/logrotate.d/splunk_facl
22-
owner: root
23-
group: root
24-
become: true
23+
- name: Add setfacl to logrotate script
24+
lineinfile:
25+
path: "{{ logrotate_file }}"
26+
insertbefore: 'endscript'
27+
line: ' /usr/bin/setfacl -Rm u:{{ splunk_nix_user }}:rx /var/log'
28+
become: True
2529

2630
- name: Check if auditd.conf is present
2731
stat:
@@ -41,6 +45,4 @@
4145
- restart non-redhat auditd service
4246
when: result_auditd_conf.stat.exists
4347

44-
when:
45-
- least_privileged == false or "'full' in group_names"
46-
- splunk_nix_user != 'root'
48+
when: not least_privileged

0 commit comments

Comments
 (0)