I'm new on stackoverflow and I'm very glad to be here.
My question is:
I want to get the Splunk version and then if version is not equal to e.g "8" or something else, then stop Splunk and uninstasll it and install the right version.
Here is my Ansible playbook I write to get the version.
tasks:
- name: Read splunk.version file
slurp:
src: C:\\Program Files\\SplunkUniversalForwarder\\etc\\splunk.version
register: result
ignore_errors: true
- name: set splunk version
set_fact:
splunk_version: "{{ result['content'] | b64decode | regex_findall('(?<=VERSION\\=).*?(?=\\r)') }}"
- name: message
debug:
var: splunk_version
- name: message
debug:
msg: "same version installed"
when: splunk_version == "8.0.3"
And here my result
TASK [Read splunk.version file]
********************
ok: [192.168.*.*]
TASK [set splunk version]
*********************
ok: [192.168.*.*]
TASK [message]
***********************
ok: [192.168.*.*] => {
"splunk_version": [
"8.0.3"
]
}
TASK [message]
***********************
skipping: [192.168.*.*]
As you see despite being in same version, I get wrong result. I know I made a mistake in my comparison conditions but I don't know where!
So I'm very appreciative if anyone could correct my playbook.
Sorry for my mistakes
Thanks in advance