Skip to content

Instantly share code, notes, and snippets.

@gkspranger
gkspranger / decrypt.yml
Last active January 9, 2020 05:10
a common way to decrypt a whole file using ansible vault and openssl
---
# this is how you encrypt a file using openssl and aes-256
# openssl aes-256-cbc -salt -a -e -in <src file> -out <out file> -k <enc salt>
# expects you pass in vars:
# enc_src_file -- local location of encrypted src file that will copied to target node
# enc_src_dest -- where the decrypted file should be put
# enc_salt -- salt used to decrypt
# enc_file_user -- user ownership
def jsonString = readFileFromWorkspace("jobs.json")
def slurper = new groovy.json.JsonSlurper()
json = slurper.parseText(jsonString)
/* example JSON
{
"cronJobs":[
{
"name": "Cron_Run_Ansible_Dev",
"vars":[
#!/bin/bash
#
# takes a snapshot of the provided device and writes a description
# will freeze the FS, snapshot, then unfreeze
# has the ability to "wait" until the snapshot is done if you want to make sure before you proceed to other tasks
#
device=0
desc=0
wait=0
# hubot event listener
# can map to a Jenkins instance and job and build it with params if needed
# can be invoked like this:
# robot.emit "jenkins_job", {
# name: "Restart_Tomcat",
# msg: msg,
# success: "Hello .. I went ahead and triggered a restart for Tomcat in the #{env} environment",
# params: "Inventory=#{env}&Group=tomcat"
# }
# Commands:
# hal restart tomcat in <environment>
module.exports = (robot) ->
robot.respond /restart tomcat in (dev|stage|prod)/i, (msg) ->
env = msg.match[1]
robot.emit "jenkins_job", {
name: "Restart_Tomcat",
msg: msg,
require 'spec_helper'
# check to make sure the httpd package is installed
describe package('httpd') do
it { should be_installed }
end
# check to ensure the httpd service is running and enabled
describe service('httpd') do
it { should be_running }
#!/bin/bash
# our AEM app runs as the 'day' user in the /home/day DIR
## for you yungins, 'day' is the company that created cq5/aem6
# MUST RUN THIS as the day user
# {{ aem_type }} is the AEM instance type we store in Ansible .. author or publish
PID=$(ps aux | egrep "day.*java" | egrep -v "egrep" | awk '{print $2}')
LOG="/home/day/{{ aem_type }}/crx-quickstart/logs/threaddump.log"
# clear out old log file
---
# ansible-playbook -i inventories/ec2.py adhoc/aem_thread_dump.yml --limit aem-author.example.com
# tag_role_aem is what our AWS EC2 AEM nodes are tagged with .. tag:role=aem
# the --limit <node name> is the name of the node you want to run the thread dump helper on
- hosts: tag_role_aem
max_fail_percentage: 1
vars:
email_to:
# MULTILINE NOTES for NAGIOS SERVICE !!
# no more run on sentences .. this annoyed me so much
# check aem6 service is running
define service {
service_description AEM6
hostgroup_name aem
check_command check_check_aem6
use default-service
# status link = <a href=\"https://{{ inventory_hostname }}/nagios/cgi-bin/extinfo.cgi?type=2&host=$HOSTNAME$&service=$$(echo $SERVICEDESC$ | sed -e 's/ /%20/g')\">Status Link</a>
# ack link = <a href=\"https://{{ inventory_hostname }}/nagios/cgi-bin/cmd.cgi?cmd_typ=34&host=$HOSTNAME$&service=$$(echo $SERVICEDESC$ | sed -e 's/ /%20/g')\">Acknowledgement Link</a>
# appended to the "$SERVICEOUTPUT$"
# see below
define command {
command_name notify-service-by-hipchat
command_line hipsaint --token={{ hipchat_token }} --room={{ hipchat_redrum_id }} --type=service --inputs="$SERVICEDESC$|$HOSTALIAS$|$LONGDATETIME$|$NOTIFICATIONTYPE$|$HOSTADDRESS$|$SERVICESTATE$|$SERVICEOUTPUT$<br><br><a href=\"https://{{ inventory_hostname }}/nagios/cgi-bin/extinfo.cgi?type=2&host=$HOSTNAME$&service=$$(echo $SERVICEDESC$ | sed -e 's/ /%20/g')\">Status Link</a><br><a href=\"https://{{ inventory_hostname }}/nagios/cgi-bin/cmd.cgi?cmd_typ=34&host=$HOSTNAME$&service=$$(echo $SERVICEDESC$ | sed -e 's/ /%20/g')\">Acknowledgemen