Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
LOG_FILE = 'access.log'
csv_data = 'method,uri\n'
File.open(LOG_FILE, 'r') do |f|
counter = 1
f.each_line do |line|
csv_data += "#{line.slice(line.index('"')+1..-1).split('"')[0].split[0]},#{line.slice(line.index('"')+1..-1).split('"')[0].split[1]}\n"
@tfitch
tfitch / converge_nodes.rb
Created July 31, 2014 17:00
converge nodes via API
#!/usr/bin/env ruby
# ASSUMES YOU'VE ALREADY USED single_org_setup.rb to create your nodes
# which will have saved the nodes key files to your machine and make API auth go
require 'fauxhai'
require 'mixlib/cli'
require 'mixlib/config'
require 'chef/rest'
require 'chef/node'
@tfitch
tfitch / mongodb.sysconfig
Created August 12, 2014 18:49
mongodb sysconfig example
# This config file is manually-generated by tfitch
# please modify manually if the IaaS setup changes
DAEMON="/apps/mongodb/bin/mongod"
NAME="mongod"
DAEMON_OPTS=""
DAEMON_OPTS="$DAEMON_OPTS --port 27017"
DAEMON_OPTS="$DAEMON_OPTS --dbpath /apps/data/mongodb"
DAEMON_OPTS="$DAEMON_OPTS --logpath /apps/log/mongodb/mongod.log"
@tfitch
tfitch / gist:1a48dc7d3f5e36dea015
Created August 12, 2014 19:04
mongodb init.d
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 35 85 15
# description: Mongo is a scalable, document-oriented database.
# processname: mongod
# config: /apps/mongodb/conf/awc-mongodb.conf
# pidfile: /apps/mongodb/mongo.pid
@tfitch
tfitch / attributes.rb
Last active August 29, 2015 14:05
Name/value pairs from cookbook attributes to dynamic resource attributes
# attributes for the iis_pool
default['config']['setting']['runtime_version'] = '12'
default['config']['setting']['thirty_two_bit'] = false
default['config']['setting']['max_proc'] = 4
@tfitch
tfitch / hardcoded-recipe.rb
Created September 1, 2014 20:50
Name/values pairs hardcoded
# if nothing was dynamic
iis_pool 'MyAppPool' do
runtime_version '12'
max_proc 4
thirty_two_bit false
action :config
end
@tfitch
tfitch / attributes.rb
Created September 1, 2014 20:55
Name/Value pairs as attributes
# attributes for the iis_pool
default['config']['setting']['runtime_version'] = '12'
default['config']['setting']['thirty_two_bit'] = false
default['config']['setting']['max_proc'] = 4
@tfitch
tfitch / dynamic-recipe-fail.rb
Last active August 29, 2015 14:05
Name/value pairs dynamic fail
# outputs the same as hardcoded-recipe.rb but does *not* work
iis_pool 'MyAppPool' do
node['config']['setting'].each do |setting, value|
"#{setting}" "#{value}"
end
action :config
end
@tfitch
tfitch / dynamic-recipe-works.rb
Created September 1, 2014 21:22
Name/value pairs dynamic works
# same result as hardcoded-recipe.rb but now driven by Attributes
iis_pool 'MyAppPool' do
node['config']['setting'].each do |setting, value|
send(setting, value)
end
action :config
end
@tfitch
tfitch / knife_search.sh
Created September 6, 2014 04:33
Knife node search
knife search node "role:mongo AND chef_environment:dev AND mongodb_replica_set:ReplSet1"