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
c = LXC::Container.new('foo')
c.create('ubuntu')
c.start
# we'll start tripping from here
reader, writer = IO.pipe
c.attach(wait: true) do
reader.close # its a process clone, so you have all the variable
x = Dir['/*']
writer.write(Marshal.dump(x))
name 'chef'
from 'ubuntu'
run 'apt-get install curl -y'
run 'curl -L https://www.opscode.com/chef/install.sh | sudo bash'
execute "apt_update" do
command "apt-get update -y"
end
%w{ ack-grep autoconf automake autotools-dev binutils bridge-utils
build-essential coreutils debootstrap dnsmasq-base doxygen fakeroot
git gnutls-bin golang golang-src htop iproute2 libdevmapper-dev
libgnutls-dev libgnutls26 make ncurses-base ncurses-bin ncurses-term libssl-dev
openssl python3.3 python3.3-dev strace tcpdump telnet tmux vim wget zlib1g
zlib1g-dev python3-software-properties}.each do |pkg|
@ranjib
ranjib / Chef12-Feature-Votes.md
Last active December 28, 2015 07:28
Chef Summit - 3 - Chef 12 Feature Votes #opschef
a) Version everything (roles, environments, data bags)
b) Chef server also to act as omnitruck package repository
c) Ruby 2.0
d) attribute level debugging
e) API generate audit trail
f) Resources for managing containers
g) Fix json
h) GC for chef server objects
i) knife-cloud plugin refactor

j) Semver support for cookbook versions

@ranjib
ranjib / cass.yaml.erb
Created October 18, 2013 06:26
Create cassandra using jugaad
cluster_name: 'jugaad'
num_tokens: 256
hinted_handoff_enabled: true
max_hint_window_in_ms: 10800000 # 3 hours
hinted_handoff_throttle_in_kb: 1024
max_hints_delivery_threads: 2
authenticator: AllowAllAuthenticator
authorizer: AllowAllAuthorizer
permissions_validity_in_ms: 2000
partitioner: org.apache.cassandra.dht.Murmur3Partitioner
template "/etc/sysconfig/iptables" do
extend Helper
source "chef_iptables_ruleset.erb"
owner = "root"
mode "0600"
variables(
:static_inbound => static_inbound_ruleset,
:dynamic_inbound => dynamic_inbound_ruleset,
:static_outbound => static_outbound_ruleset,
:dynamic_outbound => dynamic_outbound_ruleset
@ranjib
ranjib / zk_cjeck.py
Created September 11, 2013 22:55
Check Zookeeper
import sys
import telnetlib
import re
hosts = [ 'zk06.pd-internal.com', 'zk07.pd-internal.com', 'zk08.pd-internal.com',
'zk10.pd-internal.com', 'zk11.pd-internal.com' ]
leaders = {}
followers = {}
standalone = {}
@ranjib
ranjib / omnibus_creator.rb
Last active December 22, 2015 20:59
Create your omnibus installers using lxc & Chef
require 'lxc'
require 'lxc/extension'
# In this gist, we'll spawn an lxc container, use the lxc-chef/ssh extensions to install chef & omnibus
# then we'll drop our omnibus dummy definition , then build the omnibus installer
# then finally we'll copy over the resulting debian on the host box, and destroy the whole container
# you can create a rpm by spawning a centos/fedora container
LXC.use_sudo = true
vm = LXC::Container.new('omnibus-creator')
@ranjib
ranjib / chef_server_lxc.rb
Created September 11, 2013 03:57
How to kill a chef server
#
# Tested on
# fedora19 (kernel 3.10.10-200.fc19.x86_64) ,
# ruby 2 (rbenv), chef > 11.4 , lxc-0.9.0-2.fc21.x86_64) (rawhide)
# comes from lxc-ruby
require 'lxc'
# monkey patches that i introduced
# f19 specific bugfix
# [core] container.ipv4
@ranjib
ranjib / gvm_apply.rb
Last active December 22, 2015 17:09
gvm installation
package "build-essential"
package "mercurial"
package "bison"
package "curl"
package "git"
execute "install_gvm" do
user "ubuntu"
cwd "/home/ubuntu"