cdillc.splunk.ksconf_app_sideload module – Unpacks a Splunk app archive after copying it from the controller machine
Note
This module is part of the cdillc.splunk collection (version 0.26.1).
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install cdillc.splunk
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: cdillc.splunk.ksconf_app_sideload
.
New in cdillc.splunk 0.10.0
Synopsis
By default, it will copy the source file from the local system to the target before unpacking.
For Windows targets, switch to Linux.
Note
This module has a corresponding action plugin.
Requirements
The below requirements are needed on the host that executes this module.
ksconf>=0.11
Parameters
Parameter |
Comments |
---|---|
The attributes the resulting filesystem object should have. To get supported flags look at the man page for chattr on the target system. This string should contain the attributes in the same order as the one displayed by lsattr. The |
|
This option controls the autodecryption of source files using vault. Choices:
|
|
Remote absolute path where the archive should be unpacked. Typically this will be |
|
Name of the group that should own the filesystem object, as would be fed to chown. When left unspecified, it uses the current group of the current user unless you are root, in which case it can preserve the previous ownership. |
|
Size of the volatile memory buffer that is used for extracting files from the archive in bytes. Default: |
|
If set to True, return the list of files that are contained in the tarball. Choices:
|
|
The permissions the resulting filesystem object should have. For those used to /usr/bin/chmod remember that modes are actually octal numbers. You must give Ansible enough information to parse them correctly. For consistent results, quote octal numbers (for example, Giving Ansible a number without following either of these rules will end up with a decimal number which will have unexpected results. As of Ansible 1.8, the mode may be specified as a symbolic mode (for example, If If Specifying |
|
Name of the user that should own the filesystem object, as would be fed to chown. When left unspecified, it uses the current user unless you are root, in which case it can preserve the previous ownership. Specifying a numeric username will be assumed to be a user ID and not a username. Avoid numeric usernames to avoid this confusion. |
|
Allow remote rebuilding of corrupted or missing manifest state data. This can be beneficial when upgrading between versions of the collection. But this may not be desirable in all situations. For example, any files not in new app will be removed, which can be problematic if you’ve intensionally created content within an app (e.g., you’ve deployed to the ‘apps’ folder of a running search head and allowed users to create/edit knowledge objects) When disabled, any app update from earlier versions will simply overwrite the current content, leaving any unknown files as-is. This means that previously deleted content will remain also means that previously delete content will not be removed, as file deletions were not supported prior to manifest support. Choices:
|
|
The level part of the SELinux filesystem object context. This is the MLS/MCS attribute, sometimes known as the When set to |
|
The role part of the SELinux filesystem object context. When set to |
|
The type part of the SELinux filesystem object context. When set to |
|
The user part of the SELinux filesystem object context. By default it uses the When set to |
|
Local path to Splunk archive file to copy to the target server; can be absolute or relative. |
|
Override the default state file location. The default state file location is nested immediately under the app folder, called Sometimes this may not be ideal when populating Be sure you understand the implications of changing this path. There must be one exactly state file per app per target, otherwise you can anticipate “flapping” between states as app deployment executes. |
|
Influence when to use atomic operation to prevent data corruption or inconsistent reads from the target filesystem object. By default this module uses atomic operations to prevent data corruption or inconsistent reads from the target filesystem objects, but sometimes systems are configured or just broken in ways that prevent this. One example is docker mounted filesystem objects, which cannot be updated atomically from inside the container and can only be written in an unsafe manner. This option allows Ansible to fall back to unsafe methods of updating filesystem objects when atomic operations fail (however, it doesn’t force Ansible to perform unsafe writes). IMPORTANT! Unsafe writes are subject to race conditions and can lead to data corruption. Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Indicates this has a corresponding action plugin so some parts of the options can be executed on the controller |
|
Support: none |
Supports being used with the |
|
Support: none |
Forces a ‘global’ task that does not execute per host, this bypasses per host templating and serial, throttle and other loop considerations Conditionals will work as if This action will not work normally outside of lockstep strategies |
|
Support: none |
Can run in check_mode and return changed status prediction without modifying target |
|
Support: str |
Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode |
|
Platform: posix |
Target OS/families that can be operated against |
|
Support: none |
Uses Ansible’s strict file operation functions to ensure proper permissions and avoid data corruption |
|
Support: full |
Can automatically decrypt Ansible vaulted files |
Notes
Note
Requires ksconf package on controller and target host.
Can handle .tgz, .tar.gz, .spl, and .zip files.
Existing files/directories in the destination which are not in the archive are removed. This requires that the prior app installation include a manifest. This feature was added in v0.18 of this collection; and all hash calculations have changed.
Note that only files are extracted. This means empty directories will not be created. If this cause an issue for you, open a bug report and describe your use case.
Too speed up subsequent calls to ksconf_app_sideload, manifest files are created and cached on the controller node in the same directory as src. This reduces the controller’s processing overhead. For this speedup to work, the controller must have write access to the parent directory of src. Also, any tarball created with ksconf_package will already have this manifest file.
Examples
- name: Extract ta-nix.tgz into /opt/splunk/etc/apps
cdillc.splunk.ksconf_app_sideload:
src: ta-nix.tgz
dest: /opt/splunk/etc/apps
- name: Install rendered apps from version control & existing tarballs
cdillc.splunk.ksconf_app_sideload:
# Add prefix for archived apps
src: "{{ apps_folder }}/{{ item }}"
dest: "{{ splunk_home }}/etc/deployment-apps"
owner: "{{ splunk_nix_user }}"
group: "{{ splunk_nix_group }}"
# Loop over present + managed apps created from (1) ksconf_package and (2) existing tarballs
loop: >
{{ app_render_output.results
| selectattr("archive")
| selectattr("item.state", "eq", "present")
| selectattr("item.managed")
| map(attribute="archive")
+ apps_inventory
| selectattr("tarball")
| selectattr("state", "eq", "present")
| selectattr("managed")
| map(attribute="tarball")
}}
become: true
become_user: "{{ splunk_nix_user }}"
notify: "reload deployment-server"
tags: install'
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Path to the destination directory. Returned: always Sample: |
|
List of all the files in the archive. Returned: When list_files is True Sample: |
|
Numerical ID of the group that owns the destination directory. Returned: always Sample: |
|
Name of the group that owns the destination directory. Returned: always Sample: |
|
String that represents the octal permissions of the destination directory. Returned: always Sample: |
|
Name of the user that owns the destination directory. Returned: always Sample: |
|
The source archive’s path. The location is local to the ansible controller. Returned: always Sample: |
|
State of the destination. Effectively always “directory”. Returned: always Sample: |
|
Path to the json state tracking file where installation state, source hash, and application manifest is stored. By default, this is relative to the app install path. Returned: always Sample: |
|
Numerical ID of the user that owns the destination directory. Returned: always Sample: |