Skip to content

Instantly share code, notes, and snippets.

Avatar

Charles Johnson charlesjohnson

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am charlesjohnson on github.
  • I am chipadeedoodah (https://keybase.io/chipadeedoodah) on keybase.
  • I have a public key ASC6A2ZXs9oAPsolgExpIOmtEhVmlufZ1mKEbt3g4sVa0Qo

To claim this, I am signing this object:

View Brewfile
# Taps
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-fonts"
tap "homebrew/core"
tap "sambadevi/powerlevel9k"
# Brew CLI apps
brew "fd"
brew "fzf"
@charlesjohnson
charlesjohnson / example1.rb
Created Mar 31, 2017
In Chef, these two examples are roughly syntactically equivalent
View example1.rb
directory '/var/www/'
View Policyfile
#Policyfile for Jenkins
name "jenkins"
# Run_list
run_list "apt", "java", "jenkins::master", "recipe[policyfile_demo]"
# Attributes
default["greeting"] = "Attributes, f*** yeah"
override["attr_only_updating"] = "use -a"
View reverse lookup.rb
Its a cookbook class that we use to abstract cookbooks and their
dependencies. The key method to look at is dependency_hash which creates
a hash based on the dependencies of the cookbook.
We do not explicitly do a reverse dependency lookup but we can use this
hash to infer a change in dependencies from a change in any cookbook in
an environment. So the flow is:
1. I change cookbook A and it gets sent to the chef server and indexed
@charlesjohnson
charlesjohnson / break.rb
Last active Aug 29, 2015
chef-client 11.18.2 logging behavior
View break.rb
#temp/break.rb
directory '/test/foo' do
action :create
end
@charlesjohnson
charlesjohnson / break.rb
Created Jun 26, 2015
chef-client 12.4 logging behavior
View break.rb
#temp/break.rb
directory '/test/foo' do
action :create
end
@charlesjohnson
charlesjohnson / break.rb
Last active Aug 29, 2015
chef-client 12.3 logging behavior
View break.rb
#temp/break.rb
directory '/test/foo' do
action :create
end
@charlesjohnson
charlesjohnson / what_a_jerk.rb
Created Feb 22, 2015
A dirty gem trick, install dependency gems without prompting the user if that's what they actually want.
View what_a_jerk.rb
begin
gem 'chef-api'
rescue LoadError
require 'rubygems/dependency_installer'
Gem::DependencyInstaller.new(Gem::DependencyInstaller::DEFAULT_OPTIONS).install('chef-api')
end
require 'chef-api'
@charlesjohnson
charlesjohnson / foo.chef.rb
Last active Nov 4, 2019
Get bash / execute output from Chef
View foo.chef.rb
#!/opt/chefdk/bin/chef-apply
# Lifted pretty much verbatim from http://stackoverflow.com/questions/17813592/how-can-i-display-the-output-of-a-opscode-chef-bash-command-in-my-console)
results = "/tmp/output.txt"
file results do
action :delete
end
cmd = "ls /"
bash cmd do