|
1 | 1 | --- |
2 | 2 | # 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 |
16 | 4 | 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)) |
24 | 17 |
|
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" |
35 | 27 |
|
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.' |
44 | 38 |
|
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.' |
53 | 47 |
|
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 |
60 | 65 |
|
61 | 66 | - name: Enable splunk boot-start via initd |
62 | 67 | shell: "{{ splunk_home }}/bin/splunk enable boot-start -user {{ splunk_nix_user }} -systemd-managed 0 --answer-yes --auto-ports --no-prompt --accept-license" |
63 | 68 | 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 |
67 | 71 | notify: |
68 | 72 | - set ulimits in init.d |
69 | 73 | - reload systemctl daemon |
|
72 | 76 | - name: Enable splunk boot-start via systemd |
73 | 77 | shell: "{{ splunk_home }}/bin/splunk enable boot-start -user {{ splunk_nix_user }} -systemd-managed 1 --answer-yes --auto-ports --no-prompt --accept-license" |
74 | 78 | 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 |
78 | 81 | notify: |
79 | 82 | - reload systemctl daemon |
80 | 83 | - start splunk |
|
0 commit comments