Skip to content

Instantly share code, notes, and snippets.

View glarizza's full-sized avatar

Gary Larizza glarizza

  • Open Infrastructure Services
  • Portland, Oregon
View GitHub Profile
File {
require => Exec['myexec'],
}
<file declarations>
<exec declaration>
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'centos'
# Fusion Settings
----------FUNCTION----------
Puppet::Parser::Functions.newfunction(:extract, :type => :rvalue, :doc => "Extract it!") do |args|
raise Puppet::ParseError, "Please pass 2 arguments to the extract function, not #{args.length}" unless args.length == 2
yaml_file = args[0]
yaml_field = args[1]
raise Puppet::ParseError, "File #{yaml_file} not accessible to the extract function" unless File.exist?(yaml_file) and File.readable?(yaml_file)
yaml_hash = YAML.load_file(yaml_file)
require 'rspec-puppet'
#require 'puppetlabs_spec_helper/puppetlabs_spec/puppet_internals'
# Works even without ^^^
scope = PuppetlabsSpec::PuppetInternals.scope
Puppet::Parser::Functions.autoloader.load(:extract)
scope.function_extract(['/var/tmp/test.yaml', 'name'])
(~/src/facter)▷ irb
>> require 'facter'
=> true
>> require 'puppet'
=> true
>> require 'facter/util/cfpropertylist'
=> true
>> data = ['foo', 'bar']
=> ["foo", "bar"]
>> plist = Facter::Util::CFPropertyList::List.new
(~/src/veewee)▷ bundle exec vagrant basebox build osx --force [35/9654]
[osx] Downloading vbox guest additions iso v 4.1.22 - http://download.virtualbox.org/virtualbox/4.1.22/VBoxGuestAdditions_4.1.22.iso
[osx] Checking if isofile VBoxGuestAdditions_4.1.22.iso already exists.
[osx] Full path: /Users/glarizza/src/veewee/iso/VBoxGuestAdditions_4.1.22.iso
[osx]
[osx] The isofile VBoxGuestAdditions_4.1.22.iso already exists.
[osx] Building Box osx with Definition osx:
[osx] - force : true
[osx]
[osx] The isofile OSX_InstallESD_10.8.2.dmg already exists.
property_list_key { 'netboot_enabled':
ensure => present,
path => '/etc/bootpd',
key => 'netboot_enabled',
value => $interface,
value_type => 'array',
}
property_list_key { 'startTime':
ensure => present,
@glarizza
glarizza / gist:4254770
Created December 11, 2012 00:51
Custom Time Fact
# Put this in a module in your modulepath
# Drop this file inside a module's 'lib/facter' directory
# Run Puppet to sync down the custom fact
# The fact is accessible in your code as $time_now or absolutely as $::time_now
Facter.add('time_now') do
setcode do
t = Time.now
t.strftime("%H:%M.%S")
end
Ruby 1.9.3:
irb(main):001:0> string = 'foo'
=> "foo"
irb(main):002:0> string.each { |bar| puts bar }
NoMethodError: undefined method `each' for "foo":String
from (irb):2
from /opt/boxen/rbenv/versions/1.9.3/bin/irb:12:in `<main>'
@glarizza
glarizza / gist:4108374
Created November 19, 2012 00:44
Set Desktop Picture
property_list_key { 'Desktop Picture':
ensure => present,
path => '/Library/Preferences/com.apple.loginwindow',
key => 'DesktopPicture',
value => '/Library/Desktop Pictures/Ripples Blue.jpg',
}