Skip to content

Commit

Permalink
Fix fresh install splunk vs upgrade (#726)
Browse files Browse the repository at this point in the history
Upgrade qualifies only fro a first run. And clean up home dir for fresh install
  • Loading branch information
hendolim authored May 19, 2023
1 parent 09c73d4 commit bdc4c19
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion roles/splunk_common/tasks/get_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
# and allowing upgrades between new and old hashes of the same version.
- name: "Setting upgrade fact"
set_fact:
splunk_upgrade: "{{ 'build_location' in splunk and splunk.build_location and not splunk_install and splunk_target_version and ((splunk_target_version != splunk_current_version) or (splunk_current_build_hash != splunk_target_build_hash))| default(False) }}"
splunk_upgrade: "{{ not first_run and 'build_location' in splunk and splunk.build_location and not splunk_install and splunk_target_version and ((splunk_target_version != splunk_current_version) or (splunk_current_build_hash != splunk_target_build_hash))| default(False) }}"

# determine if we need to set up indexer clusters
- name: "Setting indexer cluster fact from config"
Expand Down
20 changes: 20 additions & 0 deletions roles/splunk_common/tasks/install_splunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@
- "{{ splunk.home }}/Python-2.7"
when: splunk_upgrade | bool

- name: Find all files to clean up in Splunk home for fresh install
find:
path: "{{ splunk.home }}"
file_type: file
ignore_errors: yes
become: yes
become_user: "{{ privileged_user }}"
register: cleanup_files
when: not splunk_upgrade

- name: Clean up Splunk home for fresh install
file:
path: "{{ item.path }}"
state: "absent"
ignore_errors: yes
become: yes
become_user: "{{ privileged_user }}"
with_items: "{{ cleanup_files.files }}"
when: not splunk_upgrade

- name: Install Splunk
include_tasks: install_splunk_{{ splunk_build_type }}.yml

Expand Down

0 comments on commit bdc4c19

Please sign in to comment.