Skip to content

v1.8.5

Compare
Choose a tag to compare
@gobeila gobeila released this 11 Jun 15:53
· 30 commits to master since this release

commit c340ade
Author: Stéphane Duchesneau stephane.duchesneau@desjardins.com
Date: Mon Jun 11 11:46:00 2018 -0400

add create-all-roles.sh

diff --git a/jobs/splunk-full/spec b/jobs/splunk-full/spec
index 59787ea..544cedc 100644
--- a/jobs/splunk-full/spec
+++ b/jobs/splunk-full/spec
@@ -3,6 +3,7 @@
name: splunk-full
templates:
ctl.sh.erb: bin/ctl.sh

  • create-all-roles.sh.erb: bin/create-all-roles.sh
    system_inputs.conf.erb: config/system_local/inputs.conf
    system_user-seed.conf.erb: config/system_local/user-seed.conf
    system_indexes.conf.erb: config/system_local/indexes.conf
    diff --git a/jobs/splunk-full/templates/create-all-roles.sh.erb b/jobs/splunk-full/templates/create-all-roles.sh.erb
    new file mode 100644
    index 0000000..69752cb
    --- /dev/null
    +++ b/jobs/splunk-full/templates/create-all-roles.sh.erb
    @@ -0,0 +1,56 @@
    +#!/bin/bash -eu
    +SPLUNK_ADMIN_USER=<%= p('cf_splunk.cf_admin_user') %>
    +SPLUNK_ADMIN_PASSWORD=<%= p('cf_splunk.cf_admin_password') %>
    +set -x

+for i in $(/var/vcap/packages/python/bin/python_wrapper /var/vcap/packages/splunk-filter/list-orgs.py); do

  • SPLUNK_ROLE_NAME=$i
  • SPLUNK_APP_NAME=$i
  • CREATE THE ROLE,

  • ROLE_EXISTS_CODE=$(curl -K - -k "https://localhost:8089/services/authorization/roles/${SPLUNK_ROLE_NAME}" -sSw "%{http_code}" -o /dev/null <<< "-u ${SPLUNK_ADMIN_USER}:${SPLUNK_ADMIN_PASSWORD}")
  • if [ "$ROLE_EXISTS_CODE" == 404 ]; then
  • curl -sS -K - -k -X POST https://localhost:8089/services/authorization/roles?output_mode=json -d name=${SPLUNK_ROLE_NAME} <<< "-u ${SPLUNK_ADMIN_USER}:${SPLUNK_ADMIN_PASSWORD}"
  • fi
  • IF NOT EXISTS: CREATE THE APP, REFRESH IT, GRANT PERMS

  • APP_EXISTS_CODE=$(curl -K - -k "https://localhost:8089/services/apps/local/${SPLUNK_APP_NAME}" -sSw "%{http_code}" -o /dev/null <<< "-u ${SPLUNK_ADMIN_USER}:${SPLUNK_ADMIN_PASSWORD}")
  • if [ "$APP_EXISTS_CODE" == 404 ]; then
  • if test -d /var/vcap/store/splunk-persistent/apps/${SPLUNK_APP_NAME}; then
  •  ln -fs /var/vcap/store/splunk-persistent/apps/${SPLUNK_APP_NAME} /var/vcap/packages/splunk/etc/apps
    
  •  curl -sS -K - -k https://localhost:8089/services/apps/local?refresh=true <<< "-u ${SPLUNK_ADMIN_USER}:${SPLUNK_ADMIN_PASSWORD}"
    
  • else
  •  curl -sS -K - -k -X POST https://localhost:8089/services/apps/local -d "name=${SPLUNK_APP_NAME}&template=barebones" <<< "-u ${SPLUNK_ADMIN_USER}:${SPLUNK_ADMIN_PASSWORD}"
    
  •  test -d /var/vcap/store/splunk-persistent/apps || mkdir -p /var/vcap/store/splunk-persistent/apps && chmod 755 /var/vcap/store/splunk-persistent/apps
    
  •  mv /var/vcap/packages/splunk/etc/apps/${SPLUNK_APP_NAME} /var/vcap/store/splunk-persistent/apps/
    
  •  ln -fs /var/vcap/store/splunk-persistent/apps/${SPLUNK_APP_NAME} /var/vcap/packages/splunk/etc/apps
    
  •  ## REFRESH THE APP
    
  •  curl -K - -k https://localhost:8089/services/apps/local/${SPLUNK_APP_NAME}?refresh=true <<< "-u ${SPLUNK_ADMIN_USER}:${SPLUNK_ADMIN_PASSWORD}"
    
  •  # GRANT PERMS ON APP
    
  •  curl -K - -k -X POST https://localhost:8089/services/apps/local/${SPLUNK_APP_NAME}/acl \
    
  •        -d owner=nobody \
    
  •        -d sharing=app \
    
  •        -d "perms.read=${SPLUNK_ROLE_NAME},admin" \
    
  •        -d "perms.write=${SPLUNK_ROLE_NAME},admin" <<< "-u ${SPLUNK_ADMIN_USER}:${SPLUNK_ADMIN_PASSWORD}"
    
  •  curl -K - -k -X POST https://localhost:8089/services/apps/local/${SPLUNK_APP_NAME} -d "visible=yes" <<< "-u ${SPLUNK_ADMIN_USER}:${SPLUNK_ADMIN_PASSWORD}"
    
  •  sleep 1
    
  •  mkdir -p /var/vcap/packages/splunk/etc/apps/${SPLUNK_APP_NAME}/local  
    
  •  chown vcap.vcap /var/vcap/packages/splunk/etc/apps/${SPLUNK_APP_NAME}/local  
    
  •  cat > /var/vcap/packages/splunk/etc/apps/${SPLUNK_APP_NAME}/local/ui-prefs.conf  <<EOC
    

+[search]
+dispatch.earliest_time = @d
+dispatch.latest_time = now
+EOC

  •  chown vcap.vcap /var/vcap/packages/splunk/etc/apps/${SPLUNK_APP_NAME}/local/ui-prefs.conf  
    
  •  ## REFRESH THE APP AGAIN
    
  •  curl -K - -k https://localhost:8089/services/apps/local/${SPLUNK_APP_NAME}?refresh=true <<< "-u ${SPLUNK_ADMIN_USER}:${SPLUNK_ADMIN_PASSWORD}"
    
  • fi
  • fi

+done
\ No newline at end of file

Deployment

releases:
- name: cf-splunk
  version: 1.8.5
  url: https://github.com/emerald-squad/splunk-firehose-nozzle-release/releases/download/v1.8.5/cf-splunk-1.8.5.tgz
  sha1: 7b73c88ffe0b3b38c25d88a820711ad4a8444601