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
@@ -53,14 +53,14 @@ module Puppet
53
53
  end
54
54
 
55
55
  newparam(:name) do
56
- desc "The host name."
56
+ desc "The host name that the key is associated with."
57
57
 
58
58
  isnamevar
59
59
  end
60
60
 
61
61
  newproperty(:target) do
62
- desc "The file in which to store the mount table. Only used by
63
- those providers that write to disk (i.e., not NetInfo)."
62
+ desc "The file in which to store the ssh key. Only used by
63
+ the ``parsed`` provider."
64
64
 
65
65
  defaultto { if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
66
66
  @resource.class.defaultprovider.default_target
@@ -1,6 +1,9 @@
1
+ require 'puppet/util/warnings'
2
+
1
3
  # Autoload paths, either based on names or all at once.
2
4
  class Puppet::Util::Autoload
3
5
  include Puppet::Util
6
+ include Puppet::Util::Warnings
4
7
 
5
8
  @autoloaders = {}
6
9
  @loaded = []
@@ -109,9 +112,8 @@ class Puppet::Util::Autoload
109
112
  Dir.glob("#{dir}/*.rb").each do |file|
110
113
  name = File.basename(file).sub(".rb", '').intern
111
114
  next if loaded?(name)
112
- rubypath = File.join(@path, name.to_s)
113
115
  begin
114
- Kernel.require rubypath
116
+ Kernel.require file
115
117
  loaded(name, file)
116
118
  rescue => detail
117
119
  if Puppet[:trace]
@@ -123,8 +125,6 @@ class Puppet::Util::Autoload
123
125
  end
124
126
  end
125
127
 
126
- private
127
-
128
128
  # Yield each subdir in turn.
129
129
  def eachdir
130
130
  searchpath.each do |dir|
@@ -137,7 +137,7 @@ class Puppet::Util::Autoload
137
137
  def searchpath
138
138
  # JJM: Search for optional lib directories in each module bundle.
139
139
  module_lib_dirs = Puppet[:modulepath].split(":").collect do |d|
140
- Dir.glob("%s/*/lib" % d).select do |f|
140
+ Dir.glob("%s/*/{plugins,lib}" % d).select do |f|
141
141
  FileTest.directory?(f)
142
142
  end
143
143
  end.flatten
@@ -1,37 +1,75 @@
1
+ # A stand-alone module for calculating checksums
2
+ # in a generic way.
1
3
  module Puppet::Util::Checksums
4
+ # Calculate a checksum using Digest::MD5.
2
5
  def md5(content)
3
6
  require 'digest/md5'
4
7
  Digest::MD5.hexdigest(content)
5
8
  end
6
9
 
7
- def md5_file(filename)
10
+ # Calculate a checksum of the first 500 chars of the content using Digest::MD5.
11
+ def md5lite(content)
12
+ md5(content[0..511])
13
+ end
14
+
15
+ # Calculate a checksum of a file's content using Digest::MD5.
16
+ def md5_file(filename, lite = false)
8
17
  require 'digest/md5'
9
18
 
10
- incr_digest = Digest::MD5.new()
11
- File.open(filename, 'r') do |file|
12
- file.each_line do |line|
13
- incr_digest << line
14
- end
15
- end
19
+ digest = Digest::MD5.new()
20
+ return checksum_file(digest, filename, lite)
21
+ end
22
+
23
+ # Calculate a checksum of the first 500 chars of a file's content using Digest::MD5.
24
+ def md5lite_file(filename)
25
+ md5_file(filename, true)
26
+ end
16
27
 
17
- return incr_digest.hexdigest
28
+ # Return the :mtime timestamp of a file.
29
+ def mtime_file(filename)
30
+ File.stat(filename).send(:mtime)
18
31
  end
19
32
 
33
+ # Calculate a checksum using Digest::SHA1.
20
34
  def sha1(content)
21
35
  require 'digest/sha1'
22
36
  Digest::SHA1.hexdigest(content)
23
37
  end
24
38
 
25
- def sha1_file(filename)
39
+ # Calculate a checksum of the first 500 chars of the content using Digest::SHA1.
40
+ def sha1lite(content)
41
+ sha1(content[0..511])
42
+ end
43
+
44
+ # Calculate a checksum of a file's content using Digest::SHA1.
45
+ def sha1_file(filename, lite = false)
26
46
  require 'digest/sha1'
27
47
 
28
- incr_digest = Digest::SHA1.new()
48
+ digest = Digest::SHA1.new()
49
+ return checksum_file(digest, filename, lite)
50
+ end
51
+
52
+ # Calculate a checksum of the first 500 chars of a file's content using Digest::SHA1.
53
+ def sha1lite_file(filename)
54
+ sha1_file(filename, true)
55
+ end
56
+
57
+ # Return the :ctime of a file.
58
+ def ctime_file(filename)
59
+ File.stat(filename).send(:ctime)
60
+ end
61
+
62
+ private
63
+
64
+ # Perform an incremental checksum on a file.
65
+ def checksum_file(digest, filename, lite = false)
29
66
  File.open(filename, 'r') do |file|
30
- file.each_line do |line|
31
- incr_digest << line
67
+ while content = file.read(512)
68
+ digest << content
69
+ break if lite
32
70
  end
33
71
  end
34
72
 
35
- return incr_digest.hexdigest
73
+ return digest.hexdigest
36
74
  end
37
75
  end
@@ -0,0 +1,14 @@
1
+ # Created on 2008-02-12
2
+ # Copyright Luke Kanies
3
+
4
+ # A common module for converting between constants and
5
+ # file names.
6
+ module Puppet::Util::ConstantInflector
7
+ def file2constant(file)
8
+ file.split("/").collect { |name| name.capitalize }.join("::").gsub(/_+(.)/) { |term| $1.capitalize }
9
+ end
10
+
11
+ def constant2file(constant)
12
+ constant.to_s.gsub(/([a-z])([A-Z])/) { |term| $1 + "_" + $2 }.gsub("::", "/").downcase
13
+ end
14
+ end
@@ -165,7 +165,7 @@ class Puppet::Util::FileType
165
165
 
166
166
  # Remove a specific @path's cron tab.
167
167
  def remove
168
- if Facter.value("operatingsystem") == "FreeBSD"
168
+ if %w{Darwin FreeBSD}.include?(Facter.value("operatingsystem"))
169
169
  %x{/bin/echo yes | #{cmdbase()} -r 2>/dev/null}
170
170
  else
171
171
  %x{#{cmdbase()} -r 2>/dev/null}
@@ -16,21 +16,15 @@ module Puppet::Util::Graph
16
16
 
17
17
  self.each do |child|
18
18
  unless block_given? and ! yield(child)
19
- graph.add_edge!(self, child)
20
-
21
- if graph.cyclic?
22
- raise Puppet::Error, "%s created a cyclic graph" % self
23
- end
19
+ graph.add_edge(self, child)
24
20
 
25
21
  if child.respond_to?(:to_graph)
26
22
  child.to_graph(graph, &block)
27
23
  end
28
24
  end
29
25
  end
30
-
31
- if graph.cyclic?
32
- raise Puppet::Error, "%s created a cyclic graph" % self
33
- end
26
+
27
+ # Do a topsort, which will throw an exception if the graph is cyclic.
34
28
 
35
29
  graph
36
30
  end
@@ -0,0 +1,57 @@
1
+ require 'puppet/external/nagios'
2
+ require 'puppet/external/nagios/base'
3
+ require 'puppet/provider/naginator'
4
+
5
+ module Puppet::Util::NagiosMaker
6
+ # Create a new nagios type, using all of the parameters
7
+ # from the parser.
8
+ def self.create_nagios_type(name)
9
+ name = name.to_sym
10
+ full_name = ("nagios_" + name.to_s).to_sym
11
+
12
+ raise(Puppet::DevError, "No nagios type for %s" % name) unless nagtype = Nagios::Base.type(name)
13
+
14
+ type = Puppet::Type.newtype(full_name) {}
15
+
16
+ type.ensurable
17
+
18
+ type.newparam(nagtype.namevar, :namevar => true) do
19
+ desc "The name parameter for Nagios type %s" % nagtype.name
20
+ end
21
+
22
+ # We deduplicate the parameters because it makes sense to allow Naginator to have dupes.
23
+ nagtype.parameters.uniq.each do |param|
24
+ next if param == nagtype.namevar
25
+
26
+ # We can't turn these parameter names into constants, so at least for now they aren't
27
+ # supported.
28
+ next if param.to_s =~ /^[0-9]/
29
+
30
+ type.newproperty(param) do
31
+ desc "Nagios configuration file parameter."
32
+ end
33
+ end
34
+
35
+ type.newproperty(:target) do
36
+ desc 'target'
37
+
38
+ defaultto do
39
+ resource.class.defaultprovider.default_target
40
+ end
41
+ end
42
+
43
+ target = "/etc/nagios/#{full_name.to_s}.cfg"
44
+ provider = type.provide(:naginator, :parent => Puppet::Provider::Naginator, :default_target => target) {}
45
+
46
+ type.desc "The Nagios type #{name.to_s}. This resource type is autogenerated using the
47
+ model developed in Naginator_, and all of the Nagios types are generated using the
48
+ same code and the same library.
49
+
50
+ This type generates Nagios configuration statements in Nagios-parseable configuration
51
+ files. By default, the statements will be added to ``#{target}``, but
52
+ you can send them to a different file by setting their ``target`` attribute.
53
+
54
+ .. _naginator: http://reductivelabs.com/trac/naginator
55
+ "
56
+ end
57
+ end
@@ -509,19 +509,19 @@ class Puppet::Util::Settings
509
509
  objects += add_user_resources(section, obj, done)
510
510
  end
511
511
 
512
+ value = obj.value
513
+
512
514
  # Only files are convertable to transportable resources.
513
- if obj.respond_to? :to_transportable
514
- next if value(obj.name) =~ /^\/dev/
515
- transobjects = obj.to_transportable
516
- transobjects = [transobjects] unless transobjects.is_a? Array
517
- transobjects.each do |trans|
518
- # transportable could return nil
519
- next unless trans
520
- unless done[:file].include? trans.name
521
- @created << trans.name
522
- objects << trans
523
- done[:file][trans.name] = trans
524
- end
515
+ next unless obj.respond_to? :to_transportable and transobjects = obj.to_transportable
516
+
517
+ transobjects = [transobjects] unless transobjects.is_a? Array
518
+ transobjects.each do |trans|
519
+ # transportable could return nil
520
+ next unless trans
521
+ unless done[:file].include? trans.name
522
+ @created << trans.name
523
+ objects << trans
524
+ done[:file][trans.name] = trans
525
525
  end
526
526
  end
527
527
  end
@@ -1124,7 +1124,7 @@ Generated on #{Time.now}.
1124
1124
  # the variable 'dir', or adding a slash at the end.
1125
1125
  def munge(value)
1126
1126
  # If it's not a fully qualified path...
1127
- if value.is_a?(String) and value !~ /^\$/ and value !~ /^\//
1127
+ if value.is_a?(String) and value !~ /^\$/ and value !~ /^\// and value != 'false'
1128
1128
  # Make it one
1129
1129
  value = File.join(Dir.getwd, value)
1130
1130
  end
@@ -1153,12 +1153,15 @@ Generated on #{Time.now}.
1153
1153
  def to_transportable
1154
1154
  type = self.type
1155
1155
  return nil unless type
1156
- path = @parent.value(self.name).split(File::SEPARATOR)
1157
- path.shift # remove the leading nil
1158
1156
 
1159
- objects = []
1160
1157
  path = self.value
1161
1158
 
1159
+ return nil unless path.is_a?(String)
1160
+ return nil if path =~ /^\/dev/
1161
+ return nil if Puppet::Type.type(:file)[path] # skip files that are in our global resource list.
1162
+
1163
+ objects = []
1164
+
1162
1165
  # Skip plain files that don't exist, since we won't be managing them anyway.
1163
1166
  return nil unless self.name.to_s =~ /dir$/ or File.exist?(path) or self.create
1164
1167
  obj = Puppet::TransObject.new(path, "file")
@@ -0,0 +1,39 @@
1
+ # Created on 2008-01-19
2
+ # Copyright Luke Kanies
3
+
4
+ # A common module to handle tagging.
5
+ module Puppet::Util::Tagging
6
+ # Add a tag to our current list. These tags will be added to all
7
+ # of the objects contained in this scope.
8
+ def tag(*ary)
9
+ @tags ||= []
10
+
11
+ qualified = []
12
+
13
+ ary.collect { |tag| tag.to_s.downcase }.each do |tag|
14
+ fail(Puppet::ParseError, "Invalid tag %s" % tag.inspect) unless valid_tag?(tag)
15
+ qualified << tag if tag.include?("::")
16
+ @tags << tag unless @tags.include?(tag)
17
+ end
18
+
19
+ qualified.collect { |name| name.split("::") }.flatten.each { |tag| @tags << tag unless @tags.include?(tag) }
20
+ end
21
+
22
+ # Are we tagged with the provided tag?
23
+ def tagged?(tag)
24
+ defined?(@tags) and @tags.include?(tag.to_s)
25
+ end
26
+
27
+ # Return a copy of the tag list, so someone can't ask for our tags
28
+ # and then modify them.
29
+ def tags
30
+ @tags ||= []
31
+ @tags.dup
32
+ end
33
+
34
+ private
35
+
36
+ def valid_tag?(tag)
37
+ tag =~ /^\w[-\w:.]*$/
38
+ end
39
+ end
@@ -83,5 +83,22 @@ class TestPuppetBin < Test::Unit::TestCase
83
83
 
84
84
  assert(FileTest.exists?(path), "Failed to create config'ed file")
85
85
  end
86
+
87
+ def test_parseonly
88
+ path = tempfile()
89
+ manifest = tempfile()
90
+ puppet = %x{which puppet}.chomp
91
+ if puppet == ""
92
+ Puppet.info "cannot find puppet; cannot test parseonly"
93
+ return
94
+ end
95
+ code = 'File <<| |>>
96
+ include nosuchclass'
97
+
98
+ assert_nothing_raised {
99
+ IO.popen("#{puppet} --parseonly", 'w') { |p| p.puts code }
100
+ }
101
+ assert($? == 0, "parseonly test exited with code %s" % $?.to_i)
102
+ end
86
103
  end
87
104
 
@@ -35,14 +35,14 @@ class TestAST < Test::Unit::TestCase
35
35
  # We initialized it to true, so we should get that first
36
36
  ret = nil
37
37
  assert_nothing_raised {
38
- ret = astif.evaluate(:scope => "yay")
38
+ ret = astif.evaluate("yay")
39
39
  }
40
40
  assert_equal(:if, ret)
41
41
 
42
42
  # Now set it to false and check that
43
43
  faketest.evaluate = false
44
44
  assert_nothing_raised {
45
- ret = astif.evaluate(:scope => "yay")
45
+ ret = astif.evaluate("yay")
46
46
  }
47
47
  assert_equal(:else, ret)
48
48
  end
@@ -57,10 +57,10 @@ class TestAST < Test::Unit::TestCase
57
57
  end
58
58
 
59
59
  Puppet::Parser::Resource.expects(:new).with { |o| o.is_a?(Hash) }.returns(:override)
60
- scope.compile.expects(:store_override).with(:override)
60
+ scope.compiler.expects(:add_override).with(:override)
61
61
  ret = nil
62
62
  assert_nothing_raised do
63
- ret = ref.evaluate :scope => scope
63
+ ret = ref.evaluate scope
64
64
  end
65
65
 
66
66
  assert_equal(:override, ret, "Did not return override")
@@ -74,7 +74,7 @@ class TestAST < Test::Unit::TestCase
74
74
  args = {:source => "/yay/ness", :group => "yayness"}
75
75
  assert_nothing_raised do
76
76
  obj = defaultobj "file", args
77
- obj.evaluate :scope => scope
77
+ obj.evaluate scope
78
78
  end
79
79
 
80
80
  hash = nil
@@ -93,56 +93,6 @@ class TestAST < Test::Unit::TestCase
93
93
  end
94
94
  end
95
95
 
96
- def test_node
97
- scope = mkscope
98
- parser = scope.compile.parser
99
-
100
- # Define a base node
101
- basenode = parser.newnode "basenode", :code => AST::ASTArray.new(:children => [
102
- resourcedef("file", "/tmp/base", "owner" => "root")
103
- ])
104
-
105
- # Now define a subnode
106
- nodes = parser.newnode ["mynode", "othernode"],
107
- :code => AST::ASTArray.new(:children => [
108
- resourcedef("file", "/tmp/mynode", "owner" => "root"),
109
- resourcedef("file", "/tmp/basenode", "owner" => "daemon")
110
- ])
111
-
112
- assert_instance_of(Array, nodes)
113
-
114
- # Make sure we can find them all.
115
- %w{mynode othernode}.each do |node|
116
- assert(parser.nodes[node], "Could not find %s" % node)
117
- end
118
- mynode = parser.nodes["mynode"]
119
-
120
- # Now try evaluating the node
121
- assert_nothing_raised do
122
- mynode.evaluate :scope => scope, :resource => scope.resource
123
- end
124
-
125
- # Make sure that we can find each of the files
126
- myfile = scope.findresource "File[/tmp/mynode]"
127
- assert(myfile, "Could not find file from node")
128
- assert_equal("root", myfile[:owner])
129
-
130
- basefile = scope.findresource "File[/tmp/basenode]"
131
- assert(basefile, "Could not find file from base node")
132
- assert_equal("daemon", basefile[:owner])
133
-
134
- # Now make sure we can evaluate nodes with parents
135
- child = parser.newnode(%w{child}, :parent => "basenode").shift
136
-
137
- newscope = mkscope :parser => parser
138
- assert_nothing_raised do
139
- child.evaluate :scope => newscope, :resource => scope.resource
140
- end
141
-
142
- assert(newscope.findresource("File[/tmp/base]"),
143
- "Could not find base resource")
144
- end
145
-
146
96
  def test_collection
147
97
  scope = mkscope
148
98
 
@@ -155,13 +105,13 @@ class TestAST < Test::Unit::TestCase
155
105
 
156
106
  ret = nil
157
107
  assert_nothing_raised do
158
- ret = coll.evaluate :scope => scope
108
+ ret = coll.evaluate scope
159
109
  end
160
110
 
161
111
  assert_instance_of(Puppet::Parser::Collector, ret)
162
112
 
163
113
  # Now make sure we get it back from the scope
164
- colls = scope.compile.instance_variable_get("@collections")
114
+ colls = scope.compiler.instance_variable_get("@collections")
165
115
  assert_equal([ret], colls, "Did not store collector in config's collection list")
166
116
  end
167
117
 
@@ -175,7 +125,7 @@ class TestAST < Test::Unit::TestCase
175
125
  run_collection_queries(:virtual) do |string, result, query|
176
126
  code = nil
177
127
  assert_nothing_raised do
178
- str, code = query.evaluate :scope => scope
128
+ str, code = query.evaluate scope
179
129
  end
180
130
 
181
131
  assert_instance_of(Proc, code)