cdillc / cdillc.splunk / 0.24.2 / module / splunk_cli Splunk command line interface | "added in version" 0.9.0 of cdillc.splunk" Authors: Lowell C. Alleman (@lowell80)cdillc.splunk.splunk_cli (0.24.2) — module
Install with ansible-galaxy collection install cdillc.splunk:==0.24.2
collections: - name: cdillc.splunk version: 0.24.2
This is a lightweight wrapper around the Splunk CLI that handles auth parameter hiding and some other niceties.
This is a drop-in replacement for M(ansible.builtin.command). When converting, simply replace authenticated calls using C(-auth user:password) to use I(username) and (password) module options. Additional sensitive arguments can be protected too using I(hidden_args).
Calls to remote splunkd instance can be handled by specifying I(splunkd_uri).
- name: Reload the deployment server cdillc.splunk.splunk_cli: cmd: "{{splunk_home}}/bin/splunk reload deploy-server" username: "{{splunk_admin_user}}" password: "{{splunk_admin_pass}}"
- name: Update CM URL and secret (note that '-secret' is not logged) cdillc.splunk.splunk_cli: cmd: edit cluster-config -master_uri {{cm_url}} hidden_args: secret: "{{ cm_secret }}" splunk_home: "{{splunk_home}}" username: "{{splunk_admin_user}}" password: "{{splunk_admin_pass}}"
# Replacement for adding a search peer # command: splunk add search-server -auth {{splunk_admin_user}}:{{splunk_admin_pass}} # {{sh_url}} -remoteUsername {{sh_user}} -remotePassword {{sh_pass}} # This version protect the local and remote credentials - name: Add search peer cdillc.splunk.splunk_cli: cmd: add search-server {{sh_url}} hidden_args: remoteUsername: "{{ sh_user }}" remotePassword: "{{ sh_pass }}" splunk_home: "{{splunk_home}}" username: "{{splunk_admin_user}}" password: "{{splunk_admin_pass}}" creates: "{{splunk_home}}/.search-peer-added-{{ sh_url | urlencode }}" create_on_success: true
cmd: default: null description: - Command line arguments to the Splunk CLI - The initial C(splunk) command is optional as long as C(splunk_home) is provided. required: true password: default: null description: - The password for username/password authentication. - Must be provided if I(username) is provided. required: false username: default: null description: - Splunk username for username/password authentication. - When provided, I(password) must also be specified. required: false hidden_args: default: null description: - Specify additional arguments without logging values. - These will be appended to C(cmd) when the command is called. - A leading dash will be added to keys to simplify the YAML syntax. required: false type: dict splunk_home: default: /opt/splunk description: - The Splunk installation home. $SPLUNK_HOME - This value is required unless the first argument to I(cmd) is the absolute path to the splunk executable (often C(/opt/splunk/bin/splunk)) required: false splunkd_uri: aliases: - uri default: https://localhost:8089 description: - The Splunkd endpoint of the Splunk server to configure. - Defaults to the local server and default splunkd port. required: false