Skip to content

Commit 393eb51

Browse files
authored
Extend configure license task (#182)
* Extend configure license task * Added check_decrypted_secret task desc to README
1 parent b35ca09 commit 393eb51

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ Note: Any task with an **adhoc** prefix means that it can be used independently
132132
- **adhoc_fix_server_certificate.yml** - Use to delete an expired server.pem and generate a new one (default certs). Useful if your server.pem certificate has expired and you are using Splunk's default certificate for splunkd. Note that default certificates present a security risk and that their use should be avoided, if possible.
133133
- **adhoc_kill_splunkd.yml** - Some releases of Splunk have a "feature" that leaves zombie splunkd processes after a 'splunk stop'. Use this task after a 'splunk stop' to make sure that it's really stopped. Useful for upgrades on some of the 7.x releases, and automatically called by the upgrade_splunk.yml task.
134134
- **check_splunk.yml** - Check if Splunk is installed. If Splunk is not installed, it will be installed on the host. If Splunk is already installed, the task will execute a "splunk version" command on the host, and then compare the version and build number of Splunk to the version and build number of the expected version of Splunk. Note that the expected version of Splunk does not need to be statically defined; The expected Splunk version and build are automatically extracted from the value of splunk_package_url_full or splunk_package_url_uf using Jinja regex filters. This task will work for both the Universal Forwarder and full Splunk Enterprise packages. You define which host uses what package by organizing it under the appropriate group ('full' or 'uf') in your Ansible inventory.
135+
- **check_decrypted_secret.yml** - Check the decrypted value of a given `pass4SymmKey`. This can be called by a task to compare the desired value with the currently configured value to see if they match. This pervents unnessecary changes to be applied.
135136
- **configure_apps.yml** - This task should be called directly from a playbook in order to deploy apps or configurations (from git repositories) to Splunk hosts. Tip: Add a this task to a playbook after the check_splunk.yml play. Doing so will perform a "install (or upgrade) and deploy apps" run, all in one playbook.
136137
- **configure_authentication.yml** - Uses the template identified by the `splunk_authenticationconf` variable to install an authentication.conf file to $SPLUNK_HOME/etc/system/local/authentication.conf. We are including this task here since Ansible is able to securely deploy an authentication.conf configuration by using ansible-vault to encrypt sensitive values such as the value of the `ad_bind_password` variable. Note: If you are using a common splunk.secret file, you can omit this task and instead use configure_apps.yml to deploy an authentication.conf file from a Git repository containing an authentication.conf app with pre-hashed credentials.
137138
- **configure_bash.yml** - Configures bashrc and bash_profile files for the splunk user. Please note that the templates included with this role will overwrite any existing files for the splunk user (if they exist). The templates will define a custom PS1 at the bash prompt, configure the $SPLUNK_HOME environment variable so that you can issue "splunk <command>" without specifying the full path to the Splunk binary, and will enable auto-completion of Splunk CLI commands in bash.

roles/splunk/tasks/configure_license.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
mode: "0700"
1717
owner: "{{ splunk_nix_user }}"
1818
group: "{{ splunk_nix_group }}"
19-
become: yes
19+
become: true
2020
when:
2121
- splunk_license_group=="Enterprise"
2222
- name: Copy license file
@@ -27,19 +27,21 @@
2727
group: "{{ splunk_nix_group }}"
2828
mode: "0600"
2929
loop: "{{ splunk_license_file }}"
30-
become: yes
30+
become: true
3131
when:
3232
- splunk_license_group=="Enterprise"
33-
- name: "Remove {{ mode_option }} when using local license"
33+
- name: "Remove license manager uri when using local license"
3434
ini_file:
3535
path: "{{ splunk_home }}/etc/system/local/server.conf"
3636
section: license
37-
option: "{{ mode_option }}"
38-
value: "{{ splunk_uri_lm }}"
37+
option: "{{ item }}"
3938
owner: "{{ splunk_nix_user }}"
4039
group: "{{ splunk_nix_group }}"
4140
state: absent
42-
become: yes
41+
with_items:
42+
- manager_uri
43+
- master_uri
44+
become: true
4345
- name: Configure License Group
4446
ini_file:
4547
path: "{{ splunk_home }}/etc/system/local/server.conf"
@@ -48,7 +50,7 @@
4850
value: "{{ splunk_license_group }}"
4951
owner: "{{ splunk_nix_user }}"
5052
group: "{{ splunk_nix_group }}"
51-
become: yes
53+
become: true
5254
notify: restart splunk
5355
when:
5456
- not splunk_license_group=="Peer"
@@ -64,7 +66,14 @@
6466
value: "{{ splunk_uri_lm }}"
6567
owner: "{{ splunk_nix_user }}"
6668
group: "{{ splunk_nix_group }}"
67-
become: yes
69+
become: true
70+
71+
- name: Extract encrypted value
72+
include_tasks: check_decrypted_secret.yml
73+
vars:
74+
req_secret_conf: server
75+
req_secret_section: general
76+
req_secret_option: pass4SymmKey
6877

6978
- name: Set pass4SymmKey to match LM
7079
ini_file:
@@ -74,8 +83,11 @@
7483
value: "{{ splunk_general_key }}"
7584
owner: "{{ splunk_nix_user }}"
7685
group: "{{ splunk_nix_group }}"
77-
become: yes
86+
become: true
7887
notify: restart splunk
88+
when:
89+
- splunk_general_key != "undefined"
90+
- encrypted_secret_value.stdout == "" or (splunk_general_key != decrypted_secret_value.stdout | default(''))
7991
no_log: true
8092
when:
8193
- splunk_license_group=="Peer"

0 commit comments

Comments
 (0)