Skip to content

Instantly share code, notes, and snippets.

View scarolan's full-sized avatar
🤸‍♂️
In whatever position one is in...one must find balance. -BKS Iyengar

Sean Carolan scarolan

🤸‍♂️
In whatever position one is in...one must find balance. -BKS Iyengar
View GitHub Profile

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
require_relative '../spec_helper.rb'
describe 'mailx::default' do
context 'on Debian' do
let(:chef_run) { ChefSpec::Runner.new({:platform => 'ubuntu', :version => '14.04'}).converge(described_recipe) }
it 'should install the correct packages' do
expect(chef_run).to install_package 'mailutils'
end
end
<% if @port != 80 -%>
Listen <%= @port %>
<% end -%>
<VirtualHost *:<%= @port %>>
ServerAdmin webmaster@localhost
DocumentRoot <%= @document_root %>
<Directory />
Options FollowSymLinks
@scarolan
scarolan / modules.rb
Created September 10, 2014 17:46
modules.rb
Ohai.plugin(:Apache) do
require 'mixlib/shellout'
provides "apache/modules"
collect_data(:default) do
modules = Mixlib::ShellOut.new("apachectl -t -D DUMP_MODULES")
modules.run_command
apache Mash.new
apache[:modules] = modules.stdout
end
@scarolan
scarolan / ohai_plugin.rb
Created September 10, 2014 17:51
ohai_plugin.rb
ohai 'reload_apache' do
plugin 'apache'
action :nothing
end
cookbook_file "#{node['ohai']['plugin_path']}/modules.rb" do
source 'plugins/modules.rb'
owner 'root'
group 'root'
mode '0644'
ruby_block "randomly_choose_language" do
block do
if Random.rand > 0.5
node.run_state['scripting_language'] = 'php'
else
node.run_state['scripting_language'] = 'perl'
end
end
end
### Keybase proof
I hereby claim:
* I am scarolan on github.
* I am scarolan (https://keybase.io/scarolan) on keybase.
* I have a public key whose fingerprint is C1CE FF7C BDD2 CB0C F493 8B30 6A1B 0F13 150F 853D
To claim this, I am signing this object:
function image() {
convert "$1" -resize "$2" txt:-|sed -E 's/://;s/\( ? ?//;s/, ? ?/,/g;s/\)//;s/(\w,\w,\w),\w/\1/g;/mage/d'|awk '{print $1,$2}'|python -c "import sys;f=sys.stdin.read().split('\n');f=filter(None,f);print 'tput rev;'+''.join([''.join(map(str,('echo;' if x.split(' ')[0].split(',')[0] is '0' else '','tput setaf '+str(sum(p*q for p,q in zip([36,6,1],[int(min(int(c),254)/42.5) for c in x.split(' ')[1].split(',')]))+16)+';echo -n \" \";'))) for x in f])+'echo;tput sgr0'"|bash
}
I think a basic example is defining a user and then trying to access ohai facts about the user. Even if you use run_action to invoke it right away the ohai data is not populated. You can tell ohai to rebuild it’s data but it’s all rather awkward. In puppet or in general I would imagine you have different stages / ordering that allows you to create users before you try to use data about them. Then also the fact that dependencies stop working if you run an action at compile time doesn’t seem very ideal.
<% if @port != 80 -%>
Listen <%= @port %>
<% end -%>
<VirtualHost *:<%= @port %>>
ServerAdmin webmaster@localhost
DocumentRoot <%= @document_root %>
<Directory />
Options FollowSymLinks