Skip to content

Instantly share code, notes, and snippets.

---
# 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" });
});
// Commands:
// hubot handlebar me - example of how to use handlebars
const logger = require("winston");
const handlebars = require("handlebars");
const fs = require("fs");
module.exports = function(robot) {
// this is the controller
robot.respond(/handlebar me/i, function(message) {
{{!--
# these are comments .. they will not be displayed
# i often put what the object looks like in here so i don't forget
{
line1: ...,
arr1: [...],
obj1: {
obj: ...
#!/bin/bash
#
# checks for the number of AWS AMIs and allows alerts when threshold is met
# example usage:
# ./check_aws_amis.sh -w <integer> -c <integer>
###
### USES ANSIBLE to put AWS KEYs as VARS
### USES ANSIBLE to define NAGIOS REGION
###
### REQUIRES AWS CLI : https://aws.amazon.com/cli/
#!/bin/bash
#
# checks for the number of AWS snapshots and allows alerts when threshold is met
# example usage:
# ./check_aws_snapshots.sh -w <integer> -c <integer>
###
### USES ANSIBLE to put AWS KEYs as VARS
### USES ANSIBLE to define NAGIOS REGION
###
### REQUIRES AWS CLI : https://aws.amazon.com/cli/
{# loop thru all relevant nodes #}
{% for i in ansible_play_batch | sort %}
{# set the node name AND node vars #}
{% set node_name=i %}
{% set node_vars=hostvars[ i ] %}
{# define the nagios hostgroup vars associated with this node .. default to linux #}
{% if node_vars.nagios_hostgroups is defined %}
{% set node_hostgroups="linux," ~ node_vars.nagios_hostgroups %}
# AWS EC2 hosts
# using ANSIBLE to assign tags
{% macro eze(tag) -%}
{# this is an easy, consistent way to enable a tag #}
{{ tag }} = enabled
{%- endmacro %}
{# loop thru all your EC2 hosts in alpha order #}
{% for i in ansible_play_batch | sort %}
#!/bin/bash
# hubot
# chkconfig: 345 20 80
# description: hubot
# processname: hubot
# REFERENCE: http://werxltd.com/wp/2012/01/05/simple-init-d-script-template/
# This script assumes you have a user called "hubot" on your system and that hubot is installed in /home/hubot