Skip to content

Instantly share code, notes, and snippets.

View miah's full-sized avatar
🍕
Dreaming of pizza.

Miah Johnson miah

🍕
Dreaming of pizza.
View GitHub Profile
#!/usr/bin/env ruby
require 'erubis'
input = File.read('./nginx.conf.erb')
eruby = Erubis::Eruby.new(input)
context = {
:listen_port => 80,
:chef_env => 'prod',
chef > node.default.djbdns.public_dnscache_allowed_networks = node.ipaddress.split('.')[0,2].join('.')
=> "192.168"
chef > default[:djbdns][:public_dnscache_allowed_networks] = [ipaddress.split(".")[0,2].join(".")]
NameError: undefined local variable or method `default' for main:Object
from (irb):4
from /Users/miahjohnson/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/shef.rb:73:in `block in start'
from /Users/miahjohnson/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/shef.rb:72:in `catch'
from /Users/miahjohnson/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/shef.rb:72:in `start'
from /Users/miahjohnson/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/chef-10.14.2/bin/shef:34:in `<top (required)>'
chef > node.default[:djbdns][:public_dnscache_ipaddress] = node['ipaddress']
=> "192.168.1.10"
chef > node.default[:djbdns][:tinydns_internal_resolved_domain] = node['domain']
=> "local"
chef > node.default[:djbdns][:public_dnscache_allowed_networks] = [node.ipaddress.split(".")[0,2].join(".")]
=> ["192.168"]
[miahjohnson@~]$: ohai ipaddress
sh: 1: Permission denied
[
"192.168.1.10"
]
[miahjohnson@~]$: which ohai
/Users/miahjohnson/.rbenv/shims/ohai
@miah
miah / gist:3837299
Created October 5, 2012 00:21
test-kitchen hates me (and im probably an idiot)
[miahjohnson@chef-collectd]$: bundle exec kitchen test --verbose
Assembling required cookbooks at [/Users/miahjohnson/projects/github/chef-collectd/test/kitchen/.kitchen/cookbooks].
/Users/miahjohnson/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:1344:in `mkdir': File exists - /Users/miahjohnson/projects/github/chef-collectd/test/kitchen/.kitchen/cookbook_under_test/vendor/bundle/ruby/1.9.1/gems/treetop-1.4.10/examples/lambda_calculus/lambda_calculus (Errno::EEXIST)
from /Users/miahjohnson/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:1344:in `copy'
from /Users/miahjohnson/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:465:in `block in copy_entry'
from /Users/miahjohnson/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:1433:in `preorder_traverse'
from /Users/miahjohnson/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:462:in `copy_entry'
from /Users/miahjohnson/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/fileutils.rb:437:in `block in cp_r'
from /Users/miahjohnson/.rbe
@miah
miah / gist:3876136
Created October 11, 2012 23:02
chef-server cookbook fail.
magical-unicorn:chef_server miahjohnson$ vagrant up
[chef_server] Importing base box 'opscode-ubuntu-12.04'...
[chef_server] The guest additions on this VM do not match the install version of
VirtualBox! This may cause things such as forwarded ports, shared
folders, and more to not work properly. If any of those things fail on
this machine, please update the guest additions and repackage the
box.
Guest Additions Version: 4.1.22
VirtualBox Version: 4.2.1
[cache:a]
ENABLE_UDP_LISTENER = True
UDP_RECEIVER_INTERFACE = 0.0.0.0
CACHE_QUERY_INTERFACE = 0.0.0.0
LINE_RECEIVER_INTERFACE = 0.0.0.0
PICKLE_RECEIVER_INTERFACE = 0.0.0.0
UDP_RECEIVER_PORT = 2103
LINE_RECEIVER_PORT = 2103
PICKLE_RECEIVER_PORT = 2104
CACHE_QUERY_PORT = 7102
Finished tests in 0.003879s, 1031.1936 tests/s, 1031.1936 assertions/s.
1) Failure:
test_0001_inherits the Input::File module(ResourceLogstashConfig::Tests for Chef::Resource::LogstashConfig::Dynamic Module loading test) [test/spec/libraries/resource_logstash_config_spec.rb:45]:
Expected <logstash_config[test_instance] @name: "test_instance" @noop: nil @before: nil @params: {} @provider: Chef::Provider::LogstashConfig @allowed_actions: [:create, :destroy, :nothing] @action: :create @updated: false @updated_by_last_action: false @supports: {} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: nil @elapsed_time: 0 @resource_name: :logstash_config @plugin_name: "File" @plugin_type: "Input" @instance: "instance_name"> (Chef::Resource::LogstashConfig) to respond to #path.
4 tests, 4 assertions, 1 failures, 0 errors, 0 skips
[chef_logstash]$:
# something that allocates X volumes of Y size and stripes
# them into a single volume, and mounts/fstab's that volume
#
action :create do
aws = data_bag_item('credentials', 'aws')
ebs_devices = []
lvm_devices = []
miahjohnson@Downloads]$: python distribute_setup.py
Extracting in /var/folders/jg/tpnfcl694_jgpdll9wfd4l7h0000gn/T/tmpjX3KcB
Now working in /var/folders/jg/tpnfcl694_jgpdll9wfd4l7h0000gn/T/tmpjX3KcB/distribute-0.6.46
Installing Distribute
Before install bootstrap.
Scanning installed packages
Setuptools installation detected at /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Non-egg installation
Moving elements out of the way...
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools-0.6c12dev_r88846-py2.7.egg-info/EGG-INFO/PKG-INFO already patched.