Skip to content

Instantly share code, notes, and snippets.

View charlesjohnson's full-sized avatar

Charles Johnson charlesjohnson

View GitHub Profile

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:

@charlesjohnson
charlesjohnson / Brewfile
Last active March 18, 2020 19:16
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 March 31, 2017 04:50
In Chef, these two examples are roughly syntactically equivalent
directory '/var/www/'
@charlesjohnson
charlesjohnson / Policyfile
Created July 13, 2015 17:36
Coincidence?
#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"
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 August 29, 2015 14:23
chef-client 11.18.2 logging behavior
#temp/break.rb
directory '/test/foo' do
action :create
end
@charlesjohnson
charlesjohnson / break.rb
Created June 26, 2015 00:23
chef-client 12.4 logging behavior
#temp/break.rb
directory '/test/foo' do
action :create
end
@charlesjohnson
charlesjohnson / break.rb
Last active August 29, 2015 14:23
chef-client 12.3 logging behavior
#temp/break.rb
directory '/test/foo' do
action :create
end
@charlesjohnson
charlesjohnson / what_a_jerk.rb
Created February 22, 2015 00:10
A dirty gem trick, install dependency gems without prompting the user if that's what they actually want.
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 November 4, 2019 05:47
Get bash / execute output from Chef
#!/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