Skip to content

Instantly share code, notes, and snippets.

View ranjib's full-sized avatar
🥁
having fun

Ranjib Dey ranjib

🥁
having fun
View GitHub Profile

Thanks for wanting to contribute to Chef! There are many ways to get involved in various areas of the project, tools, and documentation. This document will help you get started; the links below point to how-to-contribute information for each project.

An Overview of the Main Projects under the Chef Umbrella

The Chef Client

The Chef Development Kit

@ranjib
ranjib / recipe_spec.rb
Last active August 29, 2015 14:12
ChefSpec memoization
let(:runner) do
memoized_runner('pd-gocd::agent') do |node|
#.....
end
end
# Using chef to create files with a time stamp or similar - in this case,
# the serial number in a DNS zone file - presents a problem, because the
# time stamp interferes with with idempotency. Here is a trick for solving
# this (thanks to Noah Kantrowitz for his input and suggestion!)
# The trick is to use the same template twice, once with a constant serial
# number to check for idempotency, and a second time with the "real" serial
# number. The actual serial number can be stored in an attribute.
# Initial serial number for the zone
execute 'apt-get source redis-server=2:2.8.19-3' do
cwd '/opt/foo'
creares '/opt/foo/redis-2.8.19'
end
@ranjib
ranjib / upgrade.rb
Last active August 29, 2015 14:22
Upgrade chef
config(:chef, node_name: 'foo', client_key: '/path/to/client.pem', chef_server_url: 'https://foo.bar.com')
config(:ssh, user: 'foo', password: 'bar')
[
'sudo apt-get remove chef --purge -y',
'sudo rm -rf /opt/chef',
'sudo rm -rf /etc/chef/client.d',
'wget -c https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/13.04/x86_64/chef-xxx.deb',
'sudo dpkg -i chef-xxx.deb',
'sudo env -i /opt/chef/bin/chef-client',
'rm chef-xxx.deb'
@ranjib
ranjib / tweeter_search.rb
Created January 22, 2013 07:17
tweeter gem search api not returning the most recent tweets
tweets = Twitter.search("#devops",
:count => 100,
:result_type => "recent").results
#!/bin/bash
# As the "bufferbloat" folks have recently re-discovered and/or more widely
# publicized, congestion avoidance algorithms (such as those found in TCP) do
# a great job of allowing network endpoints to negotiate transfer rates that
# maximize a link's bandwidth usage without unduly penalizing any particular
# stream. This allows bulk transfer streams to use the maximum available
# bandwidth without affecting the latency of non-bulk (e.g. interactive)
# streams.
@ranjib
ranjib / default.rb
Last active December 14, 2015 09:09 — forked from bryanwb/gist:5063043
# cookbooks/nokogiri/recipes/default.rb
stage "install_deps" do
run_list "recipe[nokogiri::deps]"
end
stage "install_gem" do
run_list "recipe[nokogiri::gem]"
end
ruby_block "some command" do
block do
c = Mixlib::Shelout.new("ls -l")
c.run_command
c.stdout # do something exciting with c.stdout
end
end
@ranjib
ranjib / berkshelf_error.txt
Created March 14, 2013 09:01
berkshelf error
[berkshefl] $ berks upload
Using apache2 (1.6.0)
Using java (1.10.0)
Using yum (2.1.0)
Using s3cmd (0.0.0) at path: 'site-cookbooks/s3cmd'
Using as_app (0.0.3) at path: 'site-cookbooks/as_app'
Using rabbitmq (0.0.0) at path: 'site-cookbooks/rabbitmq'
Using solr (0.0.0) at path: 'site-cookbooks/solr'
Using windows (1.8.4)
Using chef_handler (1.1.4)