Skip to content

Commit 684a575

Browse files
author
Mason Morales
authored
Merge pull request #72 from midnight5ky/add_indexer_clustering_configurations
Add indexer clustering configurations
2 parents a10a2be + c854b79 commit 684a575

File tree

7 files changed

+91
-12
lines changed

7 files changed

+91
-12
lines changed

playbooks/splunk_idxc_deploy.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Example playbook to install Splunk and configure a basic indexer cluster
2+
# Ensure that the following vars are configured: ansible_user, ansible_ssh_private_key_file, splunk_uri_lm, and splunk_admin_password
3+
- hosts:
4+
- clustermanager
5+
- indexers
6+
roles:
7+
- ../roles/splunk
8+
vars:
9+
- deployment_task: check_splunk.yml
10+
11+
- hosts:
12+
- clustermanager
13+
roles:
14+
- ../roles/splunk
15+
vars:
16+
- deployment_task: configure_idxc_manager.yml
17+
18+
- hosts:
19+
- indexers
20+
roles:
21+
- ../roles/splunk
22+
vars:
23+
- deployment_task: configure_idxc_member.yml

playbooks/splunk_shc_deploy.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Ensure that the following vars are configured: ansible_user, ansible_ssh_private_key_file, splunk_admin_password, splunk_user_seed: true
33
- hosts:
44
- shdeployer
5+
- shc
56
roles:
67
- ../roles/splunk
78
vars:
@@ -14,13 +15,6 @@
1415
vars:
1516
- deployment_task: configure_shc_deployer.yml
1617

17-
- hosts:
18-
- shc
19-
roles:
20-
- ../roles/splunk
21-
vars:
22-
- deployment_task: check_splunk.yml
23-
2418
- hosts:
2519
- shc
2620
roles:

roles/splunk/defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ git_key: undefined # Path to SSH key for cloning repositories - Note that this m
3636
git_project: undefined
3737
git_version: master # Configure default version to clone, overridable inside the git_apps dictionary within host_vars
3838
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
39+
# IDXC Vars
40+
splunk_idxc_key: mypass4symmkey
41+
splunk_idxc_rf: 2
42+
splunk_idxc_sf: 2
43+
splunk_idxc_rep_port: 9887
44+
splunk_idxc_label: myidxc
3945
splunk_apply_cluster_bundle_retries: 3 # How many times to retry indexer cluster bundle apply if it fails
4046
splunk_apply_cluster_bundle_delay: 60 # Delay in seconds between retries to apply indexer cluster bundle
4147
splunk_apply_shcluster_bundle_retries: 3 # How many times to retry SHC bundle apply if it fails

roles/splunk/tasks/check_splunk.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919
block:
2020

2121
- name: Run splunk version command to check currently installed version
22-
command: "{{ splunk_home }}/bin/splunk version --answer-yes --auto-ports --no-prompt --accept-license"
23-
register: current_version
24-
become: true
25-
become_user: "{{ splunk_nix_user }}"
26-
changed_when: false
22+
include_tasks: check_splunk_version.yml
2723

2824
- name: "Checkpoint: Version" ##########################
2925
debug:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
- name: Run splunk version command to check currently installed version
2+
command: "{{ splunk_home }}/bin/splunk version --answer-yes --auto-ports --no-prompt --accept-license"
3+
register: current_version
4+
become: true
5+
become_user: "{{ splunk_nix_user }}"
6+
changed_when: false
7+
8+
- name: Get Splunk version number only
9+
set_fact:
10+
splunk_version_release: "{{ current_version.stdout | regex_search ('\\d+\\.\\d+') }}"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
- name: Run splunk version command to check currently installed version
3+
include_tasks: check_splunk_version.yml
4+
5+
# Splunk version < 8.1 supports mode=master
6+
# https://docs.splunk.com/Documentation/Splunk/8.0.9/Indexer/Configuremasterwithserverconf
7+
# Splunk version >= 8.1 supports mode=manager
8+
# https://docs.splunk.com/Documentation/Splunk/latest/Indexer/Configuremanagerwithserverconf
9+
- name: Setting clustering mode based on Splunk version number
10+
set_fact:
11+
mode_value: "{% if splunk_version_release | int < 8.1 %}master{% else %}manager{% endif %}"
12+
13+
- name: Configure clustering stanza for cluster manager node
14+
ini_file:
15+
path: "{{ splunk_home }}/etc/system/local/server.conf"
16+
section: clustering
17+
option: "{{ item.option }}"
18+
value: "{{ item.value }}"
19+
mode: 0644
20+
owner: "{{ splunk_nix_user }}"
21+
group: "{{ splunk_nix_group }}"
22+
become: true
23+
notify: restart splunk
24+
loop:
25+
- { option: "mode", value: "{{ mode_value}}" }
26+
- { option: "replication_factor", value: "{{ splunk_idxc_rf }}" }
27+
- { option: "search_factor", value: "{{ splunk_idxc_sf }}" }
28+
- { option: "pass4SymmKey", value: "{{ splunk_idxc_key }}" }
29+
- { option: "cluster_label", value: "{{ splunk_idxc_label }}" }
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
- name: Run splunk version command to check currently installed version
3+
include_tasks: check_splunk_version.yml
4+
5+
# Splunk version >= 8.1 supports mode=peer
6+
# https://docs.splunk.com/Documentation/Splunk/latest/Indexer/ConfigurepeerswithCLI
7+
# Splunk version < 8.1 supports mode=slave
8+
# https://docs.splunk.com/Documentation/Splunk/8.0.9/Indexer/ConfigurepeerswithCLI
9+
- name: Setting clustering mode based on Splunk version number
10+
set_fact:
11+
mode_value: "{% if splunk_version_release | int < 8.1 %}slave{% else %}peer{% endif %}"
12+
13+
- name: Configure idxc member
14+
command: "{{ splunk_home }}/bin/splunk edit cluster-config -mode {{ mode_value }} -auth {{ splunk_auth }} -master_uri {{ splunk_uri_cm }} -replication_port {{ splunk_idxc_rep_port }} -secret {{ splunk_idxc_key }}"
15+
become: true
16+
become_user: "{{ splunk_nix_user }}"
17+
register: idxc_peer_init_result
18+
changed_when: idxc_peer_init_result.rc == 0
19+
failed_when: idxc_peer_init_result.rc != 0
20+
notify: restart splunk
21+
no_log: true

0 commit comments

Comments
 (0)