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.

Files changed (198) hide show
  1. data/CHANGELOG +159 -135
  2. data/Rakefile +4 -1
  3. data/conf/gentoo/conf.d/puppetmaster +1 -1
  4. data/conf/osx/createpackage.sh +12 -0
  5. data/conf/osx/preflight +4 -0
  6. data/conf/redhat/puppet.spec +12 -2
  7. data/conf/redhat/server.init +1 -0
  8. data/conf/redhat/server.sysconfig +1 -1
  9. data/ext/ldap/puppet.schema +5 -9
  10. data/ext/puppetlast +2 -1
  11. data/ext/rack/README +2 -2
  12. data/ext/regexp_nodes/classes/databases +2 -0
  13. data/ext/regexp_nodes/classes/webservers +2 -0
  14. data/ext/regexp_nodes/parameters/environment/prod +1 -0
  15. data/ext/regexp_nodes/parameters/environment/qa +3 -0
  16. data/ext/regexp_nodes/regexp_nodes.rb +215 -0
  17. data/lib/puppet.rb +1 -1
  18. data/lib/puppet/agent.rb +2 -2
  19. data/lib/puppet/application/puppet.rb +1 -1
  20. data/lib/puppet/application/puppetd.rb +1 -1
  21. data/lib/puppet/application/puppetdoc.rb +4 -3
  22. data/lib/puppet/application/puppetrun.rb +5 -14
  23. data/lib/puppet/application/ralsh.rb +9 -25
  24. data/lib/puppet/configurer.rb +2 -1
  25. data/lib/puppet/configurer/fact_handler.rb +8 -6
  26. data/lib/puppet/daemon.rb +2 -2
  27. data/lib/puppet/defaults.rb +21 -2
  28. data/lib/puppet/external/pson/common.rb +1 -1
  29. data/lib/puppet/external/pson/pure.rb +3 -3
  30. data/lib/puppet/feature/base.rb +3 -0
  31. data/lib/puppet/feature/selinux.rb +3 -0
  32. data/lib/puppet/feature/zlib.rb +6 -0
  33. data/lib/puppet/file_serving/base.rb +16 -1
  34. data/lib/puppet/file_serving/metadata.rb +46 -9
  35. data/lib/puppet/file_serving/mount/file.rb +4 -1
  36. data/lib/puppet/indirector/catalog/active_record.rb +5 -0
  37. data/lib/puppet/indirector/envelope.rb +1 -3
  38. data/lib/puppet/indirector/indirection.rb +13 -16
  39. data/lib/puppet/indirector/node/ldap.rb +7 -4
  40. data/lib/puppet/indirector/ssl_file.rb +1 -1
  41. data/lib/puppet/network/authstore.rb +48 -118
  42. data/lib/puppet/network/client/resource.rb +2 -15
  43. data/lib/puppet/network/format.rb +2 -12
  44. data/lib/puppet/network/format_handler.rb +15 -1
  45. data/lib/puppet/network/formats.rb +19 -4
  46. data/lib/puppet/network/handler/fileserver.rb +1 -0
  47. data/lib/puppet/network/http/handler.rb +1 -0
  48. data/lib/puppet/network/http/rack/httphandler.rb +0 -18
  49. data/lib/puppet/network/http/rack/rest.rb +4 -4
  50. data/lib/puppet/network/http/rack/xmlrpc.rb +4 -4
  51. data/lib/puppet/network/http/webrick.rb +2 -1
  52. data/lib/puppet/network/server.rb +1 -1
  53. data/lib/puppet/node/environment.rb +20 -9
  54. data/lib/puppet/parameter.rb +17 -1
  55. data/lib/puppet/parser/ast/boolean_operator.rb +2 -2
  56. data/lib/puppet/parser/ast/leaf.rb +5 -1
  57. data/lib/puppet/parser/ast/resourceparam.rb +4 -0
  58. data/lib/puppet/parser/ast/selector.rb +4 -0
  59. data/lib/puppet/parser/functions/generate.rb +2 -2
  60. data/lib/puppet/parser/functions/shellquote.rb +1 -1
  61. data/lib/puppet/property.rb +3 -11
  62. data/lib/puppet/provider/cron/crontab.rb +2 -0
  63. data/lib/puppet/provider/host/parsed.rb +9 -9
  64. data/lib/puppet/provider/package/blastwave.rb +7 -6
  65. data/lib/puppet/provider/package/portage.rb +23 -27
  66. data/lib/puppet/provider/package/rug.rb +1 -1
  67. data/lib/puppet/provider/package/sun.rb +5 -3
  68. data/lib/puppet/provider/service/daemontools.rb +1 -1
  69. data/lib/puppet/provider/service/debian.rb +1 -1
  70. data/lib/puppet/provider/service/runit.rb +1 -1
  71. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +2 -1
  72. data/lib/puppet/provider/sshkey/parsed.rb +3 -5
  73. data/lib/puppet/provider/zone/solaris.rb +1 -1
  74. data/lib/puppet/rails.rb +9 -2
  75. data/lib/puppet/rails/benchmark.rb +1 -1
  76. data/lib/puppet/rails/host.rb +2 -7
  77. data/lib/puppet/rails/resource.rb +20 -26
  78. data/lib/puppet/resource/catalog.rb +3 -3
  79. data/lib/puppet/resource/reference.rb +13 -25
  80. data/lib/puppet/ssl/certificate.rb +3 -2
  81. data/lib/puppet/ssl/host.rb +14 -33
  82. data/lib/puppet/sslcertificates.rb +1 -5
  83. data/lib/puppet/sslcertificates/ca.rb +8 -7
  84. data/lib/puppet/transaction.rb +15 -12
  85. data/lib/puppet/type.rb +12 -5
  86. data/lib/puppet/type/file.rb +26 -32
  87. data/lib/puppet/type/file/content.rb +5 -5
  88. data/lib/puppet/type/file/ensure.rb +6 -17
  89. data/lib/puppet/type/file/mode.rb +18 -1
  90. data/lib/puppet/type/file/source.rb +12 -12
  91. data/lib/puppet/type/host.rb +6 -9
  92. data/lib/puppet/type/k5login.rb +1 -1
  93. data/lib/puppet/type/maillist.rb +4 -7
  94. data/lib/puppet/type/port.rb +6 -5
  95. data/lib/puppet/type/resources.rb +12 -12
  96. data/lib/puppet/type/sshkey.rb +5 -5
  97. data/lib/puppet/type/tidy.rb +9 -2
  98. data/lib/puppet/type/yumrepo.rb +3 -1
  99. data/lib/puppet/util.rb +64 -56
  100. data/lib/puppet/util/backups.rb +2 -1
  101. data/lib/puppet/util/filetype.rb +46 -0
  102. data/lib/puppet/util/log.rb +10 -18
  103. data/lib/puppet/util/log_paths.rb +14 -0
  104. data/lib/puppet/util/methodhelper.rb +3 -4
  105. data/lib/puppet/util/monkey_patches.rb +8 -0
  106. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +5 -3
  107. data/lib/puppet/util/rdoc/parser.rb +32 -16
  108. data/lib/puppet/util/reference.rb +6 -3
  109. data/lib/puppet/util/selinux.rb +21 -14
  110. data/lib/puppet/util/settings.rb +30 -25
  111. data/lib/puppet/util/settings/file_setting.rb +7 -4
  112. data/lib/puppet/util/subclass_loader.rb +1 -1
  113. data/lib/puppet/util/suidmanager.rb +11 -1
  114. data/lib/puppet/util/tagging.rb +22 -4
  115. data/man/man8/filebucket.8 +23 -18
  116. data/man/man8/pi.8 +42 -20
  117. data/man/man8/puppet.8 +47 -32
  118. data/man/man8/puppet.conf.8 +807 -764
  119. data/man/man8/puppetca.8 +24 -14
  120. data/man/man8/puppetd.8 +33 -16
  121. data/man/man8/puppetdoc.8 +71 -18
  122. data/man/man8/puppetmasterd.8 +18 -25
  123. data/man/man8/puppetqd.8 +60 -0
  124. data/man/man8/puppetrun.8 +27 -14
  125. data/man/man8/ralsh.8 +33 -40
  126. data/spec/integration/bin/puppetmasterd.rb +3 -2
  127. data/spec/integration/defaults.rb +11 -0
  128. data/spec/integration/file_serving/metadata.rb +1 -0
  129. data/spec/integration/indirector/file_content/file_server.rb +2 -1
  130. data/spec/integration/ssl/certificate_request.rb +2 -0
  131. data/spec/integration/type/file.rb +20 -1
  132. data/spec/shared_behaviours/file_serving.rb +1 -1
  133. data/spec/spec_helper.rb +1 -1
  134. data/spec/unit/application/puppet.rb +11 -30
  135. data/spec/unit/application/puppetd.rb +1 -0
  136. data/spec/unit/application/puppetdoc.rb +13 -4
  137. data/spec/unit/application/puppetmasterd.rb +1 -0
  138. data/spec/unit/application/puppetrun.rb +12 -2
  139. data/spec/unit/application/ralsh.rb +39 -22
  140. data/spec/unit/configurer.rb +6 -0
  141. data/spec/unit/configurer/fact_handler.rb +15 -1
  142. data/spec/unit/file_serving/metadata.rb +128 -16
  143. data/spec/unit/file_serving/mount/file.rb +8 -0
  144. data/spec/unit/indirector/catalog/active_record.rb +20 -1
  145. data/spec/unit/indirector/catalog/compiler.rb +2 -1
  146. data/spec/unit/indirector/indirection.rb +29 -18
  147. data/spec/unit/indirector/node/ldap.rb +20 -6
  148. data/spec/unit/network/authstore.rb +197 -0
  149. data/spec/unit/network/format_handler.rb +28 -8
  150. data/spec/unit/network/formats.rb +31 -0
  151. data/spec/unit/network/http/handler.rb +10 -0
  152. data/spec/unit/network/http/webrick.rb +2 -2
  153. data/spec/unit/network/rest_authconfig.rb +2 -2
  154. data/spec/unit/network/rights.rb +1 -1
  155. data/spec/unit/node/environment.rb +39 -23
  156. data/spec/unit/other/selinux.rb +2 -2
  157. data/spec/unit/parameter.rb +8 -0
  158. data/spec/unit/parser/ast/leaf.rb +9 -0
  159. data/spec/unit/parser/ast/selector.rb +8 -1
  160. data/spec/unit/parser/lexer.rb +1 -1
  161. data/spec/unit/parser/resource.rb +11 -0
  162. data/spec/unit/parser/resource/reference.rb +13 -1
  163. data/spec/unit/property.rb +6 -0
  164. data/spec/unit/provider/mount/parsed.rb +3 -1
  165. data/spec/unit/provider/service/debian.rb +1 -1
  166. data/spec/unit/provider/ssh_authorized_key/parsed.rb +9 -1
  167. data/spec/unit/provider/sshkey/parsed.rb +19 -0
  168. data/spec/unit/rails.rb +22 -9
  169. data/spec/unit/rails/resource.rb +20 -0
  170. data/spec/unit/ssl/host.rb +19 -57
  171. data/spec/unit/transaction.rb +39 -4
  172. data/spec/unit/type.rb +9 -0
  173. data/spec/unit/type/file/content.rb +29 -0
  174. data/spec/unit/type/maillist.rb +42 -0
  175. data/spec/unit/type/resources.rb +66 -1
  176. data/spec/unit/type/tidy.rb +14 -1
  177. data/spec/unit/util/autoload.rb +2 -0
  178. data/spec/unit/util/ldap/connection.rb +1 -1
  179. data/spec/unit/util/log.rb +14 -0
  180. data/spec/unit/util/monkey_patches.rb +103 -0
  181. data/spec/unit/util/queue.rb +10 -2
  182. data/spec/unit/util/selinux.rb +61 -2
  183. data/spec/unit/util/settings.rb +19 -0
  184. data/spec/unit/util/settings/file_setting.rb +25 -0
  185. data/spec/unit/util/tagging.rb +10 -0
  186. data/tasks/rake/changelog.rake +15 -0
  187. data/tasks/rake/ci.rake +22 -0
  188. data/tasks/rake/dailybuild.rake +9 -0
  189. data/tasks/rake/gem.rake +46 -0
  190. data/tasks/rake/git_workflow.rake +121 -0
  191. data/tasks/rake/metrics.rake +6 -0
  192. data/tasks/rake/sign.rake +14 -0
  193. data/tasks/rake/testbranch.rake +16 -0
  194. data/tasks/rake/tracdocs.rake +8 -0
  195. data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +1 -0
  196. metadata +1042 -1288
  197. data/ext/bin/sleeper +0 -67
  198. data/ext/module_puppet +0 -209
@@ -13,6 +13,7 @@ PATH=/usr/bin:/sbin:/bin:/usr/sbin
13
13
  export PATH
14
14
 
15
15
  lockfile=/var/lock/subsys/puppetmaster
16
+ pidfile=/var/run/puppet/puppetmasterd.pid
16
17
 
17
18
  # Source function library.
18
19
  . /etc/rc.d/init.d/functions
@@ -28,4 +28,4 @@
28
28
  #PUPPETMASTER_PORTS=( 18140 18141 18142 18143 )
29
29
 
30
30
  # You may specify other parameters to the puppetmaster here
31
- #PUPPETMASTER_EXTRA_OPTS=--noca
31
+ #PUPPETMASTER_EXTRA_OPTS=--no-ca
@@ -1,28 +1,24 @@
1
- # These OIDs are all fake. No guarantees there won't be conflicts.
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 'parentnode'
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 'puppetvar'
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 ))
@@ -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
@@ -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 (when it is released) is expected to work properly again.
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,2 @@
1
+ db\d{2}
2
+ mysql
@@ -0,0 +1,2 @@
1
+ ^(web|www)
2
+ leterel
@@ -0,0 +1,3 @@
1
+ ^qa-
2
+ ^qa2-
3
+ ^qa3-
@@ -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
@@ -24,7 +24,7 @@ require 'puppet/util/suidmanager'
24
24
  # it's also a place to find top-level commands like 'debug'
25
25
 
26
26
  module Puppet
27
- PUPPETVERSION = '0.25.1'
27
+ PUPPETVERSION = '0.25.2'
28
28
 
29
29
  def Puppet.version
30
30
  return PUPPETVERSION
@@ -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 = PSON.parse(text)
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
- files += Puppet[:modulepath].split(':').collect { |p| File.expand_path(p) }
70
- files += Puppet[:manifestdir].split(':').collect { |p| File.expand_path(p) }
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
- if ARGV.length > 0
42
- type = ARGV.shift
43
- else
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
- if ARGV.length > 0
50
- name = ARGV.shift
51
- end
52
-
53
- if ARGV.length > 0
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?