Skip to content

Instantly share code, notes, and snippets.

View gswallow's full-sized avatar

Greg Swallow gswallow

  • Indianapolis, IN, USA
View GitHub Profile
checks = case
when Chef::Config[:solo]
data_bag("sensu_checks").map do |item|
data_bag_item("sensu_checks", item)
end
when Chef::DataBag.list.has_key?("sensu_checks")
search(:sensu_checks, "*:*")
else
Array.new
end
sudo chef-client -E qa1
Starting Chef Client, version 11.6.0
resolving cookbooks for run list: ["chef_handler", "chef_handler::hipchat", "chef_handler::updated_resources", "ulimit", "apt", "git", "resolvconf", "ntp", "ascent-common::linux", "ascent-common::users", "ascent-common::hostsfile", "ascent-wrappers::mongodb", "ascent-logs::mongodb"]
Synchronizing Cookbooks:
- chef_handler
- ulimit
- apt
- git
- dmg
- build-essential
@gswallow
gswallow / gist:10479197
Created April 11, 2014 15:48
Create an SSL cert data bag from raw certificate files
#!/usr/bin/env ruby
require 'json'
id = ARGV.shift
cert = Array.new
ARGV.each do |file|
File.open(file, 'r').each_line do |line|
cert << line.strip
end
{
"name": "qa1",
"description": "QA environment #1",
"cookbook_versions": {
"Rstats": "= 3.0.5",
"ant": "= 1.0.2",
"apache2": "= 1.8.14",
"application": "= 4.1.4",
"application_ruby": "= 3.0.2",
"apt": "= 1.9.2",
[2014-07-08T23:15:04+00:00] DEBUG: Converging node ip-10-93-168-18.ec2.internal
[2014-07-08T23:15:04+00:00] DEBUG: Saving the current state of node ip-10-93-168-18.ec2.internal
[2014-07-08T23:15:04+00:00] DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
[2014-07-08T23:15:04+00:00] DEBUG: Re-raising exception: Encoding::UndefinedConversionError - "\xE2" from ASCII-8BIT to UTF-8
/usr/local/lib/ruby/gems/2.0.0/gems/chef-11.12.8/lib/chef/node.rb:418:in `encode'
/usr/local/lib/ruby/gems/2.0.0/gems/chef-11.12.8/lib/chef/node.rb:418:in `to_json'
/usr/local/lib/ruby/gems/2.0.0/gems/chef-11.12.8/lib/chef/node.rb:418:in `to_json'
/usr/local/lib/ruby/gems/2.0.0/gems/chef-11.12.8/lib/chef/node.rb:418:in `to_json'
/usr/local/lib/ruby/gems/2.0.0/gems/chef-11.12.8/lib/chef/node.rb:418:in `to_json'
/usr/local/lib/ruby/gems/2.0.0/gems/chef-11.12.8/lib/chef/json_compat.rb:102:in `to_json'
root@77b6ef94b4b9:/# su - jenkins
jenkins@77b6ef94b4b9:~$ ls
rvm.sh
jenkins@77b6ef94b4b9:~$ \curl -sSL https://get.rvm.io | sudo bash -s stable --debug |& tee rvmwut.log
Turning on debug mode.
Running(1): Selected RVM branch stableDownloading https://github.com/wayneeseguin/rvm/archive/stable.tar.gz
Running(1): Running(15): curl --fail --location --max-redirs 10 --connect-timeout 30 --retry-delay 2 --retry 3 -sS https://github.com/wayneeseguin/rvm/archive/stable.tar.gz -o /usr/local/rvm/archives/rvm-stable.tgzRunning(1): Running(6): tar xzf /usr/local/rvm/archives/rvm-stable.tgz --no-same-owner --strip-components 1step> 'system_installation_check' started
step< 'system_installation_check' finished with status 0 in 0.008413166 seconds
step> 'setup_rvm_group_and_users' started
Group 'rvm' already exists
@gswallow
gswallow / gist:c5e2b8103f8c180794af
Created August 16, 2014 15:09
right_aws returns empty arrays in response to ec2.create_volume and ec2.describe_volumes
#!/usr/bin/env ruby
require 'right_aws'
require 'open-uri'
require 'json'
def query_role
open("http://169.254.169.254/latest/meta-data/iam/security-credentials/").readlines.first
end
@gswallow
gswallow / 90-ebs.rules.erb
Last active August 29, 2015 14:05
mongodb on ebs
<% unless @prefixes.nil? -%>
<% @prefixes.each do |pfx| -%>
ACTION=="add", KERNEL=="<%= pfx %>", ATTR{bdi/read_ahead_kb}="32"
<% end -%>
<% end -%>
<% unless @raid_dev.nil? -%>
ACTION=="add", KERNEL=="<%= @raid_dev %>", ATTR{bdi/read_ahead_kb}="32"
<% end -%>
x RDS/man/RDS.bootstrap.intervals.Rd
x RDS/man/get.id.Rd
x RDS/man/extract-methods.Rd
x RDS/man/cumulative.estimate.Rd
x RDS/man/as.rds.data.frame.Rd
x RDS/man/gile.ss.weights.Rd
x RDS/man/read.rdsobj.Rd
x RDS/man/get.population.size.Rd
x RDS/man/write.netdraw.Rd
@gswallow
gswallow / gist:ba0d18d4b3aeb0ad28d9
Last active August 29, 2015 14:06
R package installer (handles specific versions)
#!/usr/bin/env Rscript
# Command line options parser. Shamelessly stolen (and even then
# not well understood).
library('getopt');
spec = matrix(c(
'package', 'p', 1, 'character',
'version', 'v', 2, 'character',
'help', 'h', 0, 'logical'
), byrow=TRUE, ncol=4);