Skip to content

Commit c3efc0d

Browse files
author
Mason Morales
authored
Merge pull request #30 from splunk/updates_022321
Multiple updates
2 parents 266d630 + a34388e commit c3efc0d

File tree

10 files changed

+89
-63
lines changed

10 files changed

+89
-63
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ You may also override the auto-configured `splunk_app_deploy_path` at the reposi
9999

100100
**Configure local splunk admin password at install**
101101
```
102-
splunk_user_seed: true
103102
splunk_admin_username: youradminusername (optional, defaults to admin)
104103
splunk_admin_password: yourpassword
105104
```

roles/splunk/defaults/main.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ splunk_uri_ds: undefined # e.g. mydeploymentserver.mydomain.com:8089 ; Note that
1919
clientName: undefined
2020
splunk_admin_username: admin
2121
splunk_admin_password: undefined # Use ansible-vault encrypt_string, e.g. ansible-vault encrypt_string --ask-vault-pass 'var_value_to_encrypt' --name 'var_name'
22-
splunk_user_seed: false # Requires splunk_admin_password var to be set
2322
splunk_configure_secret: false # If set to true, you need to update files/splunk.secret
23+
splunk_secret_file: splunk.secret # Used to specify your splunk.secret filename(s), files should be placed in the "files" folder of the role
2424
# Although there are tasks for the following Splunk configurations in this role, they are not included in any tasks by default. You can add them to your install_splunk.yml if you would like to have Ansible manage any of these files
2525
splunk_configure_authentication: false
2626
ad_bind_password: undefined # Use ansible-vault encrypt_string, e.g. ansible-vault encrypt_string --ask-vault-pass 'var_value_to_encrypt' --name 'var_name'
@@ -32,6 +32,10 @@ git_key: undefined # Path to SSH key for cloning repositories - Note that this m
3232
git_project: undefined
3333
git_version: master # Configure default version to clone, overridable inside the git_apps dictionary within host_vars
3434
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
35+
splunk_apply_cluster_bundle_retries: 3 # How many times to retry indexer cluster bundle apply if it fails
36+
splunk_apply_cluster_bundle_delay: 60 # Delay in seconds between retries to apply indexer cluster bundle
37+
splunk_apply_shcluster_bundle_retries: 3 # How many times to retry SHC bundle apply if it fails
38+
splunk_apply_shcluster_bundle_delay: 60 # Delay in seconds between retries to apply SHC bundle
3539
# SHC Vars
3640
splunk_shc_key: mypass4symmkey
3741
splunk_shc_label: myshc

roles/splunk/handlers/main.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,14 @@
4141
become: yes
4242

4343
- name: apply indexer cluster bundle
44-
shell: "{{ splunk_home }}/bin/splunk apply cluster-bundle --answer-yes --skip-validation -auth {{ splunk_auth }}"
44+
command: "{{ splunk_home }}/bin/splunk apply cluster-bundle --answer-yes --skip-validation -auth {{ splunk_auth }}"
4545
become: yes
4646
become_user: "{{ splunk_nix_user }}"
47+
register: apply_cluster_bundle_result
48+
changed_when: apply_cluster_bundle_result.rc == 0
49+
failed_when: apply_cluster_bundle_result.rc != 0
50+
retries: "{{ splunk_apply_cluster_bundle_retries }}"
51+
delay: "{{ splunk_apply_cluster_bundle_delay }}"
4752
no_log: true
4853
when: "'clustermaster' in group_names"
4954

@@ -55,9 +60,14 @@
5560
when: "'deploymentserver' in group_names"
5661

5762
- name: apply shcluster-bundle
58-
shell: "{{ splunk_home }}/bin/splunk apply shcluster-bundle -preserve-lookups true --answer-yes -auth {{ splunk_auth }} -target {{ deploy_target }}"
63+
command: "{{ splunk_home }}/bin/splunk apply shcluster-bundle -preserve-lookups true --answer-yes -auth {{ splunk_auth }} -target {{ deploy_target }}"
5964
become: yes
6065
become_user: "{{ splunk_nix_user }}"
66+
register: apply_shcluster_bundle_result
67+
changed_when: apply_shcluster_bundle_result.rc == 0
68+
failed_when: apply_shcluster_bundle_result.rc != 0
69+
retries: "{{ splunk_apply_shcluster_bundle_retries }}"
70+
delay: "{{ splunk_apply_shcluster_bundle_delay }}"
6171
no_log: true
6272
when: "'shdeployer' in group_names and deploy_target is defined"
6373

roles/splunk/tasks/check_splunk.yml

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,35 @@
1717

1818
- name: Execute this block only if splunk is already installed
1919
block:
20-
# If Splunk is installed, get the current version
21-
- name: Run splunk version command to check currently installed version
22-
shell: "{{ splunk_home }}/bin/splunk version --answer-yes --auto-ports --no-prompt --accept-license"
23-
register: current_version
24-
become: yes
25-
become_user: "{{ splunk_nix_user }}"
26-
changed_when: false
27-
28-
- name: "Checkpoint: Version" ##########################
29-
debug:
30-
msg: "The value of splunk_version is: {{ splunk_version }} and the current_version is: {{ current_version.stdout }}"
31-
32-
- name: "Checkpoint: Package"
33-
debug:
34-
msg: "We will download the latest release from {{ splunk_package_url }}"
35-
when: current_version.stdout != splunk_version
36-
37-
- name: Check if Splunk needs to be stopped if we are not at the expected version
38-
shell: "{{ splunk_home }}/bin/splunk status"
39-
register: splunk_status
40-
become: yes
41-
become_user: "{{ splunk_nix_user }}"
42-
when: current_version.stdout != splunk_version
43-
changed_when: false
44-
ignore_errors: true
45-
46-
- name: Stop Splunk if not at expected version and not currently stopped
47-
include_tasks: splunk_stop.yml
48-
when: current_version.stdout != splunk_version and splunk_status.stdout != 'splunkd is not running.'
49-
50-
- name: Upgrade Splunk if not at expected version
51-
include_tasks: upgrade_splunk.yml
52-
when: current_version.stdout != splunk_version
20+
21+
- name: Run splunk version command to check currently installed version
22+
shell: "{{ splunk_home }}/bin/splunk version --answer-yes --auto-ports --no-prompt --accept-license"
23+
register: current_version
24+
become: yes
25+
become_user: "{{ splunk_nix_user }}"
26+
changed_when: false
27+
28+
- name: "Checkpoint: Version" ##########################
29+
debug:
30+
msg: "The value of splunk_version is: {{ splunk_version }} and the current_version is: {{ current_version.stdout }}"
31+
32+
- name: Execute this block only if the current version does not match the expected version
33+
block:
34+
- name: "Checkpoint: Package"
35+
debug:
36+
msg: "We will download the latest release from {{ splunk_package_url }}"
37+
38+
- name: Check if Splunk needs to be stopped if we are not at the expected version
39+
include_tasks: check_splunk_status.yml
40+
changed_when: false
41+
42+
- name: Stop Splunk if not at expected version and splunk is currently running
43+
include_tasks: splunk_stop.yml
44+
when: splunk_status.rc == 0
45+
46+
- name: Upgrade Splunk if not at expected version
47+
include_tasks: upgrade_splunk.yml
48+
# Conditional for version mismatch block
49+
when: current_version.stdout != splunk_version
5350
# Conditional for this block
5451
when: splunkd_path.stat.exists == true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: Check if Splunk is currently running or stopped
3+
command: "{{ splunk_home }}/bin/splunk status"
4+
register: splunk_status
5+
become: yes
6+
become_user: "{{ splunk_nix_user }}"
7+
changed_when: false

roles/splunk/tasks/configure_splunk_boot.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
block:
55

66
- name: Check if Splunk needs to be stopped if boot-start isn't configured as Ansible expects (or boot-start is not configured at all)
7-
command: "{{ splunk_home }}/bin/splunk status"
8-
register: splunk_status
9-
become: yes
10-
become_user: "{{ splunk_nix_user }}"
7+
include_tasks: check_splunk_status.yml
118
changed_when: false
12-
failed_when: false
139
when: >
1410
((systemd_boot and splunk_use_initd) or
1511
(initd_boot.stat.exists and not splunk_use_initd) or
@@ -34,7 +30,7 @@
3430
- "'uf' in group_names"
3531
when:
3632
- systemd_boot and splunk_use_initd
37-
- splunk_status.stdout != 'splunkd is not running.'
33+
- splunk_status.rc == 0
3834

3935
- name: Stop Splunk via init.d to prepare for conversion to systemd
4036
service:
@@ -43,7 +39,7 @@
4339
become: yes
4440
when:
4541
- initd_boot.stat.exists and not splunk_use_initd
46-
- splunk_status.stdout != 'splunkd is not running.'
42+
- splunk_status.rc == 0
4743

4844
- name: Stop Splunk via command if boot-start is not configured at all and systemd is configured in Ansible
4945
command: "{{ splunk_home }}/bin/splunk stop"
@@ -52,7 +48,7 @@
5248
- not systemd_boot
5349
- not initd_boot.stat.exists
5450
- not splunk_use_initd
55-
- splunk_status.stdout != 'splunkd is not running.'
51+
- splunk_status.rc == 0
5652

5753
- name: Disable boot-start if current configuration does not matched expected configuration
5854
shell: "{{ splunk_home }}/bin/splunk disable boot-start"

roles/splunk/tasks/configure_splunk_secret.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
- name: Install splunk.secret
22
copy:
3-
src: splunk.secret
3+
src: "{{ splunk_secret_file }}"
44
dest: "{{ splunk_home }}/etc/auth/splunk.secret"
55
owner: "{{ splunk_nix_user }}"
66
group: "{{ splunk_nix_group }}"
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
---
2-
- name: "Check for existing {{ splunk_home }}/etc/passwd"
3-
stat:
4-
path: "{{ splunk_home }}/etc/passwd"
5-
register: splunk_etc_passwd
6-
become: yes
7-
become_user: "{{ splunk_nix_user }}"
2+
- name: Execute this block only when splunk_admin_password has been configured
3+
block:
4+
- name: "Check for existing {{ splunk_home }}/etc/passwd"
5+
stat:
6+
path: "{{ splunk_home }}/etc/passwd"
7+
register: splunk_etc_passwd
8+
become: yes
9+
become_user: "{{ splunk_nix_user }}"
810

9-
- name: Create user-seed.conf file with splunk_admin_username and splunk_admin_password
10-
template:
11-
src: user-seed.conf.j2
12-
dest: "{{ splunk_home }}/etc/system/local/user-seed.conf"
13-
owner: "{{ splunk_nix_user }}"
14-
group: "{{ splunk_nix_group }}"
15-
notify: restart splunk
16-
become: yes
11+
- name: Create user-seed.conf file with splunk_admin_username and splunk_admin_password
12+
template:
13+
src: user-seed.conf.j2
14+
dest: "{{ splunk_home }}/etc/system/local/user-seed.conf"
15+
owner: "{{ splunk_nix_user }}"
16+
group: "{{ splunk_nix_group }}"
17+
become: yes
18+
when: not splunk_etc_passwd.stat.exists
1719
when:
18-
- not splunk_etc_passwd.stat.exists
19-
- splunk_user_seed
2020
- splunk_admin_password != 'undefined'

roles/splunk/tasks/install_splunk.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
- name: Include configure user-seed task
4545
include_tasks: configure_user-seed.yml
4646
when:
47-
- splunk_user_seed
4847
- splunk_admin_password != 'undefined'
4948

5049
- name: Include configure default authentication.conf for AD authentication and admin role mapping
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
- include_tasks: splunk_stop.yml
3+
4+
- name: Disable boot-start
5+
shell: "{{ splunk_home }}/bin/splunk disable boot-start"
6+
become: yes
7+
8+
- name: Remove splunk folder
9+
file:
10+
path: "{{ splunk_home }}"
11+
state: absent
12+
become: yes
13+
14+
# Todo: Remove user, group, THP/ulimit files, check for cron jobs/scripts and remove those if present

0 commit comments

Comments
 (0)