Skip to content

Commit

Permalink
Merge pull request splunk#154 from splunk/upgrade_logic
Browse files Browse the repository at this point in the history
Upgrade version logic
  • Loading branch information
Brent Boe authored Apr 4, 2019
2 parents 73bf80e + 22963af commit 260026d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 4 additions & 4 deletions roles/splunk_common/tasks/get_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
# Extracting the numbers from the Splunk installer file name allows us to know the version we are targeting.
- name: "Set target version fact"
set_fact:
splunk_target_version: "{{ splunk.build_location | regex_search(regexp, '\\1.\\2.\\3') | default('0') }}"
splunk_target_version: "{{ splunk.build_location | regex_search(regexp, '\\1') | default('0') }}"
vars:
regexp: 'splunk(?:forwarder)?-(\d+)\.(\d+)\.(\d+)-'
regexp: 'splunk(?:forwarder)?-((\d+)\.(\d+)\.(\d+))-'
when: "'build_location' in splunk and splunk.build_location is not none"

# We can apply the same logic to the current version by checking which manifest file is in Splunk
Expand All @@ -48,9 +48,9 @@

- name: "Set current version fact"
set_fact:
splunk_current_version: "{{ manifests.files[0].path | regex_search(regexp, '\\1.\\2.\\3') if (manifests.matched == 1) else '0' }}"
splunk_current_version: "{{ manifests.files[0].path | regex_search(regexp, '\\1') if (manifests.matched == 1) else '0' }}"
vars:
regexp: 'splunk(?:forwarder)?-(\d+)\.(\d+)\.(\d+)-'
regexp: 'splunk(?:forwarder)?-((\d+)\.(\d+)\.(\d+))-'

# We are upgrading if it is not a fresh installation and the current version is different from the target version
- name: "Setting upgrade fact"
Expand Down
14 changes: 14 additions & 0 deletions roles/splunk_common/tasks/install_splunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@
build_location: "{{ splunk.build_location | combine(new_build_location,recursive=True) }}"
when: new_build_location is defined

- name: Remove old manifest files
file:
path: "{{ item.path }}"
state: "absent"
ignore_errors: yes
become: yes
become_method: sudo
become_user: root
with_items:
- "{{ manifests.files }}"
when:
- splunk.allow_upgrade is defined
- splunk.allow_upgrade | bool

- name: Download Splunk package (Windows)
get_url:
url: "{{ splunk.build_location }}"
Expand Down

0 comments on commit 260026d

Please sign in to comment.