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
@@ -1,5 +1,5 @@
1
1
  module Puppet
2
- Puppet.type(:file).newproperty(:content) do
2
+ Puppet::Type.type(:file).newproperty(:content) do
3
3
  include Puppet::Util::Diff
4
4
 
5
5
  desc "Specify the contents of a file as a string. Newlines, tabs, and
@@ -47,23 +47,13 @@ module Puppet
47
47
  return result
48
48
  end
49
49
 
50
- # We should probably take advantage of existing md5 sums if they're there,
51
- # but I really don't feel like dealing with the complexity right now.
52
50
  def retrieve
53
- stat = nil
54
- unless stat = @resource.stat
55
- return :absent
56
- end
51
+ return :absent unless stat = @resource.stat
57
52
 
58
- if stat.ftype == "link" and @resource[:links] == :ignore
59
- return self.should
60
- end
53
+ return self.should if stat.ftype == "link" and @resource[:links] == :ignore
61
54
 
62
55
  # Don't even try to manage the content on directories
63
- if stat.ftype == "directory" and @resource[:links] == :ignore
64
- @resource.delete(:content)
65
- return nil
66
- end
56
+ return nil if stat.ftype == "directory"
67
57
 
68
58
  begin
69
59
  currentvalue = File.read(@resource[:path])
@@ -74,12 +64,17 @@ module Puppet
74
64
  end
75
65
  end
76
66
 
67
+ # Make sure we're also managing the checksum property.
68
+ def should=(value)
69
+ super
70
+ @resource.newattr(:checksum) unless @resource.property(:checksum)
71
+ end
77
72
 
78
73
  # Just write our content out to disk.
79
74
  def sync
80
75
  return_event = @resource.stat ? :file_changed : :file_created
81
76
 
82
- @resource.write(:content) { |f| f.print self.should }
77
+ @resource.write(self.should, :content)
83
78
 
84
79
  return return_event
85
80
  end
@@ -46,7 +46,7 @@ module Puppet
46
46
  if property = (@resource.property(:content) || @resource.property(:source))
47
47
  property.sync
48
48
  else
49
- @resource.write(false) { |f| f.flush }
49
+ @resource.write("", :ensure)
50
50
  mode = @resource.should(:mode)
51
51
  end
52
52
  return :file_created
@@ -67,14 +67,12 @@ module Puppet
67
67
  "Cannot create %s; parent directory %s does not exist" %
68
68
  [@resource[:path], parent]
69
69
  end
70
- @resource.write_if_writable(parent) do
71
- if mode
72
- Puppet::Util.withumask(000) do
73
- Dir.mkdir(@resource[:path],mode)
74
- end
75
- else
76
- Dir.mkdir(@resource[:path])
70
+ if mode
71
+ Puppet::Util.withumask(000) do
72
+ Dir.mkdir(@resource[:path],mode)
77
73
  end
74
+ else
75
+ Dir.mkdir(@resource[:path])
78
76
  end
79
77
  @resource.send(:property_fix)
80
78
  @resource.setchecksum
@@ -101,9 +99,13 @@ module Puppet
101
99
  munge do |value|
102
100
  value = super(value)
103
101
 
102
+ # It doesn't make sense to try to manage links unless, well,
103
+ # we're managing links.
104
+ resource[:links] = :manage if value == :link
104
105
  return value if value.is_a? Symbol
105
106
 
106
107
  @resource[:target] = value
108
+ resource[:links] = :manage
107
109
 
108
110
  return :link
109
111
  end
@@ -136,6 +138,11 @@ module Puppet
136
138
  # We have to treat :present specially, because it works with any
137
139
  # type of file.
138
140
  def insync?(currentvalue)
141
+ if property = @resource.property(:source) and ! property.described?
142
+ warning "No specified sources exist"
143
+ return true
144
+ end
145
+
139
146
  if self.should == :present
140
147
  if currentvalue.nil? or currentvalue == :absent
141
148
  return false
File without changes
File without changes
File without changes
@@ -101,15 +101,17 @@ module Puppet
101
101
  begin
102
102
  desc = server.describe(path, @resource[:links])
103
103
  rescue Puppet::Network::XMLRPCClientError => detail
104
- self.err "Could not describe %s: %s" %
105
- [path, detail]
104
+ self.err "Could not describe %s: %s" % [path, detail]
106
105
  return nil
107
106
  end
108
107
 
108
+ return nil if desc == ""
109
+
110
+ # Collect everything except the checksum
111
+ values = desc.split("\t")
112
+ other = values.pop
109
113
  args = {}
110
- pinparams.zip(
111
- desc.split("\t")
112
- ).each { |param, value|
114
+ pinparams.zip(values).each { |param, value|
113
115
  if value =~ /^[0-9]+$/
114
116
  value = value.to_i
115
117
  end
@@ -118,16 +120,19 @@ module Puppet
118
120
  end
119
121
  }
120
122
 
121
- # we can't manage ownership as root, so don't even try
122
- unless Puppet::Util::SUIDManager.uid == 0
123
- args.delete(:owner)
123
+ # Now decide whether we're doing checksums or symlinks
124
+ if args[:type] == "link"
125
+ args[:target] = other
126
+ else
127
+ args[:checksum] = other
124
128
  end
125
129
 
126
- if args.empty? or (args[:type] == "link" and @resource[:links] == :ignore)
127
- return nil
128
- else
129
- return args
130
+ # we can't manage ownership unless we're root, so don't even try
131
+ unless Puppet::Util::SUIDManager.uid == 0
132
+ args.delete(:owner)
130
133
  end
134
+
135
+ return args
131
136
  end
132
137
 
133
138
  # Have we successfully described the remote source?
@@ -138,10 +143,10 @@ module Puppet
138
143
  # Use the info we get from describe() to check if we're in sync.
139
144
  def insync?(currentvalue)
140
145
  unless described?
141
- info "No specified sources exist"
146
+ warning "No specified sources exist"
142
147
  return true
143
148
  end
144
-
149
+
145
150
  if currentvalue == :nocopy
146
151
  return true
147
152
  end
@@ -163,7 +168,7 @@ module Puppet
163
168
 
164
169
  # Diff the contents if they ask it. This is quite annoying -- we need to do this in
165
170
  # 'insync?' because they might be in noop mode, but we don't want to do the file
166
- # retrieval twice, so we cache the value annoyingly.
171
+ # retrieval twice, so we cache the value.
167
172
  if ! result and Puppet[:show_diff] and File.exists?(@resource[:path]) and ! @stats[:_diffed]
168
173
  @stats[:_remote_content] = get_remote_content
169
174
  string_file_diff(@resource[:path], @stats[:_remote_content])
@@ -173,7 +178,7 @@ module Puppet
173
178
  end
174
179
 
175
180
  def pinparams
176
- Puppet::Network::Handler.handler(:fileserver).params
181
+ [:mode, :type, :owner, :group]
177
182
  end
178
183
 
179
184
  # This basically calls describe() on our file, and then sets all
@@ -202,14 +207,11 @@ module Puppet
202
207
  end
203
208
 
204
209
  case @stats[:type]
205
- when "directory", "file":
206
- unless @resource.deleting?
207
- @resource[:ensure] = @stats[:type]
208
- end
210
+ when "directory", "file", "link":
211
+ @resource[:ensure] = @stats[:type] unless @resource.deleting?
209
212
  else
210
213
  self.info @stats.inspect
211
- self.err "Cannot use files of type %s as sources" %
212
- @stats[:type]
214
+ self.err "Cannot use files of type %s as sources" % @stats[:type]
213
215
  return :nocopy
214
216
  end
215
217
 
@@ -221,11 +223,9 @@ module Puppet
221
223
 
222
224
  # was the stat already specified, or should the value
223
225
  # be inherited from the source?
224
- unless @resource.argument?(stat)
225
- @resource[stat] = value
226
- end
226
+ @resource[stat] = value unless @resource.argument?(stat)
227
227
  }
228
-
228
+
229
229
  return @stats[:checksum]
230
230
  end
231
231
 
@@ -241,9 +241,7 @@ module Puppet
241
241
  checks.delete(:checksum)
242
242
 
243
243
  @resource[:check] = checks
244
- unless @resource.property(:checksum)
245
- @resource[:checksum] = :md5
246
- end
244
+ @resource[:checksum] = :md5 unless @resource.property(:checksum)
247
245
  end
248
246
 
249
247
  def sync
@@ -251,7 +249,7 @@ module Puppet
251
249
 
252
250
  exists = File.exists?(@resource[:path])
253
251
 
254
- @resource.write(:source) { |f| f.print contents }
252
+ @resource.write(contents, :source, @stats[:checksum])
255
253
 
256
254
  if exists
257
255
  return :file_changed
@@ -261,34 +259,22 @@ module Puppet
261
259
  end
262
260
 
263
261
  private
262
+
264
263
  def get_remote_content
265
- unless @stats[:type] == "file"
266
- #if @stats[:type] == "directory"
267
- #[@resource.name, @should.inspect]
268
- #end
269
- raise Puppet::DevError, "Got told to copy non-file %s" %
270
- @resource[:path]
271
- end
264
+ raise Puppet::DevError, "Got told to copy non-file %s" % @resource[:path] unless @stats[:type] == "file"
272
265
 
273
266
  sourceobj, path = @resource.uri2obj(@source)
274
267
 
275
268
  begin
276
269
  contents = sourceobj.server.retrieve(path, @resource[:links])
277
- rescue Puppet::Network::XMLRPCClientError => detail
278
- self.err "Could not retrieve %s: %s" %
279
- [path, detail]
280
- return nil
270
+ rescue => detail
271
+ self.fail "Could not retrieve %s: %s" % [path, detail]
281
272
  end
282
273
 
283
- # FIXME It's stupid that this isn't taken care of in the
284
- # protocol.
285
- unless sourceobj.server.local
286
- contents = CGI.unescape(contents)
287
- end
274
+ contents = CGI.unescape(contents) unless sourceobj.server.local
288
275
 
289
276
  if contents == ""
290
- self.notice "Could not retrieve contents for %s" %
291
- @source
277
+ self.notice "Could not retrieve contents for %s" % @source
292
278
  end
293
279
 
294
280
  return contents
File without changes
@@ -4,6 +4,13 @@ module Puppet
4
4
 
5
5
  newproperty(:ip) do
6
6
  desc "The host's IP address, IPv4 or IPv6."
7
+
8
+ validate do |value|
9
+ unless value =~ /((([0-9a-fA-F]+:){7}[0-9a-fA-F]+)|(([0-9a-fA-F]+:)*[0-9a-fA-F]+)?::(([0-9a-fA-F]+:)*[0-9a-fA-F]+)?)|((25[0-5]|2[0-4][\d]|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3})/
10
+ raise Puppet::Error, "Invalid IP address"
11
+ end
12
+ end
13
+
7
14
  end
8
15
 
9
16
  newproperty(:alias) do
@@ -78,6 +85,12 @@ module Puppet
78
85
  desc "The host name."
79
86
 
80
87
  isnamevar
88
+
89
+ validate do |value|
90
+ unless value =~ /^\w+-?[\w+]?\.?[\w+.{1}]*\w+$/
91
+ raise Puppet::Error, "Invalid host name"
92
+ end
93
+ end
81
94
  end
82
95
 
83
96
  @doc = "Installs and manages host entries. For most systems, these
@@ -9,7 +9,7 @@ module Puppet
9
9
  end
10
10
 
11
11
  newproperty(:recipient, :array_matching => :all) do
12
- desc "Where email should should be sent. Multiple values
12
+ desc "Where email should be sent. Multiple values
13
13
  should be specified as an array."
14
14
 
15
15
  def is_to_s(value)
@@ -0,0 +1,3 @@
1
+ require 'puppet/util/nagios_maker'
2
+
3
+ Puppet::Util::NagiosMaker.create_nagios_type :command
@@ -0,0 +1,3 @@
1
+ require 'puppet/util/nagios_maker'
2
+
3
+ Puppet::Util::NagiosMaker.create_nagios_type :contact
@@ -0,0 +1,3 @@
1
+ require 'puppet/util/nagios_maker'
2
+
3
+ Puppet::Util::NagiosMaker.create_nagios_type :contactgroup
@@ -0,0 +1,3 @@
1
+ require 'puppet/util/nagios_maker'
2
+
3
+ Puppet::Util::NagiosMaker.create_nagios_type :host
@@ -0,0 +1,3 @@
1
+ require 'puppet/util/nagios_maker'
2
+
3
+ Puppet::Util::NagiosMaker.create_nagios_type :hostextinfo
@@ -0,0 +1,3 @@
1
+ require 'puppet/util/nagios_maker'
2
+
3
+ Puppet::Util::NagiosMaker.create_nagios_type :hostgroup
@@ -0,0 +1,3 @@
1
+ require 'puppet/util/nagios_maker'
2
+
3
+ Puppet::Util::NagiosMaker.create_nagios_type :hostgroupescalation
@@ -0,0 +1,3 @@
1
+ require 'puppet/util/nagios_maker'
2
+
3
+ Puppet::Util::NagiosMaker.create_nagios_type :service
@@ -0,0 +1,3 @@
1
+ require 'puppet/util/nagios_maker'
2
+
3
+ Puppet::Util::NagiosMaker.create_nagios_type :servicedependency
@@ -0,0 +1,3 @@
1
+ require 'puppet/util/nagios_maker'
2
+
3
+ Puppet::Util::NagiosMaker.create_nagios_type :serviceescalation
@@ -0,0 +1,3 @@
1
+ require 'puppet/util/nagios_maker'
2
+
3
+ Puppet::Util::NagiosMaker.create_nagios_type :serviceextinfo
@@ -0,0 +1,3 @@
1
+ require 'puppet/util/nagios_maker'
2
+
3
+ Puppet::Util::NagiosMaker.create_nagios_type :timeperiod
@@ -176,7 +176,7 @@ module Puppet
176
176
  a common name to packages::
177
177
 
178
178
  # In the 'openssl' class
179
- $ssl = $operationgsystem ? {
179
+ $ssl = $operatingsystem ? {
180
180
  solaris => SMCossl,
181
181
  default => openssl
182
182
  }
@@ -190,7 +190,7 @@ module Puppet
190
190
 
191
191
  . etc. .
192
192
 
193
- $ssh = $operationgsystem ? {
193
+ $ssh = $operatingsystem ? {
194
194
  solaris => SMCossh,
195
195
  default => openssh
196
196
  }
@@ -200,7 +200,7 @@ module Puppet
200
200
  package { $ssh:
201
201
  ensure => installed,
202
202
  alias => openssh,
203
- require => package[openssl]
203
+ require => Package[openssl]
204
204
  }
205
205
 
206
206
  "
@@ -211,14 +211,6 @@ module Puppet
211
211
  desc "Where to find the actual package. This must be a local file
212
212
  (or on a network file system) or a URL that your specific
213
213
  packaging type understands; Puppet will not retrieve files for you."
214
-
215
- validate do |value|
216
- unless value =~ /^#{File::SEPARATOR}/ or value =~ /\w+:\/\//
217
- self.fail(
218
- "Package sources must be fully qualified files or URLs, depending on the platform."
219
- )
220
- end
221
- end
222
214
  end
223
215
  newparam(:instance) do
224
216
  desc "A read-only parameter set by the package."
@@ -248,7 +240,7 @@ module Puppet
248
240
 
249
241
  newparam(:responsefile) do
250
242
  desc "A file containing any necessary answers to questions asked by
251
- the package. This is currently only used on Solaris. The
243
+ the package. This is currently used on Solaris and Debian. The
252
244
  value will be validated according to system rules, but it should
253
245
  generally be a fully qualified path."
254
246
  end
@@ -28,6 +28,8 @@ module Puppet
28
28
  feature :enableable, "The provider can enable and disable the service",
29
29
  :methods => [:disable, :enable, :enabled?]
30
30
 
31
+ feature :controllable, "The provider uses a control variable."
32
+
31
33
  newproperty(:enable, :required_features => :enableable) do
32
34
  desc "Whether a service should be enabled to start at boot.
33
35
  This property behaves quite differently depending on the platform;
@@ -163,6 +165,13 @@ module Puppet
163
165
  desc "Specify a *stop* command manually."
164
166
  end
165
167
 
168
+ newparam(:control) do
169
+ desc "The control variable used to manage services (originally for HP-UX).
170
+ Defaults to the upcased service name plus ``START`` replacing dots with
171
+ underscores, for those providers that support the ``controllable`` feature."
172
+ defaultto { resource.name.gsub(".","_").upcase + "_START" if resource.provider.controllable? }
173
+ end
174
+
166
175
  newparam :hasrestart do
167
176
  desc "Specify that an init script has a ``restart`` option. Otherwise,
168
177
  the init script's ``stop`` and ``start`` methods are used."