Skip to content

Commit b35ca09

Browse files
authored
Merge pull request #136 from schneewe/decrypted_check
add possibility to check a decrypted value, before setting a password
2 parents a84800c + 0156009 commit b35ca09

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
- name: "Extract encrypted {{ req_secret_option }} of {{ req_secret_conf }}.conf [{{ req_secret_section }}]"
3+
shell: "{{ splunk_home }}/bin/splunk btool {{ req_secret_conf }} list {{ req_secret_section }} | grep '{{ req_secret_option }} = ' | awk -F ' = ' '{print $2}'"
4+
register: encrypted_secret_value
5+
become: true
6+
become_user: "{{ splunk_nix_user }}"
7+
changed_when: false
8+
no_log: true
9+
10+
- name: "Decrypt {{ req_secret_option }} of {{ req_secret_conf }}.conf [{{ req_secret_section }}]"
11+
shell: "{{ splunk_home }}/bin/splunk show-decrypted --value '{{ encrypted_secret_value.stdout }}'"
12+
register: decrypted_secret_value
13+
become: true
14+
no_log: true
15+
changed_when: false
16+
when:
17+
- encrypted_secret_value.rc == 0 and encrypted_secret_value.stdout != ""

roles/splunk/tasks/configure_deploymentclient.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@
3838
notify: restart splunk
3939
when: phoneHomeIntervalInSecs != 'undefined'
4040

41+
- name: Extract encrypted value
42+
include_tasks: check_decrypted_secret.yml
43+
vars:
44+
req_secret_conf: server
45+
req_secret_section: deployment
46+
req_secret_option: pass4SymmKey
47+
4148
- name: Configure deployment server pass4SymmKey in server.conf
4249
ini_file:
4350
path: "{{ splunk_home }}/etc/system/local/server.conf"
@@ -49,5 +56,7 @@
4956
mode: 0644
5057
become: true
5158
notify: restart splunk
52-
no_log: true
53-
when: splunk_ds_key != 'undefined'
59+
when:
60+
- splunk_ds_key != 'undefined'
61+
- encrypted_secret_value.stdout == "" or (splunk_ds_key != decrypted_secret_value.stdout | default(''))
62+
no_log: true

0 commit comments

Comments
 (0)