|
17 | 17 |
|
18 | 18 | - name: Execute this block only if splunk is already installed
|
19 | 19 | 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 |
53 | 50 | # Conditional for this block
|
54 | 51 | when: splunkd_path.stat.exists == true
|
0 commit comments