puppet 0.25.1 → 0.25.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +159 -135
- data/Rakefile +4 -1
- data/conf/gentoo/conf.d/puppetmaster +1 -1
- data/conf/osx/createpackage.sh +12 -0
- data/conf/osx/preflight +4 -0
- data/conf/redhat/puppet.spec +12 -2
- data/conf/redhat/server.init +1 -0
- data/conf/redhat/server.sysconfig +1 -1
- data/ext/ldap/puppet.schema +5 -9
- data/ext/puppetlast +2 -1
- data/ext/rack/README +2 -2
- data/ext/regexp_nodes/classes/databases +2 -0
- data/ext/regexp_nodes/classes/webservers +2 -0
- data/ext/regexp_nodes/parameters/environment/prod +1 -0
- data/ext/regexp_nodes/parameters/environment/qa +3 -0
- data/ext/regexp_nodes/regexp_nodes.rb +215 -0
- data/lib/puppet.rb +1 -1
- data/lib/puppet/agent.rb +2 -2
- data/lib/puppet/application/puppet.rb +1 -1
- data/lib/puppet/application/puppetd.rb +1 -1
- data/lib/puppet/application/puppetdoc.rb +4 -3
- data/lib/puppet/application/puppetrun.rb +5 -14
- data/lib/puppet/application/ralsh.rb +9 -25
- data/lib/puppet/configurer.rb +2 -1
- data/lib/puppet/configurer/fact_handler.rb +8 -6
- data/lib/puppet/daemon.rb +2 -2
- data/lib/puppet/defaults.rb +21 -2
- data/lib/puppet/external/pson/common.rb +1 -1
- data/lib/puppet/external/pson/pure.rb +3 -3
- data/lib/puppet/feature/base.rb +3 -0
- data/lib/puppet/feature/selinux.rb +3 -0
- data/lib/puppet/feature/zlib.rb +6 -0
- data/lib/puppet/file_serving/base.rb +16 -1
- data/lib/puppet/file_serving/metadata.rb +46 -9
- data/lib/puppet/file_serving/mount/file.rb +4 -1
- data/lib/puppet/indirector/catalog/active_record.rb +5 -0
- data/lib/puppet/indirector/envelope.rb +1 -3
- data/lib/puppet/indirector/indirection.rb +13 -16
- data/lib/puppet/indirector/node/ldap.rb +7 -4
- data/lib/puppet/indirector/ssl_file.rb +1 -1
- data/lib/puppet/network/authstore.rb +48 -118
- data/lib/puppet/network/client/resource.rb +2 -15
- data/lib/puppet/network/format.rb +2 -12
- data/lib/puppet/network/format_handler.rb +15 -1
- data/lib/puppet/network/formats.rb +19 -4
- data/lib/puppet/network/handler/fileserver.rb +1 -0
- data/lib/puppet/network/http/handler.rb +1 -0
- data/lib/puppet/network/http/rack/httphandler.rb +0 -18
- data/lib/puppet/network/http/rack/rest.rb +4 -4
- data/lib/puppet/network/http/rack/xmlrpc.rb +4 -4
- data/lib/puppet/network/http/webrick.rb +2 -1
- data/lib/puppet/network/server.rb +1 -1
- data/lib/puppet/node/environment.rb +20 -9
- data/lib/puppet/parameter.rb +17 -1
- data/lib/puppet/parser/ast/boolean_operator.rb +2 -2
- data/lib/puppet/parser/ast/leaf.rb +5 -1
- data/lib/puppet/parser/ast/resourceparam.rb +4 -0
- data/lib/puppet/parser/ast/selector.rb +4 -0
- data/lib/puppet/parser/functions/generate.rb +2 -2
- data/lib/puppet/parser/functions/shellquote.rb +1 -1
- data/lib/puppet/property.rb +3 -11
- data/lib/puppet/provider/cron/crontab.rb +2 -0
- data/lib/puppet/provider/host/parsed.rb +9 -9
- data/lib/puppet/provider/package/blastwave.rb +7 -6
- data/lib/puppet/provider/package/portage.rb +23 -27
- data/lib/puppet/provider/package/rug.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +5 -3
- data/lib/puppet/provider/service/daemontools.rb +1 -1
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/runit.rb +1 -1
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +2 -1
- data/lib/puppet/provider/sshkey/parsed.rb +3 -5
- data/lib/puppet/provider/zone/solaris.rb +1 -1
- data/lib/puppet/rails.rb +9 -2
- data/lib/puppet/rails/benchmark.rb +1 -1
- data/lib/puppet/rails/host.rb +2 -7
- data/lib/puppet/rails/resource.rb +20 -26
- data/lib/puppet/resource/catalog.rb +3 -3
- data/lib/puppet/resource/reference.rb +13 -25
- data/lib/puppet/ssl/certificate.rb +3 -2
- data/lib/puppet/ssl/host.rb +14 -33
- data/lib/puppet/sslcertificates.rb +1 -5
- data/lib/puppet/sslcertificates/ca.rb +8 -7
- data/lib/puppet/transaction.rb +15 -12
- data/lib/puppet/type.rb +12 -5
- data/lib/puppet/type/file.rb +26 -32
- data/lib/puppet/type/file/content.rb +5 -5
- data/lib/puppet/type/file/ensure.rb +6 -17
- data/lib/puppet/type/file/mode.rb +18 -1
- data/lib/puppet/type/file/source.rb +12 -12
- data/lib/puppet/type/host.rb +6 -9
- data/lib/puppet/type/k5login.rb +1 -1
- data/lib/puppet/type/maillist.rb +4 -7
- data/lib/puppet/type/port.rb +6 -5
- data/lib/puppet/type/resources.rb +12 -12
- data/lib/puppet/type/sshkey.rb +5 -5
- data/lib/puppet/type/tidy.rb +9 -2
- data/lib/puppet/type/yumrepo.rb +3 -1
- data/lib/puppet/util.rb +64 -56
- data/lib/puppet/util/backups.rb +2 -1
- data/lib/puppet/util/filetype.rb +46 -0
- data/lib/puppet/util/log.rb +10 -18
- data/lib/puppet/util/log_paths.rb +14 -0
- data/lib/puppet/util/methodhelper.rb +3 -4
- data/lib/puppet/util/monkey_patches.rb +8 -0
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +5 -3
- data/lib/puppet/util/rdoc/parser.rb +32 -16
- data/lib/puppet/util/reference.rb +6 -3
- data/lib/puppet/util/selinux.rb +21 -14
- data/lib/puppet/util/settings.rb +30 -25
- data/lib/puppet/util/settings/file_setting.rb +7 -4
- data/lib/puppet/util/subclass_loader.rb +1 -1
- data/lib/puppet/util/suidmanager.rb +11 -1
- data/lib/puppet/util/tagging.rb +22 -4
- data/man/man8/filebucket.8 +23 -18
- data/man/man8/pi.8 +42 -20
- data/man/man8/puppet.8 +47 -32
- data/man/man8/puppet.conf.8 +807 -764
- data/man/man8/puppetca.8 +24 -14
- data/man/man8/puppetd.8 +33 -16
- data/man/man8/puppetdoc.8 +71 -18
- data/man/man8/puppetmasterd.8 +18 -25
- data/man/man8/puppetqd.8 +60 -0
- data/man/man8/puppetrun.8 +27 -14
- data/man/man8/ralsh.8 +33 -40
- data/spec/integration/bin/puppetmasterd.rb +3 -2
- data/spec/integration/defaults.rb +11 -0
- data/spec/integration/file_serving/metadata.rb +1 -0
- data/spec/integration/indirector/file_content/file_server.rb +2 -1
- data/spec/integration/ssl/certificate_request.rb +2 -0
- data/spec/integration/type/file.rb +20 -1
- data/spec/shared_behaviours/file_serving.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/application/puppet.rb +11 -30
- data/spec/unit/application/puppetd.rb +1 -0
- data/spec/unit/application/puppetdoc.rb +13 -4
- data/spec/unit/application/puppetmasterd.rb +1 -0
- data/spec/unit/application/puppetrun.rb +12 -2
- data/spec/unit/application/ralsh.rb +39 -22
- data/spec/unit/configurer.rb +6 -0
- data/spec/unit/configurer/fact_handler.rb +15 -1
- data/spec/unit/file_serving/metadata.rb +128 -16
- data/spec/unit/file_serving/mount/file.rb +8 -0
- data/spec/unit/indirector/catalog/active_record.rb +20 -1
- data/spec/unit/indirector/catalog/compiler.rb +2 -1
- data/spec/unit/indirector/indirection.rb +29 -18
- data/spec/unit/indirector/node/ldap.rb +20 -6
- data/spec/unit/network/authstore.rb +197 -0
- data/spec/unit/network/format_handler.rb +28 -8
- data/spec/unit/network/formats.rb +31 -0
- data/spec/unit/network/http/handler.rb +10 -0
- data/spec/unit/network/http/webrick.rb +2 -2
- data/spec/unit/network/rest_authconfig.rb +2 -2
- data/spec/unit/network/rights.rb +1 -1
- data/spec/unit/node/environment.rb +39 -23
- data/spec/unit/other/selinux.rb +2 -2
- data/spec/unit/parameter.rb +8 -0
- data/spec/unit/parser/ast/leaf.rb +9 -0
- data/spec/unit/parser/ast/selector.rb +8 -1
- data/spec/unit/parser/lexer.rb +1 -1
- data/spec/unit/parser/resource.rb +11 -0
- data/spec/unit/parser/resource/reference.rb +13 -1
- data/spec/unit/property.rb +6 -0
- data/spec/unit/provider/mount/parsed.rb +3 -1
- data/spec/unit/provider/service/debian.rb +1 -1
- data/spec/unit/provider/ssh_authorized_key/parsed.rb +9 -1
- data/spec/unit/provider/sshkey/parsed.rb +19 -0
- data/spec/unit/rails.rb +22 -9
- data/spec/unit/rails/resource.rb +20 -0
- data/spec/unit/ssl/host.rb +19 -57
- data/spec/unit/transaction.rb +39 -4
- data/spec/unit/type.rb +9 -0
- data/spec/unit/type/file/content.rb +29 -0
- data/spec/unit/type/maillist.rb +42 -0
- data/spec/unit/type/resources.rb +66 -1
- data/spec/unit/type/tidy.rb +14 -1
- data/spec/unit/util/autoload.rb +2 -0
- data/spec/unit/util/ldap/connection.rb +1 -1
- data/spec/unit/util/log.rb +14 -0
- data/spec/unit/util/monkey_patches.rb +103 -0
- data/spec/unit/util/queue.rb +10 -2
- data/spec/unit/util/selinux.rb +61 -2
- data/spec/unit/util/settings.rb +19 -0
- data/spec/unit/util/settings/file_setting.rb +25 -0
- data/spec/unit/util/tagging.rb +10 -0
- data/tasks/rake/changelog.rake +15 -0
- data/tasks/rake/ci.rake +22 -0
- data/tasks/rake/dailybuild.rake +9 -0
- data/tasks/rake/gem.rake +46 -0
- data/tasks/rake/git_workflow.rake +121 -0
- data/tasks/rake/metrics.rake +6 -0
- data/tasks/rake/sign.rake +14 -0
- data/tasks/rake/testbranch.rake +16 -0
- data/tasks/rake/tracdocs.rake +8 -0
- data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +1 -0
- metadata +1042 -1288
- data/ext/bin/sleeper +0 -67
- data/ext/module_puppet +0 -209
data/conf/redhat/server.init
CHANGED
data/ext/ldap/puppet.schema
CHANGED
@@ -1,28 +1,24 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# $Id$
|
4
|
-
|
5
|
-
attributetype ( 1.1.3.10 NAME 'puppetclass'
|
1
|
+
attributetype ( 1.3.6.1.4.1.34380.1.1.3.10 NAME 'puppetClass'
|
6
2
|
DESC 'Puppet Node Class'
|
7
3
|
EQUALITY caseIgnoreIA5Match
|
8
4
|
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
|
9
5
|
|
10
|
-
attributetype ( 1.1.3.9 NAME '
|
6
|
+
attributetype ( 1.3.6.1.4.1.34380.1.1.3.9 NAME 'parentNode'
|
11
7
|
DESC 'Puppet Parent Node'
|
12
8
|
EQUALITY caseIgnoreIA5Match
|
13
9
|
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
|
14
10
|
SINGLE-VALUE )
|
15
11
|
|
16
|
-
attributetype ( 1.1.3.11 NAME 'environment'
|
12
|
+
attributetype ( 1.3.6.1.4.1.34380.1.1.3.11 NAME 'environment'
|
17
13
|
DESC 'Puppet Node Environment'
|
18
14
|
EQUALITY caseIgnoreIA5Match
|
19
15
|
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
|
20
16
|
|
21
|
-
attributetype ( 1.1.3.12 NAME '
|
17
|
+
attributetype ( 1.3.6.1.4.1.34380.1.1.3.12 NAME 'puppetVar'
|
22
18
|
DESC 'A variable setting for puppet'
|
23
19
|
EQUALITY caseIgnoreIA5Match
|
24
20
|
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
|
25
21
|
|
26
|
-
objectclass ( 1.1.1.2 NAME 'puppetClient' SUP top AUXILIARY
|
22
|
+
objectclass ( 1.3.6.1.4.1.34380.1.1.1.2 NAME 'puppetClient' SUP top AUXILIARY
|
27
23
|
DESC 'Puppet Client objectclass'
|
28
24
|
MAY ( puppetclass $ parentnode $ environment $ puppetvar ))
|
data/ext/puppetlast
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
# AJ "Fujin" Christensen <aj@junglist.gen.nz>
|
5
5
|
#
|
6
6
|
require 'puppet'
|
7
|
+
require 'time'
|
7
8
|
|
8
9
|
Puppet[:config] = "/etc/puppet/puppet.conf"
|
9
10
|
Puppet.parse_config
|
@@ -11,5 +12,5 @@ Puppet[:name] = "puppetmasterd"
|
|
11
12
|
Puppet::Node::Facts.terminus_class = :yaml
|
12
13
|
|
13
14
|
Puppet::Node::Facts.search("*").sort { |a,b| a.name <=> b.name }.each do |node|
|
14
|
-
puts "#{node.name} #{node.expired? ? 'cached expired, ' : ''}checked in #{((Time.now - node.values[:_timestamp]) / 60).floor} minutes ago"
|
15
|
+
puts "#{node.name} #{node.expired? ? 'cached expired, ' : ''}checked in #{((Time.now - Time.parse(node.values[:_timestamp])) / 60).floor} minutes ago"
|
15
16
|
end
|
data/ext/rack/README
CHANGED
@@ -43,7 +43,7 @@ Make sure puppetmasterd ran at least once, so the CA & SSL certificates
|
|
43
43
|
got set up.
|
44
44
|
|
45
45
|
Requirements:
|
46
|
-
Passenger version 2.2.2 or newer***
|
46
|
+
Passenger version 2.2.2 or 2.2.5 or newer***
|
47
47
|
Rack version 1.0.0
|
48
48
|
Apache 2.x
|
49
49
|
SSL Module loaded
|
@@ -68,6 +68,6 @@ config.ru. Therefore, config.ru shall be owned by the puppet user.
|
|
68
68
|
*** Important note about Passenger versions:
|
69
69
|
2.2.2 is known to work.
|
70
70
|
2.2.3-2.2.4 are known to *NOT* work.
|
71
|
-
2.2.5
|
71
|
+
2.2.5 works again when used with Puppet 0.25.2+.
|
72
72
|
Passenger installation doc: http://www.modrails.com/install.html
|
73
73
|
|
@@ -0,0 +1 @@
|
|
1
|
+
\d{3}$
|
@@ -0,0 +1,215 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# = Synopsis
|
4
|
+
# This is an external node classifier script, after
|
5
|
+
# http://reductivelabs.com/trac/puppet/wiki/ExternalNodes
|
6
|
+
#
|
7
|
+
# = Usage
|
8
|
+
# regexp_nodes.rb <host>
|
9
|
+
#
|
10
|
+
# = Description
|
11
|
+
# This classifier implements filesystem autoloading: It looks through classes
|
12
|
+
# and parameters subdirectories, looping through each file it finds there - the
|
13
|
+
# contents are a regexp-per-line which, if they match the hostname passed us as
|
14
|
+
# ARGV[0], will cause a class or parameter named the same thing as the file to
|
15
|
+
# be set.
|
16
|
+
#
|
17
|
+
# = Examples
|
18
|
+
# In the distribution there are two subdirectories test_classes/ and
|
19
|
+
# test_parameters, which are passed as parameters to MyExternalNode.new.
|
20
|
+
# test_classes/database will set the 'database' class for any hostnames
|
21
|
+
# matching %r{db\d{2}} (that is, 'db' followed by two digits) or with 'mysql'
|
22
|
+
# anywhere in the hostname. Similarly, hosts beginning with 'www' or 'web'
|
23
|
+
# or the hostname 'leterel' (my workstation) will be assigned the 'webserver'
|
24
|
+
# class.
|
25
|
+
#
|
26
|
+
# Under test_parameters/ there is one subdirectory 'environment' which
|
27
|
+
# sets the a parameter called 'environment' to the value 'prod' for production
|
28
|
+
# hosts (whose hostnames always end with three numbers for us), 'qa' for
|
29
|
+
# anything that starts with 'qa-' 'qa2-' or 'qa3-', and 'sandbox' for any
|
30
|
+
# development machines which are, naturally, named after Autechre songs.
|
31
|
+
#
|
32
|
+
#
|
33
|
+
# = Author
|
34
|
+
# Eric Sorenson <esorenson@apple.com>
|
35
|
+
|
36
|
+
|
37
|
+
# we need yaml or there's not much point in going on
|
38
|
+
require 'yaml'
|
39
|
+
|
40
|
+
# Sets are like arrays but automatically de-duplicate elements
|
41
|
+
require 'set'
|
42
|
+
|
43
|
+
# set up some nice logging
|
44
|
+
require 'logger'
|
45
|
+
# XXX flip this for production vs local sandbox
|
46
|
+
# $LOG = Logger.new("/var/puppet/log/extnodes.log")
|
47
|
+
# $LOG.level = Logger::FATAL
|
48
|
+
$LOG = Logger.new($stderr)
|
49
|
+
$LOG.level = Logger::DEBUG
|
50
|
+
|
51
|
+
# paths for files we use will be relative to this directory
|
52
|
+
# XXX flip this for production vs local sandbox
|
53
|
+
# WORKINGDIR = "/var/puppet/bin"
|
54
|
+
WORKINGDIR = Dir.pwd
|
55
|
+
|
56
|
+
# This class holds all the methods for creating and accessing the properties
|
57
|
+
# of an external node. There are really only two public methods: initialize()
|
58
|
+
# and a special version of to_yaml()
|
59
|
+
|
60
|
+
class ExternalNode
|
61
|
+
# Make these instance variables get/set-able with eponymous methods
|
62
|
+
attr_accessor :classes, :parameters, :hostname
|
63
|
+
|
64
|
+
# initialize() takes three arguments:
|
65
|
+
# hostname:: usually passed in via ARGV[0] but it could be anything
|
66
|
+
# classdir:: directory under WORKINGDIR to look for files named after
|
67
|
+
# classes
|
68
|
+
# parameterdir:: directory under WORKINGDIR to look for directories to set
|
69
|
+
# parameters
|
70
|
+
def initialize(hostname, classdir = 'classes/', parameterdir = 'parameters/')
|
71
|
+
# instance variables that contain the lists of classes and parameters
|
72
|
+
@hostname
|
73
|
+
@classes = Set.new ["baseclass"]
|
74
|
+
@parameters = Hash.new("unknown") # sets a default value of "unknown"
|
75
|
+
|
76
|
+
self.parse_argv(hostname)
|
77
|
+
self.match_classes(WORKINGDIR + "/" + classdir)
|
78
|
+
self.match_parameters(WORKINGDIR + "/" + parameterdir)
|
79
|
+
end
|
80
|
+
|
81
|
+
# private method called by initialize() which sanity-checks our hostname.
|
82
|
+
# good candidate for overriding in a subclass if you need different checks
|
83
|
+
def parse_argv(hostname)
|
84
|
+
if hostname =~ /^([-\w]+?)\.([-\w\.]+)/ # non-greedy up to the first . is hostname
|
85
|
+
@hostname = $1
|
86
|
+
elsif hostname =~ /^([-\w]+)$/ # sometimes puppet's @name is just a name
|
87
|
+
@hostname = hostname
|
88
|
+
else
|
89
|
+
$LOG.fatal("didn't receive parsable hostname, got: [#{hostname}]")
|
90
|
+
exit(1)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# to_yaml massages a copy of the object and outputs clean yaml so we don't
|
95
|
+
# feed weird things back to puppet []<
|
96
|
+
def to_yaml
|
97
|
+
classes = self.classes.to_a
|
98
|
+
if self.parameters.empty? # otherwise to_yaml prints "parameters: {}"
|
99
|
+
parameters = nil
|
100
|
+
else
|
101
|
+
parameters = self.parameters
|
102
|
+
end
|
103
|
+
({ 'classes' => classes, 'parameters' => parameters}).to_yaml
|
104
|
+
end
|
105
|
+
|
106
|
+
# Private method that expects an absolute path to a file and a string to
|
107
|
+
# match - it returns true if the string was matched by any of the lines in
|
108
|
+
# the file
|
109
|
+
def matched_in_patternfile?(filepath, matchthis)
|
110
|
+
|
111
|
+
patternlist = []
|
112
|
+
|
113
|
+
begin
|
114
|
+
open(filepath).each { |l|
|
115
|
+
pattern = %r{#{l.chomp!}}
|
116
|
+
patternlist << pattern
|
117
|
+
$LOG.debug("appending [#{pattern}] to patternlist for [#{filepath}]")
|
118
|
+
}
|
119
|
+
rescue Exception
|
120
|
+
$LOG.fatal("Problem reading #{filepath}: #{$!}")
|
121
|
+
exit(1)
|
122
|
+
end
|
123
|
+
|
124
|
+
$LOG.debug("list of patterns for #{filepath}: #{patternlist}")
|
125
|
+
|
126
|
+
if matchthis =~ Regexp.union(patternlist)
|
127
|
+
$LOG.debug("matched #{$~.to_s} in #{matchthis}, returning true")
|
128
|
+
return true
|
129
|
+
|
130
|
+
else # hostname didn't match anything in patternlist
|
131
|
+
$LOG.debug("#{matchthis} unmatched, returning false")
|
132
|
+
return nil
|
133
|
+
end
|
134
|
+
|
135
|
+
end # def
|
136
|
+
|
137
|
+
# private method - takes a path to look for files, iterates through all
|
138
|
+
# readable, regular files it finds, and matches this instance's @hostname
|
139
|
+
# against each line; if any match, the class will be set for this node.
|
140
|
+
def match_classes(fullpath)
|
141
|
+
Dir.foreach(fullpath) do |patternfile|
|
142
|
+
filepath = "#{fullpath}/#{patternfile}"
|
143
|
+
next unless File.file?(filepath) and
|
144
|
+
File.readable?(filepath)
|
145
|
+
$LOG.debug("Attempting to match [#{@hostname}] in [#{filepath}]")
|
146
|
+
if matched_in_patternfile?(filepath,@hostname)
|
147
|
+
@classes << patternfile.to_s
|
148
|
+
$LOG.debug("Appended #{patternfile.to_s} to classes instance variable")
|
149
|
+
end # if
|
150
|
+
end # Dir.foreach
|
151
|
+
end # def
|
152
|
+
|
153
|
+
# Parameters are handled slightly differently; we make another level of
|
154
|
+
# directories to get the parameter name, then use the names of the files
|
155
|
+
# contained in there for the values of those parameters.
|
156
|
+
#
|
157
|
+
# ex: cat /var/puppet/bin/parameters/environment/production
|
158
|
+
# ^prodweb
|
159
|
+
# would set parameters["environment"] = "production" for prodweb001
|
160
|
+
def match_parameters(fullpath)
|
161
|
+
Dir.foreach(fullpath) do |parametername|
|
162
|
+
|
163
|
+
filepath = "#{fullpath}/#{parametername}"
|
164
|
+
next if File.basename(filepath) =~ /^\./ # skip over dotfiles
|
165
|
+
|
166
|
+
next unless File.directory?(filepath) and
|
167
|
+
File.readable?(filepath) # skip over non-directories
|
168
|
+
|
169
|
+
$LOG.debug "Considering contents of #{filepath}"
|
170
|
+
|
171
|
+
Dir.foreach("#{filepath}") do |patternfile|
|
172
|
+
secondlevel = "#{filepath}/#{patternfile}"
|
173
|
+
$LOG.debug "Found parameters patternfile at #{secondlevel}"
|
174
|
+
next unless File.file?(secondlevel) and
|
175
|
+
File.readable?(secondlevel)
|
176
|
+
$LOG.debug("Attempting to match [#{@hostname}] in [#{secondlevel}]")
|
177
|
+
if matched_in_patternfile?(secondlevel, @hostname)
|
178
|
+
@parameters[ parametername.to_s ] = patternfile.to_s
|
179
|
+
$LOG.debug("Set @parameters[#{parametername.to_s}] = #{patternfile.to_s}")
|
180
|
+
end # if
|
181
|
+
end # Dir.foreach #{filepath}
|
182
|
+
end # Dir.foreach #{fullpath}
|
183
|
+
end # def
|
184
|
+
|
185
|
+
end # Class
|
186
|
+
|
187
|
+
# Logic for local hacks that don't fit neatly into the autoloading model can
|
188
|
+
# happen as we initialize a subclass
|
189
|
+
class MyExternalNode < ExternalNode
|
190
|
+
|
191
|
+
def initialize(hostname, classdir = 'classes/', parameterdir = 'parameters/')
|
192
|
+
|
193
|
+
super
|
194
|
+
|
195
|
+
# Set "hostclass" parameter based on hostname,
|
196
|
+
# stripped of leading environment prefix and numeric suffix
|
197
|
+
if @hostname =~ /^(\w*?)-?(\D+)(\d{2,3})$/
|
198
|
+
match = Regexp.last_match
|
199
|
+
|
200
|
+
hostclass = match[2]
|
201
|
+
$LOG.debug("matched hostclass #{hostclass}")
|
202
|
+
@parameters[ "hostclass" ] = hostclass
|
203
|
+
else
|
204
|
+
$LOG.debug("hostclass couldn't figure out class from #{@hostname}")
|
205
|
+
end # if
|
206
|
+
end # def
|
207
|
+
|
208
|
+
end # Class
|
209
|
+
|
210
|
+
|
211
|
+
# Here we begin actual execution by calling methods defined above
|
212
|
+
|
213
|
+
mynode = MyExternalNode.new(ARGV[0], classes = 'test_classes', parameters = 'test_parameters')
|
214
|
+
|
215
|
+
puts mynode.to_yaml
|
data/lib/puppet.rb
CHANGED
data/lib/puppet/agent.rb
CHANGED
@@ -51,7 +51,7 @@ class Puppet::Agent
|
|
51
51
|
with_client do |client|
|
52
52
|
begin
|
53
53
|
sync.synchronize { lock { client.run(*args) } }
|
54
|
-
rescue => detail
|
54
|
+
rescue Exception => detail
|
55
55
|
puts detail.backtrace if Puppet[:trace]
|
56
56
|
Puppet.err "Could not run %s: %s" % [client_class, detail]
|
57
57
|
end
|
@@ -122,7 +122,7 @@ class Puppet::Agent
|
|
122
122
|
def with_client
|
123
123
|
begin
|
124
124
|
@client = client_class.new
|
125
|
-
rescue => detail
|
125
|
+
rescue Exception => detail
|
126
126
|
puts detail.backtrace if Puppet[:trace]
|
127
127
|
Puppet.err "Could not create instance of %s: %s" % [client_class, detail]
|
128
128
|
return
|
@@ -49,7 +49,7 @@ Puppet::Application.new(:puppet) do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
begin
|
52
|
-
catalog =
|
52
|
+
catalog = Puppet::Resource::Catalog.convert_from(Puppet::Resource::Catalog.default_format,text)
|
53
53
|
unless catalog.is_a?(Puppet::Resource::Catalog)
|
54
54
|
catalog = Puppet::Resource::Catalog.pson_create(catalog)
|
55
55
|
end
|
@@ -125,7 +125,7 @@ Puppet::Application.new(:puppetd) do
|
|
125
125
|
Puppet.settings.handlearg("--no-daemonize")
|
126
126
|
options[:verbose] = true
|
127
127
|
options[:onetime] = true
|
128
|
-
options[:waitforcert] = 0
|
128
|
+
options[:waitforcert] = 0 unless @explicit_waitforcert
|
129
129
|
end
|
130
130
|
|
131
131
|
# Handle the logging settings.
|
@@ -66,8 +66,9 @@ Puppet::Application.new(:puppetdoc) do
|
|
66
66
|
exit_code = 0
|
67
67
|
files = []
|
68
68
|
unless @manifest
|
69
|
-
|
70
|
-
files +=
|
69
|
+
env = Puppet::Node::Environment.new
|
70
|
+
files += env.modulepath
|
71
|
+
files << File.dirname(env[:manifest])
|
71
72
|
end
|
72
73
|
files += ARGV
|
73
74
|
Puppet.info "scanning: %s" % files.inspect
|
@@ -191,7 +192,7 @@ Puppet::Application.new(:puppetdoc) do
|
|
191
192
|
end
|
192
193
|
end
|
193
194
|
|
194
|
-
def setup_rdoc
|
195
|
+
def setup_rdoc(dummy_argument=:work_arround_for_ruby_GC_bug)
|
195
196
|
# consume the unknown options
|
196
197
|
# and feed them as settings
|
197
198
|
if @unknown_args.size > 0
|
@@ -1,18 +1,9 @@
|
|
1
|
-
begin
|
2
|
-
require 'rubygems'
|
3
|
-
rescue LoadError
|
4
|
-
# Nothing; we were just doing this just in case
|
5
|
-
end
|
6
|
-
|
7
|
-
begin
|
8
|
-
require 'ldap'
|
9
|
-
rescue LoadError
|
10
|
-
$stderr.puts "Failed to load ruby LDAP library. LDAP functionality will not be available"
|
11
|
-
end
|
12
|
-
|
13
1
|
require 'puppet'
|
14
2
|
require 'puppet/application'
|
15
3
|
|
4
|
+
Puppet.warning "RubyGems not installed" unless Puppet.features.rubygems?
|
5
|
+
Puppet.warning "Failed to load ruby LDAP library. LDAP functionality will not be available" unless Puppet.features.ldap?
|
6
|
+
|
16
7
|
Puppet::Application.new(:puppetrun) do
|
17
8
|
|
18
9
|
should_not_parse_config
|
@@ -176,12 +167,12 @@ Puppet::Application.new(:puppetrun) do
|
|
176
167
|
|
177
168
|
if Puppet[:node_terminus] == "ldap" and (options[:all] or @classes)
|
178
169
|
if options[:all]
|
179
|
-
@hosts = Puppet::Node.search("whatever").collect { |node| node.name }
|
170
|
+
@hosts = Puppet::Node.search("whatever", :fqdn => options[:fqdn]).collect { |node| node.name }
|
180
171
|
puts "all: %s" % @hosts.join(", ")
|
181
172
|
else
|
182
173
|
@hosts = []
|
183
174
|
@classes.each do |klass|
|
184
|
-
list = Puppet::Node.search("whatever", :class => klass).collect { |node| node.name }
|
175
|
+
list = Puppet::Node.search("whatever", :fqdn => options[:fqdn], :class => klass).collect { |node| node.name }
|
185
176
|
puts "%s: %s" % [klass, list.join(", ")]
|
186
177
|
|
187
178
|
@hosts += list
|
@@ -38,25 +38,15 @@ Puppet::Application.new(:ralsh) do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
command(:main) do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
raise "You must specify the type to display"
|
45
|
-
end
|
46
|
-
|
47
|
-
name = nil
|
41
|
+
type = ARGV.shift or raise "You must specify the type to display"
|
42
|
+
typeobj = Puppet::Type.type(type) or raise "Could not find type #{type}"
|
43
|
+
name = ARGV.shift
|
48
44
|
params = {}
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
ARGV.each do |setting|
|
55
|
-
if setting =~ /^(\w+)=(.+)$/
|
56
|
-
params[$1] = $2
|
57
|
-
else
|
58
|
-
raise "Invalid parameter setting %s" % setting
|
59
|
-
end
|
45
|
+
ARGV.each do |setting|
|
46
|
+
if setting =~ /^(\w+)=(.+)$/
|
47
|
+
params[$1] = $2
|
48
|
+
else
|
49
|
+
raise "Invalid parameter setting %s" % setting
|
60
50
|
end
|
61
51
|
end
|
62
52
|
|
@@ -64,12 +54,6 @@ Puppet::Application.new(:ralsh) do
|
|
64
54
|
raise "You cannot edit a remote host"
|
65
55
|
end
|
66
56
|
|
67
|
-
typeobj = nil
|
68
|
-
|
69
|
-
unless typeobj = Puppet::Type.type(type)
|
70
|
-
raise "Could not find type %s" % type
|
71
|
-
end
|
72
|
-
|
73
57
|
properties = typeobj.properties.collect { |s| s.name }
|
74
58
|
|
75
59
|
format = proc {|trans|
|
@@ -106,7 +90,7 @@ Puppet::Application.new(:ralsh) do
|
|
106
90
|
transbucket.sort { |a,b| a.name <=> b.name }.collect(&format)
|
107
91
|
else
|
108
92
|
if name
|
109
|
-
obj = typeobj.new(:name => name, :check => properties)
|
93
|
+
obj = typeobj.instances.find { |o| o.name == name } || typeobj.new(:name => name, :check => properties)
|
110
94
|
vals = obj.retrieve
|
111
95
|
|
112
96
|
unless params.empty?
|