puppet 0.16.0 → 0.18.4

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 (185) hide show
  1. data/CHANGELOG +98 -0
  2. data/Rakefile +5 -1
  3. data/bin/puppet +1 -1
  4. data/bin/puppetca +25 -11
  5. data/bin/puppetd +189 -66
  6. data/bin/puppetdoc +79 -62
  7. data/bin/puppetmasterd +93 -49
  8. data/bin/puppetrun +385 -0
  9. data/conf/redhat/client.init +5 -2
  10. data/conf/redhat/fileserver.conf +1 -1
  11. data/conf/redhat/lsb-config.patch +51 -0
  12. data/conf/redhat/puppet.spec +45 -18
  13. data/conf/redhat/puppetd.conf +32 -4
  14. data/conf/redhat/server.init +5 -2
  15. data/conf/solaris/pkginfo +7 -0
  16. data/conf/solaris/smf/puppetd.xml +77 -0
  17. data/conf/solaris/smf/puppetmasterd.xml +77 -0
  18. data/conf/solaris/smf/svc-puppetd +66 -0
  19. data/conf/solaris/smf/svc-puppetmasterd +62 -0
  20. data/examples/code/failers/noobjectrvalue +1 -0
  21. data/examples/code/snippets/deepclassheirarchy.pp +23 -0
  22. data/examples/code/snippets/defineoverrides.pp +17 -0
  23. data/examples/code/snippets/emptyexec.pp +3 -0
  24. data/examples/code/snippets/selectorvalues.pp +6 -1
  25. data/examples/code/snippets/tagged.pp +35 -0
  26. data/ext/ldap/puppet.schema +2 -2
  27. data/install.rb +4 -2
  28. data/lib/puppet.rb +206 -15
  29. data/lib/puppet/client.rb +30 -20
  30. data/lib/puppet/client/ca.rb +2 -2
  31. data/lib/puppet/client/dipper.rb +5 -9
  32. data/lib/puppet/client/master.rb +224 -44
  33. data/lib/puppet/client/pelement.rb +54 -9
  34. data/lib/puppet/client/proxy.rb +3 -2
  35. data/lib/puppet/client/reporter.rb +34 -0
  36. data/lib/puppet/client/runner.rb +17 -0
  37. data/lib/puppet/config.rb +136 -55
  38. data/lib/puppet/daemon.rb +59 -37
  39. data/lib/puppet/element.rb +2 -1
  40. data/lib/puppet/event.rb +14 -3
  41. data/lib/puppet/filetype.rb +28 -19
  42. data/lib/puppet/log.rb +297 -132
  43. data/lib/puppet/metric.rb +31 -131
  44. data/lib/puppet/networkclient.rb +73 -46
  45. data/lib/puppet/parameter.rb +49 -1
  46. data/lib/puppet/parsedfile.rb +32 -12
  47. data/lib/puppet/parser/ast.rb +6 -1
  48. data/lib/puppet/parser/ast/astarray.rb +32 -6
  49. data/lib/puppet/parser/ast/collection.rb +91 -0
  50. data/lib/puppet/parser/ast/compdef.rb +2 -2
  51. data/lib/puppet/parser/ast/component.rb +24 -11
  52. data/lib/puppet/parser/ast/function.rb +50 -0
  53. data/lib/puppet/parser/ast/hostclass.rb +70 -22
  54. data/lib/puppet/parser/ast/node.rb +17 -8
  55. data/lib/puppet/parser/ast/nodedef.rb +1 -1
  56. data/lib/puppet/parser/ast/objectdef.rb +28 -10
  57. data/lib/puppet/parser/ast/selector.rb +4 -1
  58. data/lib/puppet/parser/functions.rb +145 -0
  59. data/lib/puppet/parser/interpreter.rb +243 -86
  60. data/lib/puppet/parser/lexer.rb +5 -4
  61. data/lib/puppet/parser/parser.rb +586 -505
  62. data/lib/puppet/parser/scope.rb +337 -187
  63. data/lib/puppet/rails.rb +115 -0
  64. data/lib/puppet/rails/database.rb +40 -0
  65. data/lib/puppet/rails/host.rb +83 -0
  66. data/lib/puppet/rails/rails_object.rb +42 -0
  67. data/lib/puppet/rails/rails_parameter.rb +5 -0
  68. data/lib/puppet/reports/rrdgraph.rb +20 -0
  69. data/lib/puppet/reports/tagmail.rb +94 -0
  70. data/lib/puppet/server.rb +20 -4
  71. data/lib/puppet/server/authconfig.rb +14 -3
  72. data/lib/puppet/server/authstore.rb +2 -2
  73. data/lib/puppet/server/ca.rb +23 -11
  74. data/lib/puppet/server/filebucket.rb +10 -10
  75. data/lib/puppet/server/fileserver.rb +4 -8
  76. data/lib/puppet/server/master.rb +19 -22
  77. data/lib/puppet/server/pelement.rb +28 -16
  78. data/lib/puppet/server/report.rb +184 -0
  79. data/lib/puppet/server/runner.rb +62 -0
  80. data/lib/puppet/server/servlet.rb +23 -9
  81. data/lib/puppet/sslcertificates/ca.rb +25 -1
  82. data/lib/puppet/statechange.rb +34 -53
  83. data/lib/puppet/storage.rb +1 -2
  84. data/lib/puppet/transaction.rb +305 -133
  85. data/lib/puppet/transaction/report.rb +42 -0
  86. data/lib/puppet/transportable.rb +57 -33
  87. data/lib/puppet/type.rb +260 -127
  88. data/lib/puppet/type/component.rb +9 -21
  89. data/lib/puppet/type/cron.rb +367 -116
  90. data/lib/puppet/type/exec.rb +15 -16
  91. data/lib/puppet/type/group.rb +9 -1
  92. data/lib/puppet/type/nameservice.rb +2 -5
  93. data/lib/puppet/type/nameservice/netinfo.rb +3 -0
  94. data/lib/puppet/type/nameservice/objectadd.rb +23 -10
  95. data/lib/puppet/type/nameservice/pw.rb +16 -3
  96. data/lib/puppet/type/package.rb +25 -75
  97. data/lib/puppet/type/package/apple.rb +15 -1
  98. data/lib/puppet/type/package/apt.rb +37 -2
  99. data/lib/puppet/type/package/blastwave.rb +136 -0
  100. data/lib/puppet/type/package/dpkg.rb +4 -4
  101. data/lib/puppet/type/package/gem.rb +119 -0
  102. data/lib/puppet/type/package/openbsd.rb +7 -6
  103. data/lib/puppet/type/package/ports.rb +7 -2
  104. data/lib/puppet/type/package/rpm.rb +1 -1
  105. data/lib/puppet/type/package/sun.rb +23 -9
  106. data/lib/puppet/type/package/sunfreeware.rb +7 -0
  107. data/lib/puppet/type/package/yum.rb +16 -9
  108. data/lib/puppet/type/parsedtype.rb +7 -5
  109. data/lib/puppet/type/parsedtype/mount.rb +55 -34
  110. data/lib/puppet/type/parsedtype/port.rb +7 -1
  111. data/lib/puppet/type/parsedtype/sshkey.rb +6 -16
  112. data/lib/puppet/type/pfile.rb +115 -23
  113. data/lib/puppet/type/pfile/checksum.rb +18 -5
  114. data/lib/puppet/type/pfile/content.rb +2 -2
  115. data/lib/puppet/type/pfile/ensure.rb +3 -3
  116. data/lib/puppet/type/pfile/group.rb +2 -2
  117. data/lib/puppet/type/pfile/source.rb +28 -17
  118. data/lib/puppet/type/pfile/target.rb +25 -17
  119. data/lib/puppet/type/pfilebucket.rb +25 -6
  120. data/lib/puppet/type/schedule.rb +6 -6
  121. data/lib/puppet/type/service.rb +24 -14
  122. data/lib/puppet/type/service/debian.rb +1 -1
  123. data/lib/puppet/type/service/redhat.rb +13 -10
  124. data/lib/puppet/type/service/smf.rb +3 -3
  125. data/lib/puppet/type/state.rb +1 -2
  126. data/lib/puppet/type/symlink.rb +3 -4
  127. data/lib/puppet/type/user.rb +22 -10
  128. data/lib/puppet/type/yumrepo.rb +6 -1
  129. data/lib/puppet/type/zone.rb +595 -0
  130. data/lib/puppet/util.rb +58 -12
  131. data/test/client/client.rb +2 -2
  132. data/test/client/master.rb +92 -3
  133. data/test/client/pelement.rb +99 -0
  134. data/test/executables/puppetbin.rb +3 -4
  135. data/test/executables/puppetca.rb +3 -3
  136. data/test/executables/puppetd.rb +3 -3
  137. data/test/executables/puppetmasterd.rb +1 -5
  138. data/test/executables/puppetmodule.rb +2 -2
  139. data/test/language/ast.rb +200 -11
  140. data/test/language/functions.rb +245 -0
  141. data/test/language/interpreter.rb +155 -6
  142. data/test/language/lexer.rb +35 -2
  143. data/test/language/node.rb +48 -1
  144. data/test/language/parser.rb +250 -1
  145. data/test/language/rails.rb +105 -0
  146. data/test/language/scope.rb +304 -10
  147. data/test/language/snippets.rb +54 -5
  148. data/test/language/transportable.rb +60 -28
  149. data/test/other/config.rb +214 -1
  150. data/test/other/events.rb +67 -9
  151. data/test/other/log.rb +31 -5
  152. data/test/other/metrics.rb +23 -21
  153. data/test/other/parsedfile.rb +29 -2
  154. data/test/other/puppet.rb +79 -0
  155. data/test/other/report.rb +106 -0
  156. data/test/other/storage.rb +2 -2
  157. data/test/other/transactions.rb +128 -2
  158. data/test/puppet/utiltest.rb +10 -5
  159. data/test/puppettest.rb +193 -21
  160. data/test/server/authstore.rb +13 -4
  161. data/test/server/bucket.rb +33 -8
  162. data/test/server/ca.rb +44 -6
  163. data/test/server/master.rb +6 -7
  164. data/test/server/pelement.rb +15 -5
  165. data/test/server/report.rb +93 -0
  166. data/test/server/runner.rb +107 -0
  167. data/test/server/server.rb +28 -1
  168. data/test/types/cron.rb +339 -31
  169. data/test/types/file.rb +256 -24
  170. data/test/types/filebucket.rb +6 -2
  171. data/test/types/filesources.rb +41 -92
  172. data/test/types/group.rb +31 -1
  173. data/test/types/host.rb +2 -1
  174. data/test/types/mount.rb +18 -1
  175. data/test/types/package.rb +200 -18
  176. data/test/types/service.rb +5 -1
  177. data/test/types/sshkey.rb +2 -1
  178. data/test/types/symlink.rb +3 -2
  179. data/test/types/type.rb +180 -1
  180. data/test/types/user.rb +65 -27
  181. data/test/types/yumrepo.rb +15 -0
  182. data/test/types/zone.rb +437 -0
  183. metadata +43 -4
  184. data/bin/cf2puppet +0 -186
  185. data/conf/redhat/puppetmasterd.conf +0 -5
data/bin/puppetdoc CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
 
3
3
  #
4
4
  # = Synopsis
@@ -99,7 +99,12 @@ def scrub(text)
99
99
  # indent from every line.
100
100
  if text =~ /^(\s+)/
101
101
  indent = $1
102
- return text.gsub(/^#{indent}/,'')
102
+ begin
103
+ return text.gsub(/^#{indent}/,'')
104
+ rescue => detail
105
+ puts detail.backtrace
106
+ puts detail
107
+ end
103
108
  else
104
109
  return text
105
110
  end
@@ -111,12 +116,24 @@ def indent(text, tab)
111
116
  return text.gsub(/(^|\A)/, tab).gsub(/^ +\.\./, "..")
112
117
  end
113
118
 
119
+ def paramwrap(name, text, namevar = false)
120
+ if namevar
121
+ name = name.to_s + " (*namevar*)"
122
+ end
123
+
124
+ puts "#### %s" % name
125
+ puts text
126
+
127
+ puts ""
128
+ end
129
+
114
130
  # Print the docs for arguments
115
131
  def self.arguments
116
- puts %{
117
- ===========================
118
- Puppet Executable Reference
119
- ===========================
132
+ puts %{---
133
+ inMenu: true
134
+ title: Configuration Reference
135
+ ---
136
+ # Puppet Configuration Reference
120
137
 
121
138
  Every Puppet executable (with the exception of ``puppetdoc``) accepts all of
122
139
  these arguments, but not all of the arguments make sense for every executable.
@@ -129,6 +146,8 @@ This will not always be the case. I have tried to be as thorough as possible
129
146
  in the descriptions of the arguments, so it should be obvious whether an
130
147
  argument is approprite or not.
131
148
 
149
+ Any default values are in ``block type`` at the end of the description.
150
+
132
151
  }
133
152
 
134
153
  docs = {}
@@ -139,9 +158,20 @@ argument is approprite or not.
139
158
  docs.sort { |a, b|
140
159
  a[0].to_s <=> b[0].to_s
141
160
  }.each do |name, object|
142
- puts "* **#{name.to_s}** (*#{object.section.to_s}*)"
161
+ # Make each name an anchor
162
+ puts %{#### <a name="#{name.to_s}">#{name.to_s}</a> (<em>#{object.section.to_s}</em>)}
163
+
143
164
  puts ""
144
- puts " " + object.desc.gsub(/\n/, " ")
165
+ default = ""
166
+ if val = object.value and val != ""
167
+ default = " ``%s``" % val
168
+ end
169
+ begin
170
+ puts object.desc.gsub(/\n/, " ") + default
171
+ rescue => detail
172
+ puts detail.backtrace
173
+ puts detail
174
+ end
145
175
  puts ""
146
176
  end
147
177
 
@@ -149,21 +179,31 @@ end
149
179
 
150
180
  # Print the docs for types
151
181
  def self.types
152
- puts %{
153
- ==============
154
- Type Reference
155
- ==============
182
+ puts %{---
183
+ inMenu: true
184
+ title: Type Reference
185
+ ---
186
+ # Type Reference
187
+
156
188
 
157
189
  }
158
190
 
159
191
  types = {}
160
192
  Puppet::Type.eachtype { |type|
193
+ next if type.name == :puppet
194
+ next if type.name == :component
161
195
  types[type.name] = type
162
196
  }
197
+
198
+ # Build a simple TOC
199
+ puts "## Table of Contents"
200
+ puts "1. <a href='#meta-parameters'>Meta-Parameters</a>"
201
+ types.sort { |a, b| a[0].to_s <=> b[0].to_s }.each do |name, type|
202
+ puts "1. <a href='#%s'>%s</a>" % [type.name, type.name.to_s.capitalize]
203
+ end
204
+
163
205
  puts %{
164
- ---------------
165
- Meta-Parameters
166
- ---------------
206
+ <h2><a name="meta-parameters">Meta-Parameters</a></h2>
167
207
 
168
208
  Metaparameters are parameters that work with any element; they are part of the
169
209
  Puppet framework itself rather than being part of the implementation of any
@@ -180,32 +220,37 @@ in your manifest, including defined components.
180
220
  params.sort { |a,b|
181
221
  a.to_s <=> b.to_s
182
222
  }.each { |param|
183
- puts "- **" + param.to_s + "**"
223
+ paramwrap(param.to_s, scrub(Puppet::Type.metaparamdoc(param)))
224
+ #puts "<dt>" + param.to_s + "</dt>"
184
225
  #puts tab(1) + Puppet::Type.metaparamdoc(param).scrub.indent($tab)gsub(/\n\s*/,' ')
185
- puts indent(scrub(Puppet::Type.metaparamdoc(param)), $tab)
226
+ #puts "<dd>"
227
+ #puts indent(scrub(Puppet::Type.metaparamdoc(param)), $tab)
228
+ #puts scrub(Puppet::Type.metaparamdoc(param))
229
+ #puts "</dd>"
230
+
231
+ #puts ""
186
232
  }
187
233
  rescue => detail
234
+ puts detail.backtrace
188
235
  puts "incorrect metaparams: %s" % detail
189
236
  exit(1)
190
237
  end
191
238
 
192
239
  puts %{
193
- -----
194
- Types
195
- -----
240
+ ## Types
196
241
 
197
242
  - *namevar* is the parameter used to uniquely identify a type instance.
198
243
  This is the parameter that gets assigned when a string is provided before
199
244
  the colon in a type declaration. In general, only developers will need to
200
245
  worry about which parameter is the ``namevar``.
201
246
 
202
- In the following code::
247
+ In the following code:
203
248
 
204
- file { "/etc/passwd":
205
- owner => root,
206
- group => root,
207
- mode => 644
208
- }
249
+ file { "/etc/passwd":
250
+ owner => root,
251
+ group => root,
252
+ mode => 644
253
+ }
209
254
 
210
255
  "/etc/passwd" is considered the name of the file object (used for things like
211
256
  dependency handling), and because ``path`` is the namevar for ``file``, that
@@ -221,8 +266,6 @@ Types
221
266
  types.sort { |a,b|
222
267
  a.to_s <=> b.to_s
223
268
  }.each { |name,type|
224
- next if name == :puppet
225
- next if name == :component
226
269
 
227
270
  puts "
228
271
 
@@ -231,15 +274,10 @@ Types
231
274
  "
232
275
 
233
276
  puts "
234
- %s
235
- %s" % [name, "=" * (name.to_s.length + 4)]
236
- #String.new('n%s\n') % name.to_s
237
- #puts "**" + type.doc.gsub(/\n\s*/, ' ') + "**\n\n"
277
+ <h2><a name='%s'>%s</a></h2>" % [name, name]
238
278
  puts scrub(type.doc) + "\n\n"
239
279
 
240
- #puts tab(1) + "* namevar: %s" % type.namevar
241
280
  docs = {}
242
- #puts "%s States\n'''''''''''''''''''''''''''''''" % name.to_s.capitalize
243
281
  type.validstates.sort { |a,b|
244
282
  a.to_s <=> b.to_s
245
283
  }.reject { |sname|
@@ -260,46 +298,25 @@ Types
260
298
  end
261
299
  doc = doc.dup
262
300
  str = doc
263
- #puts "A---" + str + "---"
264
301
  str = scrub(str)
265
- #puts "B---" + str + "---"
266
- #str = indent(str, $tab)
267
- #puts "C---" + str + "---"
268
- #str = indent($tab, scrub(doc))
269
-
270
- # If the state has values, then add them:
271
-
272
- #if values = state.values
273
- # unless values.empty?
274
- # extra = "Acceptable values are %s." % values.join(", ")
275
- # str += "\n\n#{extra}"
276
- # end
277
- #end
278
302
 
279
- str = indent(str, $tab)
280
- #puts "---" + str + "---"
303
+ #str = indent(str, $tab)
281
304
  docs[sname] = str
282
- #puts "- **%s**" % sname
283
- #puts tab(1) + state.doc.gsub(/\n\s*/,' ')
284
305
  }
285
306
 
286
- puts "\n%s Parameters\n''''''''''''''''''''''''''''''" % name.to_s.capitalize
307
+ puts "\n### %s Parameters\n" % name.to_s.capitalize
287
308
  type.parameters.sort { |a,b|
288
309
  a.to_s <=> b.to_s
289
310
  }.each { |name,param|
290
- docs[name] = indent(scrub(type.paramdoc(name)), $tab)
311
+ #docs[name] = indent(scrub(type.paramdoc(name)), $tab)
312
+ docs[name] = scrub(type.paramdoc(name))
291
313
  }
292
314
 
293
315
  docs.sort { |a, b|
294
316
  a[0].to_s <=> b[0].to_s
295
317
  }.each { |name, doc|
296
- print "- **%s**" % name
297
- if type.namevar == name and name != :name
298
- puts " (*namevar*)"
299
- else
300
- puts ""
301
- end
302
- puts doc
318
+ namevar = type.namevar == name and name != :name
319
+ paramwrap(name, doc, namevar)
303
320
  }
304
321
  puts "\n"
305
322
  }
@@ -314,4 +331,4 @@ puts "
314
331
  "
315
332
  puts "\n*This page autogenerated on %s*" % Time.now
316
333
 
317
- # $Id: puppetdoc 1110 2006-04-11 23:44:36Z luke $
334
+ # $Id: puppetdoc 1410 2006-07-21 15:10:11Z luke $
data/bin/puppetmasterd CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
 
3
3
  #
4
4
  # = Synopsis
@@ -7,8 +7,9 @@
7
7
  #
8
8
  # = Usage
9
9
  #
10
- # puppetmasterd [-h|--help] [-d|--debug] [-v|--verbose] [-V|--version]
11
- # [--noca] [--nobucket]
10
+ # puppetmasterd [-D|--daemonize] [-d|--debug] [-h|--help]
11
+ # [-l|--logdest <file>|console|syslog] [--noca] [--nobucket] [--nonodes]
12
+ # [-v|--verbose] [-V|--version]
12
13
  #
13
14
  # = Description
14
15
  #
@@ -20,7 +21,13 @@
20
21
  # is also a valid long argument. For example, 'ssldir' is a valid configuration
21
22
  # parameter, so you can specify '--ssldir <directory>' as an argument.
22
23
  #
23
- # See the configuration file for the full list of acceptable parameters.
24
+ # See the configuration file documentation at
25
+ # http://reductivelabs.com/projects/puppet/documentation/puppet-executable-reference
26
+ # for the full list of acceptable parameters.
27
+ #
28
+ # daemonize::
29
+ # Send the process into the background. This is the default unless
30
+ # +verbose+ or +debug+ is enabled.
24
31
  #
25
32
  # debug::
26
33
  # Enable full debugging. Causes the daemon not to go into the background.
@@ -42,6 +49,10 @@
42
49
  # nonodes::
43
50
  # Do not use individual node designations; each node will receive the result
44
51
  # of evaluating the entire configuration.
52
+ #
53
+ # noreports::
54
+ # Do not start the reports server.
55
+ #
45
56
  # verbose::
46
57
  # Enable verbosity. Causes the daemon not to go into the background.
47
58
  #
@@ -61,16 +72,24 @@
61
72
  # Copyright (c) 2005 Reductive Labs, LLC
62
73
  # Licensed under the GNU Public License
63
74
 
75
+ # Do an initial trap, so that cancels don't get a stack trace.
76
+ trap(:INT) do
77
+ $stderr.puts "Cancelling startup"
78
+ exit(0)
79
+ end
80
+
64
81
  require 'getoptlong'
65
82
  require 'puppet'
66
83
  require 'puppet/server'
67
84
 
68
85
  options = [
86
+ [ "--daemonize", "-D", GetoptLong::NO_ARGUMENT ],
69
87
  [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
70
88
  [ "--help", "-h", GetoptLong::NO_ARGUMENT ],
71
89
  [ "--logdest", "-l", GetoptLong::REQUIRED_ARGUMENT ],
72
90
  [ "--noca", GetoptLong::NO_ARGUMENT ],
73
91
  [ "--nobucket", GetoptLong::NO_ARGUMENT ],
92
+ [ "--noreports", GetoptLong::NO_ARGUMENT ],
74
93
  [ "--nonodes", GetoptLong::NO_ARGUMENT ],
75
94
  [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
76
95
  [ "--version", "-V", GetoptLong::NO_ARGUMENT ]
@@ -90,29 +109,30 @@ rescue LoadError
90
109
  $haveusage = false
91
110
  end
92
111
 
93
- haveca = true
94
112
  master = {}
95
113
  ca = {}
114
+ report = {}
96
115
  fs = {}
97
116
  bucket = {}
98
117
  args = {}
99
- #user = Puppet[:user]
100
- #group = Puppet[:group]
101
- user = nil
102
- group = nil
103
-
104
- havebucket = true
105
118
 
106
- parseonly = false
107
-
108
- setdest = false
119
+ options = {
120
+ :haveca => true,
121
+ :havereport => true,
122
+ :havebucket => true,
123
+ :havemaster => true,
124
+ :setdest => false,
125
+ :verbose => false,
126
+ :debug => false
127
+ }
109
128
 
110
129
  begin
111
130
  result.each { |opt,arg|
112
131
  case opt
132
+ when "--daemonize"
133
+ options[:daemonize] = true
113
134
  when "--debug"
114
- Puppet::Log.level = :debug
115
- Puppet::Log.newdestination(:console)
135
+ options[:debug] = true
116
136
  when "--help"
117
137
  if $haveusage
118
138
  RDoc::usage && exit
@@ -120,25 +140,31 @@ begin
120
140
  puts "No help available unless you have RDoc::usage installed"
121
141
  exit
122
142
  end
143
+ when "--noreports"
144
+ options[:havereport] = false
123
145
  when "--noca"
124
- haveca = false
146
+ options[:haveca] = false
147
+ when "--nomaster"
148
+ options[:havemaster] = false
125
149
  when "--nobucket"
126
- havebucket = false
150
+ options[:havebucket] = false
127
151
  when "--nonodes"
128
152
  master[:UseNodes] = false
129
153
  when "--logdest"
130
154
  begin
131
155
  Puppet::Log.newdestination(arg)
132
- setdest = true
156
+ options[:setdest] = true
133
157
  rescue => detail
158
+ if Puppet[:debug]
159
+ puts detail.backtrace
160
+ end
134
161
  $stderr.puts detail.to_s
135
162
  end
136
163
  when "--version"
137
164
  puts "%s" % Puppet.version
138
165
  exit
139
166
  when "--verbose"
140
- Puppet::Log.level = :info
141
- Puppet::Log.newdestination :console
167
+ options[:verbose] = true
142
168
  else
143
169
  Puppet.config.handlearg(opt, arg)
144
170
  end
@@ -152,7 +178,24 @@ rescue GetoptLong::InvalidOption => detail
152
178
  #end
153
179
  exit(1)
154
180
  end
155
- ca[:autosign] = Puppet[:autosign]
181
+
182
+ # Handle the logging settings.
183
+ if options[:debug] or options[:verbose]
184
+ if options[:debug]
185
+ Puppet::Log.level = :debug
186
+ else
187
+ Puppet::Log.level = :info
188
+ end
189
+
190
+ unless options[:daemonize]
191
+ Puppet::Log.newdestination(:console)
192
+ options[:setdest] = true
193
+ end
194
+ end
195
+
196
+ unless options[:setdest]
197
+ Puppet::Log.newdestination(:syslog)
198
+ end
156
199
 
157
200
  # Now parse the config
158
201
  if Puppet[:config] and File.exists? Puppet[:config]
@@ -164,27 +207,33 @@ Puppet.genmanifest
164
207
 
165
208
  require 'etc'
166
209
 
167
- if Puppet::Log.level == :debug or Puppet::Log.level == :info or parseonly
168
- args[:Daemonize] = false
169
- else
170
- args[:Daemonize] = true
210
+ # Default to daemonizing, but if verbose or debug is specified,
211
+ # default to staying in the foreground.
212
+ unless options.include?(:daemonize)
213
+ if Puppet::Log.level == :debug or Puppet::Log.level == :info
214
+ options[:daemonize] = false
215
+ else
216
+ options[:daemonize] = true
217
+ end
171
218
  end
172
219
 
173
220
  handlers = {
174
- :Master => master,
175
221
  :Status => {},
176
- :Logger => {}
177
222
  }
178
223
 
179
- unless setdest
180
- Puppet::Log.newdestination(:syslog)
224
+ if options[:havemaster]
225
+ handlers[:Master] = master
226
+ end
227
+
228
+ if options[:havereport]
229
+ handlers[:Report] = report
181
230
  end
182
231
 
183
- if haveca
232
+ if options[:haveca]
184
233
  handlers[:CA] = ca
185
234
  end
186
235
 
187
- if havebucket
236
+ if options[:havebucket]
188
237
  handlers[:FileBucket] = bucket
189
238
  end
190
239
 
@@ -206,6 +255,9 @@ begin
206
255
  #server = Puppet::Server.new(:CA => ca)
207
256
  server = Puppet::Server.new(args)
208
257
  rescue => detail
258
+ if Puppet[:debug]
259
+ puts detail.backtrace
260
+ end
209
261
  $stderr.puts detail
210
262
  exit(1)
211
263
  end
@@ -214,6 +266,9 @@ if Process.uid == 0
214
266
  begin
215
267
  Puppet::Util.chuser
216
268
  rescue => detail
269
+ if Puppet[:debug]
270
+ puts detail.backtrace
271
+ end
217
272
  $stderr.puts "Could not change user to %s: %s" % [Puppet[:user], detail]
218
273
  exit(39)
219
274
  end
@@ -224,25 +279,14 @@ if Puppet[:parseonly]
224
279
  exit(0)
225
280
  end
226
281
 
227
- if args[:Daemonize]
228
- server.daemonize
229
- end
230
-
282
+ Puppet.newservice(server)
283
+ Puppet.settraps
231
284
 
232
- [:INT, :TERM].each do |signal|
233
- trap(signal) do
234
- Puppet.notice "Caught #{signal}; shutting down"
235
- server.shutdown
236
- end
285
+ if options[:daemonize]
286
+ server.daemonize
237
287
  end
238
288
 
239
289
  Puppet.notice "Starting Puppet server version %s" % [Puppet.version]
290
+ Puppet.start
240
291
 
241
- begin
242
- server.start
243
- rescue => detail
244
- Puppet.err "Could not start puppetmaster: %s" % detail
245
- exit(1)
246
- end
247
-
248
- # $Id: puppetmasterd 1012 2006-03-12 02:56:23Z luke $
292
+ # $Id: puppetmasterd 1351 2006-07-01 17:27:54Z luke $