This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
require 'optparse' | |
options = {} | |
optparse = OptionParser.new { |opts| | |
opts.banner = "Usage : howmuch.rb [-c <city> -s <state>] | [-z <zip>] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class webapp::wordpress { | |
# this class includes apache/mysql/etc and declares an apache::vhost resource | |
# the vhost "if ! defined()" check fails because wordpress is being parsed first | |
# https://github.com/puppetlabs/puppetlabs-apache/blob/master/manifests/vhost.pp#L263 | |
require webapp | |
# class { '::webapp': } # does the same thing | |
# This is being parsed before webapp, so the "if ! defined()" check at | |
# https://github.com/hunner/puppet-wordpress/blob/master/manifests/app.pp#L43 | |
# always wins |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Puppet::Parser::Functions.newfunction(:homedir, :type=>:rvalue) do |args| | |
raise ArgumentError, "Expects 1 argument, not #{args.size}" if args.size != 1 | |
user = args[0] | |
case user | |
when 'root' | |
'/root' | |
else | |
"/home/#{user}" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/puppet/bin/ruby | |
# | |
# This script is designed to request classification from the configured Puppet | |
# Enterprise Console. This gives us the opportunity to inject classes or | |
# parameter settings before returning the final classification. | |
# | |
# This is a terrible idea, and you should never do it in production. | |
# | |
require 'yaml' | |
require 'syslog' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class parent { | |
include def | |
Notify { | |
message => 'This is parent scope', | |
} | |
notify {'one': } | |
} | |
class child { | |
notify { 'two': } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/puppet/bin/ruby | |
# | |
# This script is designed to request classification from the configured Puppet | |
# Enterprise Console. This gives us the opportunity to inject classes or | |
# parameter settings before returning the final classification. | |
# | |
# This is a terrible idea, and you should never do it in production. | |
# | |
# puppet requires a home directory set | |
ENV['HOME'] = '/var/opt/lib/pe-puppet' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@master /etc/puppetlabs/puppet/modules/testing]# cat lib/puppet/parser/functions/test.rb | |
Puppet::Parser::Functions.newfunction(:test) do |args| | |
require 'puppet/util/test' | |
function_notice([Puppet::Util::Test.boo()]) | |
end | |
[root@master /etc/puppetlabs/puppet/modules/testing]# cat lib/puppet/util/test.rb | |
class Puppet::Util::Test | |
def self.boo | |
'booger' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@master ~]# puppet resource package poobles provider=yum | |
Error: Execution of '/usr/bin/yum -d 0 -e 0 -y install poobles' returned 1: Error: Nothing to do | |
Error: /Package[poobles]/ensure: change from absent to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y install poobles' returned 1: Error: Nothing to do | |
package { 'poobles': | |
ensure => 'absent', | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'puppet/provider/parsedfile' | |
Puppet::Type.type(:host).provide(:classroom, | |
:parent => Puppet::Provider::ParsedFile, | |
:default_target => File.expand_path("~/etc/hosts"), | |
:filetype => :flat, | |
:record_type => :parsed, | |
) do | |
confine :exists => File.expand_path("~/etc") | |
confine :role => :student |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Puppet::Type.type(:host).provide(:classroom, | |
:parent => :parsed, | |
:default_target => File.expand_path("~/etc/hosts"), | |
:filetype => :flat, | |
:record_type => :parsed, | |
) do | |
confine :exists => File.expand_path("~/etc") | |
confine :role => :student | |
defaultfor :osfamily => :redhat |