Skip to content

Instantly share code, notes, and snippets.

View hunner's full-sized avatar

Hunter Haugen hunner

View GitHub Profile
@hunner
hunner / Vagrantfile
Last active December 30, 2015 07:09
PE3 vagrantfile
# Download PE tarball, extract to the same location as the Vagrantfile and mv
# to a directory called 'pe37'. Place a PE3 answers file called 'answers.txt'
# in the same location as the Vagrantfile (you can steal the
# all-in-one.answers.txt from the installer's answers/ directory). Run `vagrant
# up` and wait for PE to install. Visit https://localhost:4443 to view the PE
# console.
Vagrant.configure("2") do |config|
config.vm.define 'master' do |node|
node.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
node.vm.hostname = 'master.localdomain'
@hunner
hunner / Vagrantfile
Last active February 19, 2017 01:54
Vagrantfile example with vagrant-hosts and vagrant-auto_network
Vagrant.configure('2') do |config|
# Specify box files
config.vm.box = 'precise32'
config.vm.box_url = 'http://files.vagrantup.com/precise32.box'
# Create web frontend
config.vm.define 'web.example.com' do |node|
node.vm.network :forwarded_port, guest: 443, host: 4443
node.vm.network :forwarded_port, guest: 80, host: 8080
[2] pry(main)> require 'facter'
=> true
[3] pry(main)> Facter.value(:manufacturer)
=> nil
[4] pry(main)> Facter.fact(:manufacturer).stubs(:value).returns("aoeu") ; Facter.value(:manufacturer)
Mocha::StubbingError: stubbing method on nil: nil.value
from (pry):4:in `__pry__'
[5] pry(main)> Facter.add(:manufacturer) do "snth" end ; Facter.fact(:manufacturer).stubs(:value).returns("aoeu") ; Facter.value(:manufacturer)
=> "aoeu"
[6] pry(main)>
@hunner
hunner / vvagrant README
Last active December 17, 2015 13:19
`vvagrant` command which reads an environment variable `$VAGRANT_VERSION` (or command argument) to determine which version of vagrant to use. Useful for having both 1.0.x and 1.2.x installed at the same time.
## Make a directory like this for each version you want
vv% ls -l ~/local/share/rbenv/gemsets
total 0
drwxr-xr-x 8 hunner staff 272 Apr 22 15:06 vagrant_1.0.7/
drwxr-xr-x 8 hunner staff 272 Apr 22 15:12 vagrant_1.2.2/
## Put this in vagrant_*/Gemfile
vv% cat vagrant_1.2.1/Gemfile
source 'https://rubygems.org'
gem 'vagrant', :path => File.expand_path('vagrant', File.dirname(__FILE__))
@hunner
hunner / revoke_cert.rb
Created May 1, 2013 19:49
Revoke puppet certificates on first unchanged run
## modules/revoke_cert/lib/reports/revoke_cert.rb
require 'puppet/face'
Puppet::Reports.register_report(:revoke_cert) do
def process
if self.status == 'unchanged'
Puppet::Face[:certificate, :current].destroy(self.host,{:ca_location => :local})
end
end
end
@hunner
hunner / post-receive.sh
Created April 25, 2013 21:29
Put this in `modules/gitolite_hooks/files/puppet/post-receive` and feed to the gitolite module.
#
# Hook to update the /etc/puppetlabs/puppet with the lastest git changes.
# Licensed Apache 2.0
#
# To enable this hook, name this file "post-receive".
syncuser="puppetsync"
gituser="gitolite"
gitserver="hostname.example.com"
gitrepo="puppet.git"
destination="/etc/puppetlabs/puppet/environments"
@hunner
hunner / spell.vim
Created April 2, 2013 15:31
Aspell for english and esperanto
" Spell
let spell_executable = "aspell"
let spell_language_list = "spanish,english"
set spelllang=en_us,eo
@hunner
hunner / hiera.rb
Last active December 12, 2015 12:39
Hiera node terminus
## lib/puppet/indirector/node/hiera.rb
require 'puppet/node'
require 'puppet/indirector/code'
require 'hiera'
class Puppet::Node::Hiera < Puppet::Indirector::Code
desc 'Return a collection of classes and parameters by querying hiera for "classes" and "parameters" data entries.'
def find(request)
vv% cd Documents/work/git/soupkitchen
vv% vagrant status
/Users/hunner/Documents/work/git/soupkitchen/lib/oscar/networking.rb:8:in `initialize': undefined method `[]' for nil:NilClass (NoMethodError)
from /Users/hunner/Documents/work/git/soupkitchen/lib/oscar/environment.rb:13:in `new'
from /Users/hunner/Documents/work/git/soupkitchen/lib/oscar/environment.rb:13:in `run!'
from /Users/hunner/Documents/work/git/soupkitchen/lib/oscar.rb:7:in `load!'
from /Users/hunner/Documents/work/git/soupkitchen/Vagrantfile:5:in `<top (required)>'
from /Users/hunner/.rvm/gems/ruby-1.9.3-p286/gems/vagrant-1.0.5/lib/vagrant/config/loader.rb:115:in `load'
from /Users/hunner/.rvm/gems/ruby-1.9.3-p286/gems/vagrant-1.0.5/lib/vagrant/config/loader.rb:115:in `block in procs_for_source'
from /Users/hunner/.rvm/gems/ruby-1.9.3-p286/gems/vagrant-1.0.5/lib/vagrant/config.rb:41:in `block in capture_configures'
@hunner
hunner / init.pp
Created November 6, 2012 01:02
sysctl puppet class
class sysctl {
# nested class/define. Don't do this at home ;)
define conf (
$value,
$ensure='present'
) {
include sysctl
$key = $name
if $ensure == 'present' {
augeas { "sysctl_conf/$key":