Skip to content

Instantly share code, notes, and snippets.

@sean-horn
sean-horn / gist:2054293
Created March 17, 2012 01:54
Chef-0.10.8 multidigit cookbook version numbers
[master>] $ knife --version
Chef: 0.10.8
[master>] $ knife environment show production
chef_type: environment
cookbook_versions:
site1: 10.3.0
[master>] $ knife node show centos-6.2
Node Name: centos-6.2
@sean-horn
sean-horn / gist:4732213
Created February 7, 2013 16:37
Example cookbook Ruby code to show all versions of all cookbooks for the _default env
log "---writing all ckbks and version---"
require 'rest_client'
env = "_default"
num_versions = "num_versions=all"
api_endpoint = env ? "/environments/#{env}/cookbooks?#{num_versions}" : "/cookbooks?#{num_versions}"
r = Chef::REST.new(Chef::Config[:chef_server_url])
cookbook_versions = r.get_rest(api_endpoint)
log "#{cookbook_versions}"
log "---End writing all ckbks and version---"
@sean-horn
sean-horn / gist:4946481
Created February 13, 2013 17:42
Reading the cookbook collection to get the list of cookbooks/versions used
log "---writing all ckbks and version---"
cookbooks = @run_context.cookbook_collection
log "The recipes were these: #{cookbooks.keys.map {|x| cookbooks[x].name + " " + cookbooks[x].version} }"
log "---End writing all ckbks and version---"
@sean-horn
sean-horn / gist:7547476
Created November 19, 2013 15:51
results running with knife-ec-backup 0.9.2
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 200 OK
DEBUG: server: nginx/1.2.3
DEBUG: date: Tue, 19 Nov 2013 14:26:43 GMT
DEBUG: content-type: application/json; charset=utf-8
DEBUG: transfer-encoding: chunked
DEBUG: connection: close
DEBUG: status: 200 OK
DEBUG: content-encoding: gzip
DEBUG: ---- End HTTP Status/Header Data ----
@sean-horn
sean-horn / gist:7547490
Created November 19, 2013 15:51
results running with knife-ec-backup 0.9.6
knife ec backup MYBACKUP ../../../sean-horn-opscode/.chef/addorg-pivotal.pem -c ../../../sean-horn-opscode/.chef/knife-addorg.ubuntu-10.04-opc1.4.6-1.rb -VV
Grabbing users ...
DEBUG: Signing the request as pivotal
DEBUG: Initiating GET to https://chefserver///users
DEBUG: ---- HTTP Request Header Data: ----
DEBUG: Accept: application/json
DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
DEBUG: X-OPS-SIGN: algorithm=sha1;version=1.0;
DEBUG: X-OPS-USERID: pivotal
DEBUG: X-OPS-TIMESTAMP: 2013-11-19T15:49:43Z
@sean-horn
sean-horn / ec_backup.rb
Created December 4, 2013 22:54
modified ec_backup.rb
require 'chef/knife'
class Chef
class Knife
class EcBackup < Chef::Knife
banner "knife ec backup"
option :concurrency,
:long => '--concurrency THREADS',
:description => 'Maximum number of simultaneous requests to send (default: 10)'

All upgrades

All upgrades should be performed first with a copy of Production data, in an environment that is non-essential. This could be a Vagrant VM and is our typical test hardware for this purpose.

Backups are good to have for many reasons at all times. Especially during upgrades, tested backups become a critical part of our toolkit.

Upgrading from OPC1.2.x

Upgrading from OPC1.2x to EC11x REQUIRES that you first upgrade all systems in a cluster to OPC1.4.6. Please be aware of [1] at the transitions between the systems. Here is an example of the highest level upgrade process that should be followed.

All upgrades

All upgrades should be performed first with a copy of Production data, in an environment that is non-essential. This could be a Vagrant VM and is our typical test hardware for this purpose.

Backups are good to have for many reasons at all times. Especially during upgrades, tested backups become a critical part of our toolkit.

Upgrading from OPC1.2.x

Upgrading from OPC1.2x to EC11x REQUIRES that you first upgrade all systems in a cluster to OPC1.4.6.

@sean-horn
sean-horn / ldap-group-search.rb
Created May 22, 2014 22:42
Look through a specified group in LDAP for members with a certain name
## Change into the directory where we keep net-ldap
cd /opt/opscode/embedded/service/gem/ruby/1.9.1/gems/net-ldap-0.3.1
## then, startup an IRB shell
/opt/opscode/embedded/bin/irb -Ilib
## Keep the following stuff handy for pasting into the IRB shell
## Replace the values of the seven variables below with values appropriate for your site
## Everything can be copy/pasted into the IRB shell in bunches, except for the bindpass variable
@sean-horn
sean-horn / client.rb
Created July 16, 2014 20:24
Chef /etc/chef/trusted_certs Addition Issue During Chef Run
log_level :auto
log_location STDOUT
chef_server_url "https://api.opscode.com/organizations/sean-horn-opscode"
validation_client_name "sean-horn-opscode-validator"
# Using default node name (fqdn)
rest_timeout 5
http_retry_delay 2
http_retry_count 20