Skip to content

Instantly share code, notes, and snippets.

View nathwill's full-sized avatar
🐜
doin' stuff

Nathan Williams nathwill

🐜
doin' stuff
  • Treehouse
  • Portland, OR
View GitHub Profile
@nathwill
nathwill / gist:9054335
Created February 17, 2014 16:49
centos docker built routine
lang en_US.UTF-8
keyboard us
timezone --utc Etc/UTC
auth --useshadow --enablemd5
selinux --disabled
rootpw --lock --iscrypted locked
zerombr
clearpart --all --initlabel
@nathwill
nathwill / chef_user_monkey_patch.rb
Last active August 29, 2015 14:06
chef user monkey patch for github ssh keys
require 'chef/resource/directory'
require 'chef/resource/file'
require 'chef/resource/remote_file'
require 'chef/resource/user'
require 'chef/provider/user'
class Chef
class Resource::TreehouseUser < Chef::Resource::User
def github_users(arg = nil)
set_or_return(
@nathwill
nathwill / Makefile
Last active August 29, 2015 14:07
snippet of packer-centric makefile
projs := $(basename $(wildcard *.json))
cmds := validate inspect build fix
aliases := bootstrap rebuild
# Enable packer debug logging
PACKER_LOG := 1
PACKER_LOG_PATH := /tmp/packer-debug
export PACKER_LOG PACKER_LOG_PATH
# call out rules that don't generate output
@nathwill
nathwill / json_decoder.lua
Created May 30, 2015 16:45
heka json decoder
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
--[[
Parses a payload containing JSON.
Config:
- type (string, optional, default nil):
@nathwill
nathwill / sensu_event.lua
Created June 5, 2015 18:12
sensu event encoder for heka
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
--[[
Encodes a heka message as a sensu event
Config:
- status_field (string, optional, default: status)
@nathwill
nathwill / nginx_stub_status.lua
Created July 22, 2015 00:20
heka nginx_stub_status decoder
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
--[[
--]]
local l = require 'lpeg'
@nathwill
nathwill / roles.json
Created July 24, 2015 19:03
packer template for role-based packer builds
{
"description": "build th base image",
"min_packer_version": "0.8.0",
"variables": {
"user": "centos",
"image": "d5f2c6b8-ae55-41d3-b9ba-15e0f2350659",
"flavor": "2",
"role1": "common",
"role2": "common",
"role3": "common",
@nathwill
nathwill / pairs-decoder.lua
Last active August 29, 2015 22:17
POC for generic kv pairs decoder for heka
local l = require "lpeg"
require "cjson"
l.locale(l)
local sp = l.space^0
local unreserved = l.digit + l.alnum + l.S"/=-.,_~ "
local name = l.C(unreserved^1) * sp
local comment = l.P"#" * (1 - l.P"\n")^1 * l.P"\n"
local sep = l.P(read_config("pair_separator"))
@nathwill
nathwill / memcached-stats-decoder.lua
Last active September 1, 2015 22:51
heka memcached stats decoder
local l = require 'lpeg'
l.locale(l)
local sp = l.space^1
local unreserved = l.alnum + l.S"/=-.,_~"
local name = l.C(unreserved^1)
local prefix = l.P"STAT "
local pair = prefix^-1 * l.Cg(name * sp * name) * sp
local grammar = l.Cf(l.Ct("") * pair^0, rawset)
@nathwill
nathwill / Vagrantfile
Last active December 17, 2015 18:49
chef-solo multi-vm vagrantfile
# vm and role mapping for multi-vm vagrant
boxes = [
{ :name => :app, :roles => ['base', 'web'] },
{ :name => :mc, :roles => ['base', 'memcache'] },
{ :name => :db, :roles => ['base', 'db-master'] },
{ :name => :util, :roles => ['base', 'redis', 'resque' ] },
]
Vagrant.configure("2") do |config|
# base image configuration