Skip to content

Instantly share code, notes, and snippets.

@nvalentine-puppetlabs
nvalentine-puppetlabs / gist:4543503
Created January 16, 2013 00:25
package_versions.rb
IO.popen('yum list installed -q').readlines.each do | yum_line |
name, version, stuff = yum_line.split(/\s+/)
name.gsub!(/\.(i386|i686|x86_64|noarch)/,'')
Facter.add("yum_#{name}_version") do
setcode do
version
end
end
end
@nvalentine-puppetlabs
nvalentine-puppetlabs / gist:4628675
Created January 24, 2013 22:22
Get the IP address of a VM in VirtualBox
VBoxManage guestproperty get "ubuntu_1358963029" "/VirtualBox/GuestInfo/Net/0/V4/IP"
@nvalentine-puppetlabs
nvalentine-puppetlabs / gist:5120096
Last active December 14, 2015 17:09
Search your bash history and execute matching
Ctrl-R <search string>
Hit enter if the matched string is what you'd like.
Hit Ctrl-R again to search further back in the history.
@nvalentine-puppetlabs
nvalentine-puppetlabs / gist:5206726
Created March 20, 2013 17:39
git checkout and track remote branch
# git checkout -t origin/<branchname>
@nvalentine-puppetlabs
nvalentine-puppetlabs / gist:5213532
Last active December 15, 2015 05:59
Getting started with Vagrant

Getting Started with Vagrant

Installing

Installing vagrant itself can be a bit of a pain as it is a Ruby package and has most of the usual versioning problems therein. I recommend setting up your environment with the 'rbenv' package and then creating an rbenv environment with the latest vagrant. You probably want to run Vagrant with VirtualBox. At least for Ubuntu, I've had an easy enough time with Virtualbox from the Ubuntu repos.

rbenv

@nvalentine-puppetlabs
nvalentine-puppetlabs / gist:6527124
Last active December 22, 2015 20:29
Create a 'dev' branch and get rid of 'master' both local and remote.
$ git checkout -b dev
$ git branch -D master
$ git push --delete origin master
$ git push --all
@nvalentine-puppetlabs
nvalentine-puppetlabs / gist:6629601
Created September 19, 2013 20:45
Puppet pre-commit script
#!/bin/bash
# If we don't have a HEAD, then this is the first commit and we can't do any of this
git show > /dev/null 2>&1
if [ $? -ne 0 ]; then exit 0; fi
# first stash any on-disk changes so we're actually validating
# what's staged to be committed and not just what's on disk.
git diff --full-index --binary > /tmp/stash.$$
git stash -q --keep-index
@nvalentine-puppetlabs
nvalentine-puppetlabs / gist:7036421
Created October 18, 2013 04:16
List Exported Resources via PuppetDB query
curl -G -H "Accept: application/json" 'http://localhost:8080/resources' --data-urlencode 'query=["=","exported", true]'
@nvalentine-puppetlabs
nvalentine-puppetlabs / gist:7107123
Created October 22, 2013 19:59
Find Puppet exported resources via PuppetDB query
curl -G -H "Accept: application/json" 'http://localhost:8080/resources' --data-urlencode 'query=["=","exported", true]'
@nvalentine-puppetlabs
nvalentine-puppetlabs / gist:9485977
Created March 11, 2014 13:48
rename master branch to production *before* any pushes
mkdir foo
git init
git checkout -b production
touch README
git add -A
git commit -m 'initial commit'
git branch --delete master
git push --all