Skip to content

Commit 3f56e9a

Browse files
authored
Shcluster fixes (#184)
* allow for custom mgmt_uri * decrypt shclustering pass4SymmKey value
1 parent 393eb51 commit 3f56e9a

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

roles/splunk/defaults/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ splunk_force_kill: False
4242
systemd_unit_full: Splunkd # You can change this in `host_vars` or `group_vars` to customize the service name.
4343
systemd_unit_uf: SplunkForwarder # You can change this in `host_vars` or `group_vars` to customize the service name.
4444
splunk_disable_mgmt_port: false # If set to true, will disable splunkd management port during installation
45+
splunk_mgmt_uri: "{{ ansible_fqdn }}" # If the `ansible_fqdn` is not resolvable by other hosts, you can set it to something like `ansible_facts.default_ipv4.address` in `host_vars` or `group_vars` to use the IP address instead.
4546
splunkd_port: 8089 # If changed, will overwrite the default port number used by splunkd
4647
git_local_clone_path: ~/ # Base directory under which repositories for app deplyoment should be cloned to
4748
git_server: undefined # e.g. ssh://git@mygithost:1234 - Note that this may be set in an all.yml group_var or inside the git_apps dictionary within host_vars
@@ -67,7 +68,7 @@ splunk_shc_rf: 3
6768
splunk_shc_rep_port: 8100
6869
splunk_shc_target_group: shc
6970
splunk_shc_deployer: "{{ groups['shdeployer'] | first }}" # If you manage multiple SHCs, configure the var value in group_vars
70-
splunk_shc_uri_list: "{% for h in groups[splunk_shc_target_group] %}https://{{ hostvars[h].ansible_fqdn }}:{{ splunkd_port }}{% if not loop.last %},{% endif %}{% endfor %}" # If you manage multiple SHCs, configure the var value in group_vars
71+
splunk_shc_uri_list: "{% for h in groups[splunk_shc_target_group] %}https://{{ hostvars[h].splunk_mgmt_uri }}:{{ splunkd_port }}{% if not loop.last %},{% endif %}{% endfor %}" # If you manage multiple SHCs, configure the var value in group_vars
7172
start_splunk_handler_fired: false # Do not change; used to prevent unnecessary splunk restarts
7273
# Linux and scripting related vars
7374
add_crashlog_script: false # Set to true to install a script and cron job to automatically cleanup splunk crash logs older than 7 days
Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
---
2-
- name: Configure shclustering stanza for deployer
2+
- name: Extract encrypted value
3+
include_tasks: check_decrypted_secret.yml
4+
vars:
5+
req_secret_conf: server
6+
req_secret_section: shclustering
7+
req_secret_option: pass4SymmKey
8+
9+
- name: Configure pass4SymmKey in shclustering stanza for deployer
310
ini_file:
411
path: "{{ splunk_home }}/etc/system/local/server.conf"
512
section: shclustering
6-
option: "{{ item.option }}"
7-
value: "{{ item.value }}"
13+
option: pass4SymmKey
14+
value: "{{ splunk_shc_key }}"
815
mode: 0644
916
owner: "{{ splunk_nix_user }}"
1017
group: "{{ splunk_nix_group }}"
1118
become: true
1219
notify: restart splunk
1320
no_log: true
14-
loop:
15-
- { option: "pass4SymmKey", value: "{{ splunk_shc_key }}" }
16-
- { option: "shcluster_label", value: "{{ splunk_shc_label }}" }
21+
when: encrypted_secret_value.stdout == "" or (splunk_shc_key != decrypted_secret_value.stdout | default(''))
22+
23+
- name: Configure shcluster_label in shclustering stanza for deployer
24+
community.general.ini_file:
25+
path: "{{ splunk_home }}/etc/system/local/server.conf"
26+
section: shclustering
27+
option: shcluster_label
28+
value: "{{ splunk_shc_label }}"
29+
mode: 0644
30+
owner: "{{ splunk_nix_user }}"
31+
group: "{{ splunk_nix_group }}"
32+
become: true
33+
notify: restart splunk

roles/splunk/tasks/configure_shc_members.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
- name: Initialize shc config
3-
command: "{{ splunk_home }}/bin/splunk init shcluster-config -auth {{ splunk_auth }} -mgmt_uri https://{{ ansible_fqdn }}:{{ splunkd_port }} -replication_port {{ splunk_shc_rep_port }} -replication_factor {{ splunk_shc_rf }} -conf_deploy_fetch_url https://{{ splunk_shc_deployer }}:{{ splunkd_port }} -secret {{ splunk_shc_key }} -shcluster_label {{ splunk_shc_label }}"
3+
command: "{{ splunk_home }}/bin/splunk init shcluster-config -auth {{ splunk_auth }} -mgmt_uri https://{{ splunk_mgmt_uri }}:{{ splunkd_port }} -replication_port {{ splunk_shc_rep_port }} -replication_factor {{ splunk_shc_rf }} -conf_deploy_fetch_url https://{{ splunk_shc_deployer }}:{{ splunkd_port }} -secret {{ splunk_shc_key }} -shcluster_label {{ splunk_shc_label }}"
44
become: true
55
become_user: "{{ splunk_nix_user }}"
66
register: shc_init_result

roles/splunk/tasks/slack_messenger.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
ignore_errors: true
1010
run_once: true
1111
loop:
12-
- "****************\n*Starting new Ansible play...*\n```Ansible Role: {{ role_name }}\nAnsible Task: {{ deployment_task }}\nTarget Host: {{ ansible_fqdn }}\nStart Time: {{ ansible_date_time.iso8601 }}```"
12+
- "****************\n*Starting new Ansible play...*\n```Ansible Role: {{ role_name }}\nAnsible Task: {{ deployment_task }}\nTarget Host: {{ ansible_facts.hostname }}\nStart Time: {{ ansible_date_time.iso8601 }}```"
1313
when:
1414
- slack_token != 'undefined'
1515
- slack_channel != 'undefined'

0 commit comments

Comments
 (0)