Skip to content

Commit ff19f49

Browse files
author
Mason Morales
committed
Added updated configure_splunk_boot.yml
1 parent ccf39ab commit ff19f49

File tree

1 file changed

+61
-58
lines changed

1 file changed

+61
-58
lines changed

roles/splunk/tasks/configure_splunk_boot.yml

Lines changed: 61 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,73 @@
11
---
22
# Note: Splunk must be stopped when creating or altering systemd related configurations for it
3-
- 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)
4-
command: "{{ splunk_home }}/bin/splunk status"
5-
register: splunk_status
6-
become: yes
7-
become_user: "{{ splunk_nix_user }}"
8-
changed_when: false
9-
failed_when: false
10-
when: >
11-
(systemd_boot.stat.exists and splunk_use_initd) or
12-
(initd_boot.stat.exists and not splunk_use_initd) or
13-
(not systemd_boot.stat.exists and not initd_boot.stat.exists and not splunk_use_initd)
14-
15-
- name: Block to stop splunk when systemd was detected but init.d is configured in Ansible
3+
- name: Block for checking boot-start when an existing Splunk installation has been found
164
block:
17-
- name: Stop Splunkd via systemd service name to prepare for conversion to init.d
18-
service:
19-
name: Splunkd
20-
state: stopped
21-
become: yes
22-
when:
23-
- "'full' in group_names"
5+
6+
- 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 }}"
11+
changed_when: false
12+
failed_when: false
13+
when: >
14+
((systemd_boot and splunk_use_initd) or
15+
(initd_boot.stat.exists and not splunk_use_initd) or
16+
(not systemd_boot and not initd_boot.stat.exists and not splunk_use_initd))
2417
25-
- name: Stop SplunkForwarder via systemd service name to prepare for conversion to init.d
26-
service:
27-
name: SplunkForwarder
28-
state: stopped
29-
become: yes
30-
when:
31-
- "'uf' in group_names"
32-
when:
33-
- systemd_boot.stat.exists and splunk_use_initd
34-
- splunk_status.stdout != 'splunkd is not running.'
18+
- name: Block to stop splunk when systemd was detected but init.d is configured in Ansible
19+
block:
20+
- name: Stop Splunkd via systemd service name to prepare for conversion to init.d
21+
service:
22+
name: Splunkd
23+
state: stopped
24+
become: yes
25+
when:
26+
- "'full' in group_names"
3527

36-
- name: Stop Splunk via init.d to prepare for conversion to systemd
37-
service:
38-
name: splunk
39-
state: stopped
40-
become: yes
41-
when:
42-
- initd_boot.stat.exists and not splunk_use_initd
43-
- splunk_status.stdout != 'splunkd is not running.'
28+
- name: Stop SplunkForwarder via systemd service name to prepare for conversion to init.d
29+
service:
30+
name: SplunkForwarder
31+
state: stopped
32+
become: yes
33+
when:
34+
- "'uf' in group_names"
35+
when:
36+
- systemd_boot and splunk_use_initd
37+
- splunk_status.stdout != 'splunkd is not running.'
4438

45-
- name: Stop Splunk via command if boot-start is not configured at all and systemd is configured in Ansible
46-
command: "{{ splunk_home }}/bin/splunk stop"
47-
become: yes
48-
when:
49-
- not systemd_boot.stat.exists
50-
- not initd_boot.stat.exists
51-
- not splunk_use_initd
52-
- splunk_status.stdout != 'splunkd is not running.'
39+
- name: Stop Splunk via init.d to prepare for conversion to systemd
40+
service:
41+
name: splunk
42+
state: stopped
43+
become: yes
44+
when:
45+
- initd_boot.stat.exists and not splunk_use_initd
46+
- splunk_status.stdout != 'splunkd is not running.'
5347

54-
- name: Disable boot-start if current configuration does not matched expected configuration
55-
shell: "{{ splunk_home }}/bin/splunk disable boot-start"
56-
become: yes
57-
when: >
58-
(systemd_boot.stat.exists and splunk_use_initd) or
59-
(initd_boot.stat.exists and not splunk_use_initd)
48+
- name: Stop Splunk via command if boot-start is not configured at all and systemd is configured in Ansible
49+
command: "{{ splunk_home }}/bin/splunk stop"
50+
become: yes
51+
when:
52+
- not systemd_boot
53+
- not initd_boot.stat.exists
54+
- not splunk_use_initd
55+
- splunk_status.stdout != 'splunkd is not running.'
56+
57+
- name: Disable boot-start if current configuration does not matched expected configuration
58+
shell: "{{ splunk_home }}/bin/splunk disable boot-start"
59+
become: yes
60+
when: >
61+
(systemd_boot and splunk_use_initd) or
62+
(initd_boot.stat.exists and not splunk_use_initd)
63+
64+
when: splunkd_found.stat.exists
6065

6166
- name: Enable splunk boot-start via initd
6267
shell: "{{ splunk_home }}/bin/splunk enable boot-start -user {{ splunk_nix_user }} -systemd-managed 0 --answer-yes --auto-ports --no-prompt --accept-license"
6368
become: yes
64-
when:
65-
- splunk_use_initd
66-
- systemd_boot.stat.exists or not initd_boot.stat.exists
69+
when:
70+
- splunk_use_initd and not initd_boot.stat.exists
6771
notify:
6872
- set ulimits in init.d
6973
- reload systemctl daemon
@@ -72,9 +76,8 @@
7276
- name: Enable splunk boot-start via systemd
7377
shell: "{{ splunk_home }}/bin/splunk enable boot-start -user {{ splunk_nix_user }} -systemd-managed 1 --answer-yes --auto-ports --no-prompt --accept-license"
7478
become: yes
75-
when:
76-
- not splunk_use_initd
77-
- initd_boot.stat.exists or not systemd_boot.stat.exists
79+
when:
80+
- not splunk_use_initd and not systemd_boot
7881
notify:
7982
- reload systemctl daemon
8083
- start splunk

0 commit comments

Comments
 (0)