This file contains 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(:failclass, :doc => 'Calling this function will immediately fail the class in current scope and mark all contained resources as failed.') do |args| | |
raise ArgumentError, ("failclass(): call with a single argument, the message.)") if args.length != 1 | |
# build a resource | |
p_resource = Puppet::Parser::Resource.new(:whit, args[0], :scope => self, :source => resource) | |
# then add requirements to all other resources in scope. | |
# how do i select all resources in current scope? | |
compiler.catalog.resources.select{ |x| x[:scope] == self }.each do |res| |
This file contains 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
def in_puppet? | |
defined?(Puppet) | |
end |
This file contains 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
$users = [ 'billy', 'bob', 'thornton' ] | |
user { $users: | |
ensure => present, | |
} |
This file contains 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
<% scope.catalog.resources.select{|x| x.class? }.each do |klass| -%> | |
<%= klass.to_s %> | |
<% end -%> |
This file contains 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 describe --list | grep rcsrepo | |
rcsrepo - .. no documentation .. | |
[root@master ~]# puppet describe rcsrepo | |
rcsrepo | |
======= | |
A local version control repository |
This file contains 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
$rand = fqdn_rand(59) | |
$puppet_crontime = "${rand} * * * *" |
This file contains 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
# <modulepath>/<somemodule>/lib/puppet/parser/functions/my_fqdn_rand.rb | |
Puppet::Parser::Functions.newfunction( | |
:my_fqdn_rand, | |
:type => :rvalue, | |
:doc => 'runs on ruby 1.9!' | |
) do |args| | |
raise ArgumentError, 'my_fqdn_rand: accepts only one argument' if args != 1 | |
function_fqdn_rand(args[0].to_i) | |
end |
This file contains 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 x { | |
$x1 = 'stuff' | |
include x::y | |
$x2 = 'more stuff' | |
} | |
class x::y { | |
notify { $x::x1: } | |
notify { $x::x2: } | |
} |
This file contains 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
module MCollective | |
module Agent | |
class Netserv<RPC::Agent | |
metadata :name => "netserv", | |
:description => "Network services for MCollective", | |
:author => "Ben Ford", | |
:license => "GPLv2", | |
:version => "1.1", | |
:url => "http://www.puppetlabs.com.com/education", | |
:timeout => 60 |
This file contains 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
# this should go in <module>/lib/puppet/parser/functions/filter_hash.rb | |
Puppet::Parser::Functions.newfunction(:filter_hash) do |args| | |
rv = {} | |
args[0].collect do |key, item| | |
rv[key] = { 'hostname' => item['hostname'], 'path' => item['path'] } | |
end | |
return rv | |
end |
OlderNewer