Skip to content

Instantly share code, notes, and snippets.

View jtimberman's full-sized avatar
🚀

Joshua Timberman jtimberman

🚀
View GitHub Profile

Tested with Ruby 2.1.4.

Install the Octokit gem.

gem install octokit -v 3.7.0

Tested with Ruby 2.1.4.

Install the Octokit gem.

gem install octokit -v 3.7.0

Tested with Ruby 2.1.4.

Install the Octokit gem.

gem install octokit -v 3.7.0

Tested with Ruby 2.1.4.

Install the Octokit gem.

gem install octokit -v 3.7.0

Tested with Ruby 2.1.4.

Install the Octokit gem.

gem install octokit -v 3.7.0

Easy one line Chef installation for all platforms (except windows)

curl https://www.opscode.com/chef/install.sh | sudo bash

That's it. This can be put in any instructions, such as a README or someone's blog, since the logic is in the shell script. Provided you download the script using https, the file has standard levels of authentication and encryption protecting it from manipulation.

This is obviously a shell script, if you're really concerned about the argument that it may contain nefarious activities within, you can easily review it before you run it.

require 'chef/log'
require 'pry'
module ChefSoftware
class CookbookVersionsHandler < Chef::Handler
def report
Chef::Log.info('Pausing in handler to run pry; type "exit" to leave pry')
binding.pry
end

Create a new instance of a Mixlib::ShellOut object, which is configured to run the date command.

2.1.4 (main):0 > cmd = Mixlib::ShellOut.new("date")
=> <Mixlib::ShellOut#70206383528180: command: 'date' process_status: nil stdout: '' stderr: '' child_pid: nil environment: {} timeout: 600 user:  group:  working_dir:  >

Send the #run_command method to the cmd object. We'll get process status, stdout, etc.

2.1.4 (main):0 &gt; cmd.run_command
@jtimberman
jtimberman / gist:178b3a56ee5de1164224
Created December 10, 2014 20:38
Fixing untrusted self-signed Chef Server 12 certificates

Scenario: You've started up a brand new Chef Server using version 12, and you have installed Chef 12 on your local system. You log into the Management Console to create a user and organization (or do this with the command-line chef-server-ctl commands), and you're ready to rock with this knife.rb:

node_name                'jtimberman'
client_key               'jtimberman.pem'
validation_client_name   'tester-validator'
validation_key           'tester-validator.pem'
chef_server_url          'https://ip-172-31-0-111.us-west-2.compute.internal/organizations/tester'
save-last-command() {
last_command=$(fc -nl 0)
command_name="$1"
read -r -d '' new_fun <<EOF
${command_name}() {
$last_command
}
EOF
eval "$new_fun"
}