Unverified Commit f0b6c224 by Cory Lee Committed by GitHub

Merge pull request #4246 from edx/coryleeio/install_splunk_app_via_ansible

Coryleeio/install splunk app via ansible
parents 8616b8d1 927c130d
......@@ -70,6 +70,28 @@ SPLUNK_DASHBOARDS: []
# e.g.
# - {{ role_path }}/../../../secure-repo/path/to/templates/template.xml.j2
SPLUNK_APP_S3_PATH: 'BUCKET_S3_URL_GOES_HERE'
# This is the s3 url where splunk apps are stored
# A valid bucket name is not provided above because we dont want the bucket to be claimed by someone else
#
# example: s3://my-bucket-goes-here/my_optional_path
SPLUNK_APP_DOWNLOAD_PATH: "{{ splunk_home }}/etc/apps/app_downloads"
# Where on the local filesystem we store the app tars that we download from s3
SPLUNK_APP_TARS: []
# A list of dicts that contains tars of splunk apps to install, and their md5sum
# Download new apps from splunkbase(includes md5 hash):
# https://splunkbase.splunk.com/apps/
# Put them in SPLUNK_APP_S3_PATH
# Add an entry to this dict
# Apps will be installed if md5sum is correct, otherwise the task will fail
# See https://docs.splunk.com/Documentation/UnixApp/5.2.3/User/InstalltheSplunkAppforUnixandLinux#Install_the_Splunk_App_for_Unix_and_Linux_from_the_command_line
# e.g.
# SPLUNK_APP_TARS:
# - file_name: "my-tar.tgz"
# md5sum: "253385a0a68caea04e81fdb4d3083dd9"
SPLUNK_ALERT_DEFAULT_SEVERITY: "3"
......
......@@ -160,6 +160,55 @@
- "install"
- "install:configuration"
- name: create app download directory
file:
path: "{{ SPLUNK_APP_DOWNLOAD_PATH }}"
owner: "{{ splunk_user }}"
group: "{{ splunk_user }}"
mode: 0755
state: directory
tags:
- install
- install:configuration
- name: discover existing app tars
stat: path={{ SPLUNK_APP_DOWNLOAD_PATH }}/{{ item.file_name }}
register: app_present
tags:
- install
- install:configuration
with_items:
- "{{ SPLUNK_APP_TARS }}"
- name: download missing tars
shell: "aws s3 cp {{ SPLUNK_APP_S3_PATH }}/{{ item.1.file_name }} {{ SPLUNK_APP_DOWNLOAD_PATH }}/{{ item.1.file_name }}"
tags:
- install
- install:configuration
when: not item.0.stat.exists
with_together:
- "{{ app_present.results }}"
- "{{ SPLUNK_APP_TARS }}"
- name: verify app checksums
shell: "echo \"{{ item.md5sum }} {{ SPLUNK_APP_DOWNLOAD_PATH }}/{{ item.file_name }}\" | md5sum -c --status"
tags:
- install
- install:configuration
with_items:
- "{{ SPLUNK_APP_TARS }}"
- name: install apps
unarchive:
copy: no
src: "{{ SPLUNK_APP_DOWNLOAD_PATH }}/{{ item.file_name }}"
dest: "{{ splunk_home }}/etc/apps"
tags:
- install
- install:configuration
with_items:
- "{{ SPLUNK_APP_TARS }}"
- name: restart splunk
service:
name: splunk
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment