Skip to content

Instantly share code, notes, and snippets.

@paulmooring
paulmooring / data_bag_delete_functions.rb
Created December 27, 2012 23:44
orgmapper functions to delete data bags
# return the data bag object given an org and databag name
def get_bag(org, bag_name)
if ORGS[org] == nil
raise RuntimeError, "Bad org name provided"
else
bag = ORGS[org].databags[bag_name]
bag.kind_of? Mixlib::Authorization::Models::DataBag or raise RuntimeError, "Bad data bag name provided"
end
@paulmooring
paulmooring / run_orgmapper_script.rb
Last active December 10, 2015 21:28
run orgmapper scripts
#!/usr/bin/env ruby
require 'rubygems'
require "bundler/setup"
$:.unshift(File.dirname(__FILE__) + '/../lib/')
require 'orgmapper'
require 'orgmapper/config'
config_file = ARGV.first
@paulmooring
paulmooring / cb.rb
Created January 25, 2013 22:05
cb_threads.rb
def pp_cookbook(cb)
pp api.get "/cookbooks/#{cb}"
end
api.get('/cookbooks').keys.first(12).each do |cb|
thrds = Array.new
thrds << Thread.new { pp_cookbook(cb) }
thrds.each do |t|
t.join
@paulmooring
paulmooring / gist:4678588
Created January 31, 2013 00:04
bunnyc.erl snippet
%% @private
handle_call({publish, Key, Message, Opts}, _From,
State = #bunnyc_state{channel=Channel, exchange=Exchange})
when is_binary(Key), is_binary(Message) orelse ?is_message(Message),
is_list(Opts) ->
Resp = internal_publish(fun amqp_channel:call/3,
Channel, Exchange, Key, Message, Opts),
{reply, Resp, State};
handle_call({get, NoAck}, _From,
@paulmooring
paulmooring / api-curl.sh
Last active February 23, 2021 07:55
curl request script for Chef servers
#!/usr/bin/env bash
# Author:: Paul Mooring (<[email protected]>)
# Author:: Steven Danna (<[email protected]>)
# Copyright:: Copyright (c) 2013 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@paulmooring
paulmooring / install-msi.rb
Created February 14, 2013 19:10
hacky webpi install-msi.rb recipe
# Author:: Guilhem Lettron (<[email protected]>)
# Cookbook Name:: webpi
# Recipe:: install-msi
#
# Copyright 2011, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@paulmooring
paulmooring / product.rb
Created February 14, 2013 19:10
Super hacky webpi_product provider
#
# Author:: Seth Chisamore (<[email protected]>)
# Cookbook Name:: webpi
# Provider:: product
#
# Copyright:: 2011, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@paulmooring
paulmooring / product.rb
Created February 14, 2013 19:29
stubbed out product provider
#
# Author:: Seth Chisamore (<[email protected]>)
# Cookbook Name:: webpi
# Provider:: product
#
# Copyright:: 2011, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
[2013-02-21T22:42:05+00:00] INFO: Loading cookbooks [bluepill, build-essential, chef-client, ntp, rsyslog, runit]
which: no chef-server in (/sbin:/bin:/usr/sbin:/usr/bin:/opt/chef/embedded/bin:/opt/chef/embedded/bin:/usr/local/sbin:/usr/local/bin)
which: no chef-server in (/sbin:/bin:/usr/sbin:/usr/bin:/opt/chef/embedded/bin:/opt/chef/embedded/bin:/usr/local/sbin:/usr/local/bin)
================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/chef-client/recipes/default.rb
================================================================================
Chef::Exceptions::CookbookNotFound
----------------------------------
@paulmooring
paulmooring / knife memory usage
Created February 26, 2013 15:46
knife memory usage
[pmooring@jenkins ~]$ valgrind --tool=massif --depth=1 --trace-children=yes knife -v && ms_print massif.out*
==16710== Massif, a heap profiler
==16710== Copyright (C) 2003-2010, and GNU GPL'd, by Nicholas Nethercote
==16710== Using Valgrind-3.6.0 and LibVEX; rerun with -h for copyright info
==16710== Command: /usr/bin/knife -v
==16710==
Chef: 11.2.0
==16710==
--------------------------------------------------------------------------------
Command: /usr/bin/knife -v