Skip to content

Instantly share code, notes, and snippets.

def jsonString = readFileFromWorkspace("jobs.json")
def slurper = new groovy.json.JsonSlurper()
json = slurper.parseText(jsonString)
/* example JSON
{
"cronJobs":[
{
"name": "Cron_Run_Ansible_Dev",
"vars":[
# 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,
# 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"
# }
#!/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
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 }
# 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
---
# just a simple example of me using my bootstrap.yml file and re-using an action role
# this is nice because: 1) i can put my roles where i want to, and 2) it allows me to be as DRY as i want to be
- hosts: localhost
connection: local
gather_facts: False
become: False
vars_files:
---
# my custom variable file that defines where my roles and playbooks are
# both directories are siblings of the inventories file
# inventory_dir is a VAR provided to us by Ansible
# .... http://docs.ansible.com/ansible/playbooks_variables.html#magic-variables-and-how-to-access-information-about-other-hosts
roles_dir: "{{ inventory_dir | regex_replace('inventories$', 'roles') }}"
playbooks_dir: "{{ inventory_dir | regex_replace('inventories$', 'playbooks') }}"
// Commands:
// hubot hello - replies with "world"!
const logger = require("winston");
module.exports = function(robot) {
robot.respond(/hello$/i, { id: "hello" }, function(message) {
message.send("world!");
logger.log("info", "i like to log stuff!", { yourObject: "some random data" });
});