puppet 0.24.1 → 0.24.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 (266) hide show
  1. data/CHANGELOG +94 -0
  2. data/Rakefile +0 -4
  3. data/bin/puppet +18 -10
  4. data/bin/puppetd +1 -1
  5. data/bin/puppetdoc +14 -4
  6. data/bin/puppetmasterd +1 -1
  7. data/bin/puppetrun +3 -8
  8. data/bin/ralsh +12 -11
  9. data/conf/freebsd/puppetd +1 -1
  10. data/conf/freebsd/puppetmasterd +1 -1
  11. data/conf/gentoo/puppet/puppet.conf +29 -0
  12. data/conf/namespaceauth.conf +20 -0
  13. data/conf/redhat/puppet.spec +4 -1
  14. data/conf/solaris/smf/puppetd.xml +1 -1
  15. data/conf/solaris/smf/puppetmasterd.xml +1 -1
  16. data/conf/suse/puppet.spec +10 -8
  17. data/examples/root/etc/puppet/{puppetmasterd.conf → puppet.conf} +6 -3
  18. data/ext/logcheck/puppet +7 -0
  19. data/ext/puppet-test +28 -5
  20. data/lib/puppet.rb +2 -1
  21. data/lib/puppet/defaults.rb +12 -5
  22. data/lib/puppet/dsl.rb +43 -45
  23. data/lib/puppet/external/{gratr/rdot.rb → dot.rb} +0 -0
  24. data/lib/puppet/external/nagios.rb +50 -0
  25. data/lib/puppet/external/nagios/base.rb +421 -0
  26. data/lib/puppet/external/nagios/parser.rb +816 -0
  27. data/lib/puppet/file_serving/file_base.rb +16 -3
  28. data/lib/puppet/file_serving/metadata.rb +29 -11
  29. data/lib/puppet/indirector/terminus.rb +1 -0
  30. data/lib/puppet/metatype/closure.rb +4 -0
  31. data/lib/puppet/metatype/evaluation.rb +2 -17
  32. data/lib/puppet/metatype/metaparams.rb +1 -1
  33. data/lib/puppet/network.rb +3 -0
  34. data/lib/puppet/network/client.rb +4 -5
  35. data/lib/puppet/network/client/master.rb +10 -7
  36. data/lib/puppet/network/handler/fileserver.rb +22 -45
  37. data/lib/puppet/network/http_pool.rb +3 -0
  38. data/lib/puppet/network/http_server/mongrel.rb +7 -1
  39. data/lib/puppet/network/http_server/webrick.rb +4 -3
  40. data/lib/puppet/network/xmlrpc/client.rb +12 -1
  41. data/lib/puppet/node/catalog.rb +51 -40
  42. data/lib/puppet/parser/ast.rb +27 -49
  43. data/lib/puppet/parser/ast/astarray.rb +5 -24
  44. data/lib/puppet/parser/ast/caseopt.rb +4 -4
  45. data/lib/puppet/parser/ast/casestatement.rb +4 -5
  46. data/lib/puppet/parser/ast/collection.rb +3 -5
  47. data/lib/puppet/parser/ast/collexpr.rb +3 -5
  48. data/lib/puppet/parser/ast/definition.rb +148 -159
  49. data/lib/puppet/parser/ast/else.rb +2 -3
  50. data/lib/puppet/parser/ast/function.rb +3 -10
  51. data/lib/puppet/parser/ast/hostclass.rb +66 -59
  52. data/lib/puppet/parser/ast/ifstatement.rb +4 -5
  53. data/lib/puppet/parser/ast/leaf.rb +6 -6
  54. data/lib/puppet/parser/ast/node.rb +26 -58
  55. data/lib/puppet/parser/ast/resource.rb +5 -7
  56. data/lib/puppet/parser/ast/resource_defaults.rb +2 -4
  57. data/lib/puppet/parser/ast/resource_override.rb +4 -6
  58. data/lib/puppet/parser/ast/resource_reference.rb +2 -4
  59. data/lib/puppet/parser/ast/resourceparam.rb +2 -4
  60. data/lib/puppet/parser/ast/selector.rb +5 -6
  61. data/lib/puppet/parser/ast/tag.rb +2 -4
  62. data/lib/puppet/parser/ast/vardef.rb +3 -4
  63. data/lib/puppet/parser/collector.rb +5 -5
  64. data/lib/puppet/parser/{compile.rb → compiler.rb} +69 -107
  65. data/lib/puppet/parser/functions.rb +3 -3
  66. data/lib/puppet/parser/interpreter.rb +32 -23
  67. data/lib/puppet/parser/lexer.rb +391 -282
  68. data/lib/puppet/parser/parser.rb +5 -4
  69. data/lib/puppet/parser/parser_support.rb +3 -6
  70. data/lib/puppet/parser/resource.rb +24 -36
  71. data/lib/puppet/parser/resource/param.rb +1 -1
  72. data/lib/puppet/parser/resource/reference.rb +7 -3
  73. data/lib/puppet/parser/scope.rb +12 -7
  74. data/lib/puppet/parser/templatewrapper.rb +1 -1
  75. data/lib/puppet/pgraph.rb +9 -98
  76. data/lib/puppet/provider/interface/redhat.rb +65 -65
  77. data/lib/puppet/provider/mount/parsed.rb +1 -1
  78. data/lib/puppet/provider/naginator.rb +55 -0
  79. data/lib/puppet/provider/nameservice/directoryservice.rb +6 -7
  80. data/lib/puppet/provider/package/fink.rb +0 -2
  81. data/lib/puppet/provider/package/gem.rb +9 -5
  82. data/lib/puppet/provider/package/openbsd.rb +1 -1
  83. data/lib/puppet/provider/package/pkgdmg.rb +3 -8
  84. data/lib/puppet/provider/package/portage.rb +4 -4
  85. data/lib/puppet/provider/package/yumhelper.py +8 -6
  86. data/lib/puppet/provider/parsedfile.rb +7 -1
  87. data/lib/puppet/provider/service/debian.rb +2 -0
  88. data/lib/puppet/provider/service/gentoo.rb +4 -0
  89. data/lib/puppet/provider/service/init.rb +1 -1
  90. data/lib/puppet/provider/sshkey/parsed.rb +2 -0
  91. data/lib/puppet/provider/user/useradd.rb +1 -1
  92. data/lib/puppet/rails.rb +4 -0
  93. data/lib/puppet/rails/database/001_add_created_at_to_all_tables.rb +17 -0
  94. data/lib/puppet/rails/fact_value.rb +4 -0
  95. data/lib/puppet/rails/host.rb +1 -2
  96. data/lib/puppet/rails/param_value.rb +4 -0
  97. data/lib/puppet/rails/resource_tag.rb +4 -0
  98. data/lib/puppet/rails/source_file.rb +4 -1
  99. data/lib/puppet/relationship.rb +5 -1
  100. data/lib/puppet/reports/tagmail.rb +12 -1
  101. data/lib/puppet/resource_reference.rb +1 -1
  102. data/lib/puppet/simple_graph.rb +78 -11
  103. data/lib/puppet/sslcertificates.rb +1 -1
  104. data/lib/puppet/sslcertificates/ca.rb +3 -3
  105. data/lib/puppet/transaction.rb +7 -4
  106. data/lib/puppet/transportable.rb +1 -1
  107. data/lib/puppet/type.rb +3 -10
  108. data/lib/puppet/type/cron.rb +18 -0
  109. data/lib/puppet/type/exec.rb +18 -12
  110. data/lib/puppet/type/{pfile.rb → file.rb} +66 -84
  111. data/lib/puppet/type/file/checksum.rb +271 -0
  112. data/lib/puppet/type/{pfile → file}/content.rb +10 -15
  113. data/lib/puppet/type/{pfile → file}/ensure.rb +15 -8
  114. data/lib/puppet/type/{pfile → file}/group.rb +0 -0
  115. data/lib/puppet/type/{pfile → file}/mode.rb +0 -0
  116. data/lib/puppet/type/{pfile → file}/owner.rb +0 -0
  117. data/lib/puppet/type/{pfile → file}/source.rb +34 -48
  118. data/lib/puppet/type/{pfile → file}/target.rb +0 -0
  119. data/lib/puppet/type/{pfile → file}/type.rb +0 -0
  120. data/lib/puppet/type/{pfilebucket.rb → filebucket.rb} +0 -0
  121. data/lib/puppet/type/host.rb +13 -0
  122. data/lib/puppet/type/mailalias.rb +1 -1
  123. data/lib/puppet/type/nagios_command.rb +3 -0
  124. data/lib/puppet/type/nagios_contact.rb +3 -0
  125. data/lib/puppet/type/nagios_contactgroup.rb +3 -0
  126. data/lib/puppet/type/nagios_host.rb +3 -0
  127. data/lib/puppet/type/nagios_hostextinfo.rb +3 -0
  128. data/lib/puppet/type/nagios_hostgroup.rb +3 -0
  129. data/lib/puppet/type/nagios_hostgroupescalation.rb +3 -0
  130. data/lib/puppet/type/nagios_service.rb +3 -0
  131. data/lib/puppet/type/nagios_servicedependency.rb +3 -0
  132. data/lib/puppet/type/nagios_serviceescalation.rb +3 -0
  133. data/lib/puppet/type/nagios_serviceextinfo.rb +3 -0
  134. data/lib/puppet/type/nagios_timeperiod.rb +3 -0
  135. data/lib/puppet/type/package.rb +4 -12
  136. data/lib/puppet/type/service.rb +9 -0
  137. data/lib/puppet/type/sshkey.rb +3 -3
  138. data/lib/puppet/util/autoload.rb +5 -5
  139. data/lib/puppet/util/checksums.rb +51 -13
  140. data/lib/puppet/util/constant_inflector.rb +14 -0
  141. data/lib/puppet/util/filetype.rb +1 -1
  142. data/lib/puppet/util/graph.rb +3 -9
  143. data/lib/puppet/util/nagios_maker.rb +57 -0
  144. data/lib/puppet/util/settings.rb +19 -16
  145. data/lib/puppet/util/tagging.rb +39 -0
  146. data/test/executables/puppetbin.rb +17 -0
  147. data/test/language/ast.rb +8 -58
  148. data/test/language/ast/casestatement.rb +3 -3
  149. data/test/language/ast/resource.rb +6 -7
  150. data/test/language/ast/resource_reference.rb +12 -12
  151. data/test/language/ast/selector.rb +2 -2
  152. data/test/language/ast/variable.rb +2 -2
  153. data/test/language/functions.rb +24 -24
  154. data/test/language/parser.rb +20 -8
  155. data/test/language/resource.rb +5 -42
  156. data/test/language/scope.rb +21 -37
  157. data/test/language/snippets.rb +7 -0
  158. data/test/lib/puppettest.rb +28 -14
  159. data/test/lib/puppettest/parsertesting.rb +10 -10
  160. data/test/lib/puppettest/support/resources.rb +1 -1
  161. data/test/network/client/master.rb +10 -0
  162. data/test/network/handler/fileserver.rb +51 -49
  163. data/test/network/server/webrick.rb +1 -1
  164. data/test/other/dsl.rb +3 -4
  165. data/test/other/transactions.rb +6 -4
  166. data/test/rails/ast.rb +2 -2
  167. data/test/rails/configuration.rb +1 -1
  168. data/test/rails/railsparameter.rb +2 -0
  169. data/test/rails/railsresource.rb +1 -0
  170. data/test/ral/manager/type.rb +4 -4
  171. data/test/ral/providers/cron/crontab.rb +3 -1
  172. data/test/ral/providers/package.rb +1 -1
  173. data/test/ral/{types → type}/basic.rb +2 -2
  174. data/test/ral/{types → type}/cron.rb +0 -0
  175. data/test/ral/{types → type}/exec.rb +42 -2
  176. data/test/ral/{types → type}/file.rb +34 -79
  177. data/test/ral/{types → type}/file/target.rb +0 -0
  178. data/test/ral/{types → type}/filebucket.rb +0 -0
  179. data/test/ral/{types → type}/fileignoresource.rb +0 -0
  180. data/test/ral/{types → type}/filesources.rb +8 -27
  181. data/test/ral/{types → type}/group.rb +0 -0
  182. data/test/ral/{types → type}/host.rb +16 -0
  183. data/test/ral/{types → type}/mailalias.rb +0 -0
  184. data/test/ral/{types → type}/parameter.rb +0 -0
  185. data/test/ral/{types → type}/port.rb +0 -0
  186. data/test/ral/{types → type}/property.rb +0 -0
  187. data/test/ral/{types → type}/resources.rb +0 -0
  188. data/test/ral/{types → type}/service.rb +0 -0
  189. data/test/ral/{types → type}/sshkey.rb +0 -0
  190. data/test/ral/{types → type}/tidy.rb +1 -0
  191. data/test/ral/{types → type}/user.rb +0 -0
  192. data/test/ral/{types → type}/yumrepo.rb +0 -0
  193. data/test/ral/{types → type}/zone.rb +0 -0
  194. data/test/util/autoload.rb +24 -5
  195. metadata +60 -107
  196. data/conf/gentoo/puppet/puppetca.conf +0 -29
  197. data/conf/gentoo/puppet/puppetd.conf +0 -29
  198. data/conf/gentoo/puppet/puppetmasterd.conf +0 -29
  199. data/examples/root/etc/puppet/puppetd.conf +0 -4
  200. data/lib/puppet/external/gratr.rb +0 -33
  201. data/lib/puppet/external/gratr/adjacency_graph.rb +0 -257
  202. data/lib/puppet/external/gratr/base.rb +0 -34
  203. data/lib/puppet/external/gratr/biconnected.rb +0 -116
  204. data/lib/puppet/external/gratr/chinese_postman.rb +0 -123
  205. data/lib/puppet/external/gratr/common.rb +0 -73
  206. data/lib/puppet/external/gratr/comparability.rb +0 -92
  207. data/lib/puppet/external/gratr/digraph.rb +0 -116
  208. data/lib/puppet/external/gratr/digraph_distance.rb +0 -185
  209. data/lib/puppet/external/gratr/dot.rb +0 -90
  210. data/lib/puppet/external/gratr/edge.rb +0 -145
  211. data/lib/puppet/external/gratr/graph.rb +0 -303
  212. data/lib/puppet/external/gratr/graph_api.rb +0 -83
  213. data/lib/puppet/external/gratr/import.rb +0 -44
  214. data/lib/puppet/external/gratr/labels.rb +0 -90
  215. data/lib/puppet/external/gratr/maximum_flow.rb +0 -64
  216. data/lib/puppet/external/gratr/search.rb +0 -409
  217. data/lib/puppet/external/gratr/strong_components.rb +0 -127
  218. data/lib/puppet/external/gratr/undirected_graph.rb +0 -153
  219. data/lib/puppet/rails/external/tagging/acts_as_taggable.rb +0 -62
  220. data/lib/puppet/rails/external/tagging/init.rb +0 -5
  221. data/lib/puppet/rails/external/tagging/tag.rb +0 -50
  222. data/lib/puppet/rails/external/tagging/tagging.rb +0 -12
  223. data/lib/puppet/rails/puppet_class.rb +0 -6
  224. data/lib/puppet/reference/node_source.rb +0 -9
  225. data/lib/puppet/reference/report.rb +0 -21
  226. data/lib/puppet/type/pfile/checksum.rb +0 -326
  227. data/test/language/ast/definition.rb +0 -166
  228. data/test/language/ast/hostclass.rb +0 -184
  229. data/test/language/compile.rb +0 -569
  230. data/test/language/lexer.rb +0 -276
  231. data/test/lib/mocha.rb +0 -19
  232. data/test/lib/mocha/any_instance_method.rb +0 -35
  233. data/test/lib/mocha/auto_verify.rb +0 -113
  234. data/test/lib/mocha/central.rb +0 -35
  235. data/test/lib/mocha/class_method.rb +0 -62
  236. data/test/lib/mocha/deprecation.rb +0 -22
  237. data/test/lib/mocha/exception_raiser.rb +0 -17
  238. data/test/lib/mocha/expectation.rb +0 -378
  239. data/test/lib/mocha/expectation_error.rb +0 -6
  240. data/test/lib/mocha/infinite_range.rb +0 -25
  241. data/test/lib/mocha/inspect.rb +0 -39
  242. data/test/lib/mocha/instance_method.rb +0 -8
  243. data/test/lib/mocha/is_a.rb +0 -9
  244. data/test/lib/mocha/metaclass.rb +0 -7
  245. data/test/lib/mocha/missing_expectation.rb +0 -27
  246. data/test/lib/mocha/mock.rb +0 -207
  247. data/test/lib/mocha/multiple_yields.rb +0 -20
  248. data/test/lib/mocha/no_yields.rb +0 -11
  249. data/test/lib/mocha/object.rb +0 -110
  250. data/test/lib/mocha/parameter_matchers.rb +0 -9
  251. data/test/lib/mocha/parameter_matchers/all_of.rb +0 -39
  252. data/test/lib/mocha/parameter_matchers/any_of.rb +0 -44
  253. data/test/lib/mocha/parameter_matchers/anything.rb +0 -30
  254. data/test/lib/mocha/parameter_matchers/has_entry.rb +0 -39
  255. data/test/lib/mocha/parameter_matchers/has_key.rb +0 -39
  256. data/test/lib/mocha/parameter_matchers/has_value.rb +0 -39
  257. data/test/lib/mocha/parameter_matchers/includes.rb +0 -37
  258. data/test/lib/mocha/pretty_parameters.rb +0 -28
  259. data/test/lib/mocha/return_values.rb +0 -31
  260. data/test/lib/mocha/setup_and_teardown.rb +0 -23
  261. data/test/lib/mocha/single_return_value.rb +0 -24
  262. data/test/lib/mocha/single_yield.rb +0 -18
  263. data/test/lib/mocha/standalone.rb +0 -32
  264. data/test/lib/mocha/stub.rb +0 -18
  265. data/test/lib/mocha/test_case_adapter.rb +0 -49
  266. data/test/lib/mocha/yield_parameters.rb +0 -31
@@ -8,6 +8,10 @@ Puppet::Type.type(:service).provide :gentoo, :parent => :init do
8
8
 
9
9
  defaultfor :operatingsystem => :gentoo
10
10
 
11
+ def self.defpath
12
+ superclass.defpath
13
+ end
14
+
11
15
  def disable
12
16
  begin
13
17
  output = update :del, @resource[:name], :default
@@ -110,7 +110,7 @@ Puppet::Type.type(:service).provide :init, :parent => :base do
110
110
  # we just return that; otherwise, we return false, which causes it to
111
111
  # fallback to other mechanisms.
112
112
  def statuscmd
113
- if @resource[:hasstatus]
113
+ if @resource[:hasstatus] == :true
114
114
  return [self.initscript, :status]
115
115
  else
116
116
  return false
@@ -12,6 +12,8 @@ Puppet::Type.type(:sshkey).provide(:parsed,
12
12
  :default_target => known,
13
13
  :filetype => :flat
14
14
  ) do
15
+ desc "Parse and generate host-wide known hosts files for SSH."
16
+
15
17
  text_line :comment, :match => /^#/
16
18
  text_line :blank, :match => /^\s+/
17
19
 
@@ -19,7 +19,7 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
19
19
 
20
20
  has_features :manages_homedir, :allows_duplicates
21
21
 
22
- if Puppet.features.libshadow? and (Facter.value(:kernel) == "Linux")
22
+ if Puppet.features.libshadow?
23
23
  has_feature :manages_passwords
24
24
  end
25
25
 
@@ -91,6 +91,10 @@ module Puppet::Rails
91
91
  raise Puppet::Error, "Could not find Puppet::Rails database dir"
92
92
  end
93
93
 
94
+ unless ActiveRecord::Base.connection.tables.include?("resources")
95
+ raise Puppet::Error, "Database has problems, can't migrate."
96
+ end
97
+
94
98
  Puppet.notice "Migrating"
95
99
 
96
100
  begin
@@ -0,0 +1,17 @@
1
+ class AddCreatedAtToAllTables < ActiveRecord::Migration
2
+ def self.up
3
+ ActiveRecord::Base.connection.tables.each do |t|
4
+ unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at")
5
+ add_column t.to_s, :created_at, :datetime
6
+ end
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ ActiveRecord::Base.connection.tables.each do |t|
12
+ unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at")
13
+ remove_column t.to_s, :created_at
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,6 +1,10 @@
1
1
  class Puppet::Rails::FactValue < ActiveRecord::Base
2
2
  belongs_to :fact_name
3
3
  belongs_to :host
4
+
5
+ def to_label
6
+ "#{self.fact_name.name}"
7
+ end
4
8
  end
5
9
 
6
10
  # $Id: fact_value.rb 1952 2006-12-19 05:47:57Z luke $
@@ -11,8 +11,7 @@ class Puppet::Rails::Host < ActiveRecord::Base
11
11
 
12
12
  has_many :fact_values, :dependent => :destroy
13
13
  has_many :fact_names, :through => :fact_values
14
- belongs_to :puppet_classes
15
- has_many :source_files
14
+ belongs_to :source_file
16
15
  has_many :resources,
17
16
  :include => :param_values,
18
17
  :dependent => :destroy
@@ -20,5 +20,9 @@ class Puppet::Rails::ParamValue < ActiveRecord::Base
20
20
  self[:value] = val
21
21
  end
22
22
  end
23
+
24
+ def to_label
25
+ "#{self.param_name.name}"
26
+ end
23
27
  end
24
28
 
@@ -1,4 +1,8 @@
1
1
  class Puppet::Rails::ResourceTag < ActiveRecord::Base
2
2
  belongs_to :puppet_tag
3
3
  belongs_to :resource
4
+
5
+ def to_label
6
+ "#{self.puppet_tag.name}"
7
+ end
4
8
  end
@@ -1,5 +1,8 @@
1
1
  class Puppet::Rails::SourceFile < ActiveRecord::Base
2
2
  has_one :host
3
- has_one :puppet_class
4
3
  has_one :resource
4
+
5
+ def to_label
6
+ "#{self.filename}"
7
+ end
5
8
  end
@@ -59,7 +59,11 @@ class Puppet::Relationship
59
59
  end
60
60
 
61
61
  def ref
62
- "%s => %s" % [source.ref, target.ref]
62
+ "%s => %s" % [source, target]
63
+ end
64
+
65
+ def to_s
66
+ ref
63
67
  end
64
68
  end
65
69
 
@@ -28,6 +28,10 @@ Puppet::Reports.register_report(:tagmail) do
28
28
 
29
29
  This will send all messages to ``me@domain.com``, and all messages from
30
30
  webservers that are not also from mailservers to ``httpadmins@domain.com``.
31
+
32
+ If you are using anti-spam controls, such as grey-listing, on your mail
33
+ server you should whitelist the sending email (controlled by ``reportform``
34
+ configuration option) to ensure your email is not discarded as spam.
31
35
  "
32
36
 
33
37
 
@@ -127,7 +131,14 @@ Puppet::Reports.register_report(:tagmail) do
127
131
  Net::SMTP.start(Puppet[:smtpserver]) do |smtp|
128
132
  reports.each do |emails, messages|
129
133
  Puppet.info "Sending report to %s" % emails.join(", ")
130
- smtp.send_message(messages, Puppet[:reportfrom], *emails)
134
+ smtp.open_message_stream(Puppet[:reportfrom], *emails) do |p|
135
+ p.puts "From: #{Puppet[:reportfrom]}"
136
+ p.puts "Subject: Puppet Report for %s" % self.host
137
+ p.puts "To: " + emails.join(", ")
138
+ p.puts "Date: " + Time.now.rfc2822
139
+ p.puts
140
+ p.puts messages
141
+ end
131
142
  end
132
143
  end
133
144
  rescue => detail
@@ -36,7 +36,7 @@ class Puppet::ResourceReference
36
36
  # If the title has square brackets, treat it like a reference and
37
37
  # set things appropriately; else, just set it.
38
38
  def title=(value)
39
- if value =~ /^(.+)\[(.+)\]$/
39
+ if value =~ /^([^\[\]]+)\[(.+)\]$/
40
40
  self.type = $1
41
41
  @title = $2
42
42
  else
@@ -1,14 +1,11 @@
1
1
  # Created by Luke A. Kanies on 2007-11-07.
2
2
  # Copyright (c) 2007. All rights reserved.
3
3
 
4
- require 'puppet/external/gratr/dot'
4
+ require 'puppet/external/dot'
5
5
  require 'puppet/relationship'
6
- require 'puppet/external/gratr/search'
7
6
 
8
7
  # A hopefully-faster graph class to replace the use of GRATR.
9
8
  class Puppet::SimpleGraph
10
- include GRATR::Graph::Search
11
-
12
9
  # An internal class for handling a vertex's edges.
13
10
  class VertexWrapper
14
11
  attr_accessor :in, :out, :vertex
@@ -52,6 +49,19 @@ class Puppet::SimpleGraph
52
49
  return false
53
50
  end
54
51
 
52
+ # Create methods for returning the degree and edges.
53
+ [:in, :out].each do |direction|
54
+ # LAK:NOTE If you decide to create methods for directly
55
+ # testing the degree, you'll have to get the values and flatten
56
+ # the results -- you might have duplicate edges, which can give
57
+ # a false impression of what the degree is. That's just
58
+ # as expensive as just getting the edge list, so I've decided
59
+ # to only add this method.
60
+ define_method("%s_edges" % direction) do
61
+ @adjacencies[direction].values.flatten
62
+ end
63
+ end
64
+
55
65
  # The other vertex in the edge.
56
66
  def other_vertex(direction, edge)
57
67
  case direction
@@ -66,6 +76,10 @@ class Puppet::SimpleGraph
66
76
  def remove_edge(direction, edge)
67
77
  @adjacencies[direction][other_vertex(direction, edge)].delete(edge)
68
78
  end
79
+
80
+ def to_s
81
+ vertex.to_s
82
+ end
69
83
  end
70
84
 
71
85
  def initialize
@@ -80,7 +94,7 @@ class Puppet::SimpleGraph
80
94
  @edges.clear
81
95
  end
82
96
 
83
- # Whether our graph is directed. Always true. (Used by the GRATR search lib.)
97
+ # Whether our graph is directed. Always true. Used to produce dot files.
84
98
  def directed?
85
99
  true
86
100
  end
@@ -88,26 +102,58 @@ class Puppet::SimpleGraph
88
102
  # Return a reversed version of this graph.
89
103
  def reversal
90
104
  result = self.class.new
91
- vertices.each { |vertex| result.add_vertex!(vertex) }
105
+ vertices.each { |vertex| result.add_vertex(vertex) }
92
106
  edges.each do |edge|
93
107
  newedge = edge.class.new(edge.target, edge.source, edge.label)
94
- result.add_edge!(newedge)
108
+ result.add_edge(newedge)
95
109
  end
96
110
  result
97
111
  end
98
112
 
99
- # Return the size of the graph. Used by GRATR.
113
+ # Return the size of the graph.
100
114
  def size
101
115
  @vertices.length
102
116
  end
103
117
 
104
- # Return the graph as an array. Again, used by GRATR.
118
+ # Return the graph as an array.
105
119
  def to_a
106
120
  @vertices.keys
107
121
  end
108
122
 
123
+ # Provide a topological sort.
124
+ def topsort
125
+ degree = {}
126
+ zeros = []
127
+ result = []
128
+
129
+ # Collect each of our vertices, with the number of in-edges each has.
130
+ @vertices.each do |name, wrapper|
131
+ edges = wrapper.in_edges
132
+ zeros << wrapper if edges.length == 0
133
+ degree[wrapper.vertex] = edges
134
+ end
135
+
136
+ # Iterate over each 0-degree vertex, decrementing the degree of
137
+ # each of its out-edges.
138
+ while wrapper = zeros.pop do
139
+ result << wrapper.vertex
140
+ wrapper.out_edges.each do |edge|
141
+ degree[edge.target].delete(edge)
142
+ zeros << @vertices[edge.target] if degree[edge.target].length == 0
143
+ end
144
+ end
145
+
146
+ # If we have any vertices left with non-zero in-degrees, then we've found a cycle.
147
+ if cycles = degree.find_all { |vertex, edges| edges.length > 0 } and cycles.length > 0
148
+ message = cycles.collect { |vertex, edges| edges.collect { |e| e.to_s }.join(", ") }.join(", ")
149
+ raise Puppet::Error, "Found dependency cycles in the following relationships: %s" % message
150
+ end
151
+
152
+ return result
153
+ end
154
+
109
155
  # Add a new vertex to the graph.
110
- def add_vertex!(vertex)
156
+ def add_vertex(vertex)
111
157
  return false if vertex?(vertex)
112
158
  setup_vertex(vertex)
113
159
  true # don't return the VertexWrapper instance.
@@ -133,7 +179,7 @@ class Puppet::SimpleGraph
133
179
 
134
180
  # Add a new edge. The graph user has to create the edge instance,
135
181
  # since they have to specify what kind of edge it is.
136
- def add_edge!(source, target = nil, label = nil)
182
+ def add_edge(source, target = nil, label = nil)
137
183
  if target
138
184
  edge = Puppet::Relationship.new(source, target, label)
139
185
  else
@@ -195,6 +241,27 @@ class Puppet::SimpleGraph
195
241
  end
196
242
 
197
243
  public
244
+
245
+ # # For some reason, unconnected vertices do not show up in
246
+ # # this graph.
247
+ # def to_jpg(path, name)
248
+ # gv = vertices()
249
+ # Dir.chdir(path) do
250
+ # induced_subgraph(gv).write_to_graphic_file('jpg', name)
251
+ # end
252
+ # end
253
+
254
+ def to_yaml_properties
255
+ instance_variables
256
+ end
257
+
258
+ # Just walk the tree and pass each edge.
259
+ def walk(source, direction, &block)
260
+ adjacent(source, :direction => direction).each do |target|
261
+ yield source, target
262
+ walk(target, direction, &block)
263
+ end
264
+ end
198
265
 
199
266
  # LAK:FIXME This is just a paste of the GRATR code with slight modifications.
200
267
 
@@ -72,7 +72,7 @@ module Puppet::SSLCertificates
72
72
  subject_alt_name << 'DNS:' + name.sub(/^[^.]+./, "puppet.") # add puppet.domain as an alias
73
73
  end
74
74
  key_usage = %w{digitalSignature keyEncipherment}
75
- ext_key_usage = %w{serverAuth clientAuth}
75
+ ext_key_usage = %w{serverAuth clientAuth emailProtection}
76
76
  when :ocsp:
77
77
  basic_constraint = "CA:FALSE"
78
78
  key_usage = %w{nonRepudiation digitalSignature}
@@ -194,8 +194,8 @@ class Puppet::SSLCertificates::CA
194
194
  # Revoke the certificate with serial number SERIAL issued by this
195
195
  # CA. The REASON must be one of the OpenSSL::OCSP::REVOKED_* reasons
196
196
  def revoke(serial, reason = OpenSSL::OCSP::REVOKED_STATUS_KEYCOMPROMISE)
197
- if @config[:cacrl] == 'none'
198
- raise Puppet::Error, "Revocation requires a CRL, but ca_crl is set to 'none'"
197
+ if @config[:cacrl] == 'false'
198
+ raise Puppet::Error, "Revocation requires a CRL, but ca_crl is set to 'false'"
199
199
  end
200
200
  time = Time.now
201
201
  revoked = OpenSSL::X509::Revoked.new
@@ -372,7 +372,7 @@ class Puppet::SSLCertificates::CA
372
372
  @crl = OpenSSL::X509::CRL.new(
373
373
  File.read(@config[:cacrl])
374
374
  )
375
- elsif @config[:cacrl] == 'none'
375
+ elsif @config[:cacrl] == 'false'
376
376
  @crl = nil
377
377
  else
378
378
  # Create new CRL
@@ -15,8 +15,6 @@ class Transaction
15
15
  # The list of events generated in this transaction.
16
16
  attr_reader :events
17
17
 
18
- attr_writer :tags
19
-
20
18
  include Puppet::Util
21
19
 
22
20
  # Add some additional times for reporting
@@ -173,7 +171,7 @@ class Transaction
173
171
  relationship_graph.add_resource(gen_child) unless relationship_graph.resource(gen_child.ref)
174
172
 
175
173
  unless relationship_graph.edge?(edge[1], edge[0])
176
- relationship_graph.add_edge!(*edge)
174
+ relationship_graph.add_edge(*edge)
177
175
  else
178
176
  resource.debug "Skipping automatic relationship to %s" % gen_child
179
177
  end
@@ -424,7 +422,7 @@ class Transaction
424
422
 
425
423
  # Should we ignore tags?
426
424
  def ignore_tags?
427
- ! @catalog.host_config?
425
+ ! (@catalog.host_config? or Puppet[:name] == "puppet")
428
426
  end
429
427
 
430
428
  # this should only be called by a Puppet::Type::Component resource now
@@ -636,6 +634,11 @@ class Transaction
636
634
 
637
635
  @tags
638
636
  end
637
+
638
+ def tags=(tags)
639
+ tags = [tags] unless tags.is_a?(Array)
640
+ @tags = tags
641
+ end
639
642
 
640
643
  # Is this resource tagged appropriately?
641
644
  def missing_tags?(resource)
@@ -193,7 +193,7 @@ module Puppet
193
193
  next unless resource = child.to_type
194
194
  config.add_resource resource
195
195
  end
196
- config.add_edge!(container, resource)
196
+ config.add_edge(container, resource)
197
197
  if child.is_a?(self.class)
198
198
  delver.call(child)
199
199
  end
@@ -257,10 +257,7 @@ class Type
257
257
  rescue ArgumentError, Puppet::Error, TypeError
258
258
  raise
259
259
  rescue => detail
260
- error = Puppet::DevError.new(
261
- "Could not set %s on %s: %s" %
262
- [attr, self.class.name, detail]
263
- )
260
+ error = Puppet::DevError.new( "Could not set %s on %s: %s" % [attr, self.class.name, detail])
264
261
  error.set_backtrace(detail.backtrace)
265
262
  raise error
266
263
  end
@@ -422,10 +419,6 @@ end
422
419
 
423
420
  require 'puppet/propertychange'
424
421
  require 'puppet/provider'
425
- require 'puppet/type/component'
426
- require 'puppet/type/pfile'
427
- require 'puppet/type/pfilebucket'
428
- require 'puppet/type/tidy'
429
-
430
-
431
422
 
423
+ # Always load these types.
424
+ require 'puppet/type/component'
@@ -23,6 +23,24 @@ Puppet::Type.newtype(:cron) do
23
23
  hour => 2,
24
24
  minute => 0
25
25
  }
26
+
27
+ Note that all cron values can be specified as an array of values::
28
+
29
+ cron { logrotate:
30
+ command => \"/usr/sbin/logrotate\",
31
+ user => root,
32
+ hour => [2, 4]
33
+ }
34
+
35
+ Or using ranges, or the step syntax ``*/2`` (although there's no guarantee that
36
+ your ``cron`` daemon supports it)::
37
+
38
+ cron { logrotate:
39
+ command => \"/usr/sbin/logrotate\",
40
+ user => root,
41
+ hour => ['2-4'],
42
+ minute => '*/10'
43
+ }
26
44
  "
27
45
  ensurable
28
46