puppet 3.0.2 → 3.1.0.rc1

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 (320) hide show
  1. data/Gemfile +13 -11
  2. data/README.md +9 -7
  3. data/README_DEVELOPER.md +21 -30
  4. data/bin/extlookup2hiera +0 -0
  5. data/conf/auth.conf +42 -26
  6. data/conf/fileserver.conf +41 -0
  7. data/conf/tagmail.conf +16 -0
  8. data/examples/hiera/modules/data/manifests/common.pp +2 -1
  9. data/examples/hiera/modules/ntp/manifests/config.pp +4 -3
  10. data/examples/hiera/modules/ntp/manifests/data.pp +2 -1
  11. data/examples/hiera/modules/users/manifests/common.pp +2 -1
  12. data/examples/hiera/modules/users/manifests/dc1.pp +2 -1
  13. data/examples/hiera/modules/users/manifests/development.pp +2 -1
  14. data/examples/hiera/site.pp +1 -1
  15. data/ext/debian/fileserver.conf +39 -15
  16. data/ext/envpuppet +2 -0
  17. data/ext/gentoo/puppet/fileserver.conf +41 -12
  18. data/ext/ips/puppet-agent +1 -6
  19. data/ext/ips/puppetagent.xml +0 -4
  20. data/ext/osx/postflight.erb +109 -0
  21. data/ext/project_data.yaml +2 -2
  22. data/ext/redhat/fileserver.conf +41 -12
  23. data/ext/redhat/puppet.spec.erb +8 -13
  24. data/install.rb +2 -5
  25. data/lib/puppet.rb +30 -13
  26. data/lib/puppet/application.rb +34 -16
  27. data/lib/puppet/application/agent.rb +4 -4
  28. data/lib/puppet/application/master.rb +25 -5
  29. data/lib/puppet/defaults.rb +11 -7
  30. data/lib/puppet/dsl.rb +7 -3
  31. data/lib/puppet/dsl/actions.rb +283 -0
  32. data/lib/puppet/dsl/blank_slate.rb +55 -0
  33. data/lib/puppet/dsl/context.rb +393 -0
  34. data/lib/puppet/dsl/parser.rb +57 -0
  35. data/lib/puppet/dsl/resource_decorator.rb +56 -0
  36. data/lib/puppet/dsl/resource_reference.rb +95 -0
  37. data/lib/puppet/dsl/type_reference.rb +102 -0
  38. data/lib/puppet/error.rb +1 -1
  39. data/lib/puppet/face/help.rb +2 -4
  40. data/lib/puppet/face/man.rb +8 -2
  41. data/lib/puppet/feature/pson.rb +1 -3
  42. data/lib/puppet/indirector/catalog/active_record.rb +3 -0
  43. data/lib/puppet/indirector/catalog/compiler.rb +1 -2
  44. data/lib/puppet/indirector/catalog/queue.rb +4 -0
  45. data/lib/puppet/indirector/catalog/static_compiler.rb +30 -0
  46. data/lib/puppet/indirector/catalog/store_configs.rb +3 -0
  47. data/lib/puppet/indirector/certificate_request/rest.rb +1 -0
  48. data/lib/puppet/indirector/certificate_revocation_list/rest.rb +1 -0
  49. data/lib/puppet/indirector/certificate_status/file.rb +4 -0
  50. data/lib/puppet/indirector/certificate_status/rest.rb +1 -0
  51. data/lib/puppet/indirector/facts/active_record.rb +3 -0
  52. data/lib/puppet/indirector/facts/couch.rb +3 -0
  53. data/lib/puppet/indirector/facts/inventory_active_record.rb +4 -0
  54. data/lib/puppet/indirector/facts/store_configs.rb +3 -0
  55. data/lib/puppet/indirector/file_metadata/rest.rb +2 -0
  56. data/lib/puppet/indirector/instrumentation_data/local.rb +3 -0
  57. data/lib/puppet/indirector/instrumentation_data/rest.rb +3 -0
  58. data/lib/puppet/indirector/instrumentation_listener/local.rb +3 -0
  59. data/lib/puppet/indirector/instrumentation_listener/rest.rb +3 -0
  60. data/lib/puppet/indirector/instrumentation_probe/local.rb +3 -0
  61. data/lib/puppet/indirector/instrumentation_probe/rest.rb +3 -0
  62. data/lib/puppet/indirector/node/active_record.rb +3 -0
  63. data/lib/puppet/indirector/node/rest.rb +2 -2
  64. data/lib/puppet/indirector/node/store_configs.rb +3 -0
  65. data/lib/puppet/indirector/node/write_only_yaml.rb +32 -0
  66. data/lib/puppet/indirector/queue.rb +0 -1
  67. data/lib/puppet/indirector/request.rb +1 -2
  68. data/lib/puppet/indirector/resource/active_record.rb +4 -0
  69. data/lib/puppet/indirector/resource/ral.rb +3 -0
  70. data/lib/puppet/indirector/resource/rest.rb +3 -0
  71. data/lib/puppet/indirector/resource/store_configs.rb +3 -0
  72. data/lib/puppet/indirector/run/local.rb +3 -0
  73. data/lib/puppet/indirector/ssl_file.rb +16 -14
  74. data/lib/puppet/indirector/status/local.rb +3 -0
  75. data/lib/puppet/indirector/status/rest.rb +4 -0
  76. data/lib/puppet/interface.rb +78 -3
  77. data/lib/puppet/interface/action.rb +39 -3
  78. data/lib/puppet/interface/action_builder.rb +74 -1
  79. data/lib/puppet/interface/action_manager.rb +33 -3
  80. data/lib/puppet/interface/documentation.rb +116 -5
  81. data/lib/puppet/interface/face_collection.rb +6 -7
  82. data/lib/puppet/interface/option.rb +10 -1
  83. data/lib/puppet/interface/option_builder.rb +29 -1
  84. data/lib/puppet/interface/option_manager.rb +21 -6
  85. data/lib/puppet/metatype/manager.rb +47 -9
  86. data/lib/puppet/module_tool.rb +0 -1
  87. data/lib/puppet/network/formats.rb +0 -2
  88. data/lib/puppet/node.rb +2 -3
  89. data/lib/puppet/node/environment.rb +14 -1
  90. data/lib/puppet/parameter.rb +309 -44
  91. data/lib/puppet/parameter/package_options.rb +5 -0
  92. data/lib/puppet/parameter/path.rb +26 -3
  93. data/lib/puppet/parameter/value.rb +30 -6
  94. data/lib/puppet/parameter/value_collection.rb +82 -20
  95. data/lib/puppet/parser.rb +3 -0
  96. data/lib/puppet/parser/ast/definition.rb +2 -5
  97. data/lib/puppet/parser/ast/hostclass.rb +2 -3
  98. data/lib/puppet/parser/ast/node.rb +2 -5
  99. data/lib/puppet/parser/ast/resourceparam.rb +1 -1
  100. data/lib/puppet/parser/compiler.rb +10 -0
  101. data/lib/puppet/parser/functions.rb +111 -7
  102. data/lib/puppet/parser/functions/create_resources.rb +23 -2
  103. data/lib/puppet/parser/functions/defined.rb +1 -1
  104. data/lib/puppet/parser/functions/extlookup.rb +2 -1
  105. data/lib/puppet/parser/functions/fail.rb +1 -1
  106. data/lib/puppet/parser/functions/file.rb +1 -1
  107. data/lib/puppet/parser/functions/fqdn_rand.rb +1 -1
  108. data/lib/puppet/parser/functions/generate.rb +1 -1
  109. data/lib/puppet/parser/functions/hiera.rb +1 -1
  110. data/lib/puppet/parser/functions/hiera_array.rb +1 -1
  111. data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
  112. data/lib/puppet/parser/functions/hiera_include.rb +1 -1
  113. data/lib/puppet/parser/functions/include.rb +1 -1
  114. data/lib/puppet/parser/functions/inline_template.rb +1 -1
  115. data/lib/puppet/parser/functions/md5.rb +1 -1
  116. data/lib/puppet/parser/functions/realize.rb +1 -1
  117. data/lib/puppet/parser/functions/regsubst.rb +54 -57
  118. data/lib/puppet/parser/functions/require.rb +1 -0
  119. data/lib/puppet/parser/functions/search.rb +1 -1
  120. data/lib/puppet/parser/functions/sha1.rb +1 -1
  121. data/lib/puppet/parser/functions/shellquote.rb +1 -1
  122. data/lib/puppet/parser/functions/split.rb +1 -2
  123. data/lib/puppet/parser/functions/sprintf.rb +7 -10
  124. data/lib/puppet/parser/functions/tag.rb +1 -1
  125. data/lib/puppet/parser/functions/tagged.rb +1 -1
  126. data/lib/puppet/parser/functions/template.rb +1 -1
  127. data/lib/puppet/parser/functions/versioncmp.rb +1 -5
  128. data/lib/puppet/parser/parser_support.rb +11 -27
  129. data/lib/puppet/parser/scope.rb +48 -4
  130. data/lib/puppet/parser/type_loader.rb +31 -7
  131. data/lib/puppet/property.rb +304 -70
  132. data/lib/puppet/property/ensure.rb +14 -1
  133. data/lib/puppet/property/keyvalue.rb +17 -8
  134. data/lib/puppet/property/list.rb +3 -0
  135. data/lib/puppet/property/ordered_list.rb +7 -0
  136. data/lib/puppet/provider.rb +275 -53
  137. data/lib/puppet/provider/augeas/augeas.rb +17 -3
  138. data/lib/puppet/provider/confiner.rb +30 -1
  139. data/lib/puppet/provider/group/pw.rb +2 -2
  140. data/lib/puppet/provider/package/pip.rb +0 -1
  141. data/lib/puppet/provider/package/pkgin.rb +2 -0
  142. data/lib/puppet/provider/service/bsd.rb +1 -1
  143. data/lib/puppet/provider/service/freebsd.rb +10 -6
  144. data/lib/puppet/provider/service/init.rb +1 -1
  145. data/lib/puppet/provider/service/service.rb +1 -1
  146. data/lib/puppet/provider/user/pw.rb +2 -2
  147. data/lib/puppet/provider/user/useradd.rb +2 -3
  148. data/lib/puppet/reference/configuration.rb +6 -0
  149. data/lib/puppet/reports.rb +44 -4
  150. data/lib/puppet/reports/tagmail.rb +1 -1
  151. data/lib/puppet/resource.rb +38 -25
  152. data/lib/puppet/resource/type.rb +14 -6
  153. data/lib/puppet/settings.rb +66 -142
  154. data/lib/puppet/settings/config_file.rb +99 -0
  155. data/lib/puppet/settings/file_setting.rb +92 -24
  156. data/lib/puppet/settings/value_translator.rb +15 -0
  157. data/lib/puppet/ssl/certificate_authority/interface.rb +2 -2
  158. data/lib/puppet/test/test_helper.rb +8 -3
  159. data/lib/puppet/transaction.rb +1 -2
  160. data/lib/puppet/transaction/report.rb +122 -13
  161. data/lib/puppet/type.rb +763 -150
  162. data/lib/puppet/type/augeas.rb +4 -0
  163. data/lib/puppet/type/file/ensure.rb +1 -1
  164. data/lib/puppet/type/file/group.rb +1 -1
  165. data/lib/puppet/type/file/mode.rb +2 -0
  166. data/lib/puppet/type/file/selcontext.rb +1 -0
  167. data/lib/puppet/type/group.rb +12 -0
  168. data/lib/puppet/type/mount.rb +2 -2
  169. data/lib/puppet/type/notify.rb +1 -1
  170. data/lib/puppet/type/router.rb +1 -1
  171. data/lib/puppet/type/service.rb +1 -0
  172. data/lib/puppet/type/ssh_authorized_key.rb +3 -1
  173. data/lib/puppet/type/user.rb +8 -1
  174. data/lib/puppet/util.rb +8 -0
  175. data/lib/puppet/util/autoload.rb +7 -10
  176. data/lib/puppet/util/classgen.rb +58 -33
  177. data/lib/puppet/util/command_line.rb +120 -77
  178. data/lib/puppet/util/constant_inflector.rb +2 -0
  179. data/lib/puppet/util/execution.rb +63 -33
  180. data/lib/puppet/util/filetype.rb +1 -1
  181. data/lib/puppet/util/manifest_filetype_helper.rb +22 -0
  182. data/lib/puppet/util/methodhelper.rb +19 -0
  183. data/lib/puppet/util/monkey_patches.rb +46 -0
  184. data/lib/puppet/util/plugins.rb +2 -2
  185. data/lib/puppet/util/provider_features.rb +24 -8
  186. data/lib/puppet/util/rubygems.rb +8 -1
  187. data/lib/puppet/util/zaml.rb +1 -1
  188. data/lib/puppet/version.rb +74 -3
  189. data/spec/integration/application/apply_spec.rb +1 -1
  190. data/spec/integration/defaults_spec.rb +1 -0
  191. data/spec/integration/dsl/classes_spec.rb +191 -0
  192. data/spec/integration/dsl/defaults_spec.rb +38 -0
  193. data/spec/integration/dsl/definitions_spec.rb +73 -0
  194. data/spec/integration/dsl/functions_spec.rb +95 -0
  195. data/spec/integration/dsl/nodes_spec.rb +96 -0
  196. data/spec/integration/dsl/params_spec.rb +146 -0
  197. data/spec/integration/dsl/relationships_spec.rb +46 -0
  198. data/spec/integration/dsl/resources_spec.rb +202 -0
  199. data/spec/integration/dsl/type_loading_spec.rb +64 -0
  200. data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
  201. data/spec/integration/network/formats_spec.rb +32 -45
  202. data/spec/integration/parser/collector_spec.rb +105 -25
  203. data/spec/integration/parser/scope_spec.rb +64 -1
  204. data/spec/integration/resource/catalog_spec.rb +2 -4
  205. data/spec/integration/type/package_spec.rb +1 -1
  206. data/spec/lib/matchers/catalog.rb +50 -0
  207. data/spec/lib/puppet_spec/compiler.rb +11 -0
  208. data/spec/lib/puppet_spec/dsl.rb +29 -0
  209. data/spec/spec_helper.rb +17 -3
  210. data/spec/unit/application/agent_spec.rb +0 -1
  211. data/spec/unit/application/apply_spec.rb +1 -1
  212. data/spec/unit/application/face_base_spec.rb +11 -4
  213. data/spec/unit/application/indirection_base_spec.rb +4 -8
  214. data/spec/unit/application/kick_spec.rb +5 -2
  215. data/spec/unit/application/master_spec.rb +0 -6
  216. data/spec/unit/application_spec.rb +38 -14
  217. data/spec/unit/dsl/actions_spec.rb +402 -0
  218. data/spec/unit/dsl/blank_slate_spec.rb +27 -0
  219. data/spec/unit/dsl/context_spec.rb +678 -0
  220. data/spec/unit/dsl/parser_spec.rb +56 -0
  221. data/spec/unit/dsl/resource_decorator_spec.rb +94 -0
  222. data/spec/unit/dsl/resource_reference_spec.rb +150 -0
  223. data/spec/unit/dsl/type_reference_spec.rb +164 -0
  224. data/spec/unit/face/help_spec.rb +5 -7
  225. data/spec/unit/indirector/certificate_request/rest_spec.rb +4 -0
  226. data/spec/unit/indirector/certificate_revocation_list/rest_spec.rb +4 -0
  227. data/spec/unit/indirector/certificate_status/rest_spec.rb +4 -0
  228. data/spec/unit/indirector/file_metadata/rest_spec.rb +5 -0
  229. data/spec/unit/indirector/hiera_spec.rb +3 -1
  230. data/spec/unit/indirector/queue_spec.rb +1 -7
  231. data/spec/unit/indirector/ssl_file_spec.rb +66 -39
  232. data/spec/unit/module_spec.rb +1 -1
  233. data/spec/unit/network/authstore_spec.rb +22 -1
  234. data/spec/unit/network/formats_spec.rb +1 -1
  235. data/spec/unit/node/environment_spec.rb +13 -0
  236. data/spec/unit/parser/collector_spec.rb +1 -1
  237. data/spec/unit/parser/compiler_spec.rb +26 -0
  238. data/spec/unit/parser/functions/create_resources_spec.rb +12 -1
  239. data/spec/unit/parser/functions/extlookup_spec.rb +4 -4
  240. data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
  241. data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
  242. data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
  243. data/spec/unit/parser/functions/hiera_spec.rb +1 -1
  244. data/spec/unit/parser/functions/regsubst_spec.rb +4 -4
  245. data/spec/unit/parser/functions/split_spec.rb +4 -4
  246. data/spec/unit/parser/functions/sprintf_spec.rb +2 -2
  247. data/spec/unit/parser/functions/versioncmp_spec.rb +4 -4
  248. data/spec/unit/parser/functions_spec.rb +51 -1
  249. data/spec/unit/parser/parser_spec.rb +0 -14
  250. data/spec/unit/parser/type_loader_spec.rb +15 -1
  251. data/spec/unit/provider/augeas/augeas_spec.rb +31 -0
  252. data/spec/unit/provider/package/apt_spec.rb +0 -2
  253. data/spec/unit/provider/package/pip_spec.rb +12 -2
  254. data/spec/unit/provider/service/freebsd_spec.rb +8 -0
  255. data/spec/unit/provider/service/gentoo_spec.rb +20 -20
  256. data/spec/unit/provider/service/openrc_spec.rb +20 -20
  257. data/spec/unit/provider/service/src_spec.rb +4 -4
  258. data/spec/unit/provider/service/systemd_spec.rb +0 -8
  259. data/spec/unit/provider/service/windows_spec.rb +1 -1
  260. data/spec/unit/provider/user/useradd_spec.rb +2 -9
  261. data/spec/unit/relationship_spec.rb +2 -2
  262. data/spec/unit/resource/catalog_spec.rb +2 -2
  263. data/spec/unit/resource/type_spec.rb +49 -25
  264. data/spec/unit/resource_spec.rb +34 -2
  265. data/spec/unit/settings/config_file_spec.rb +100 -0
  266. data/spec/unit/settings/file_setting_spec.rb +87 -84
  267. data/spec/unit/settings/value_translator_spec.rb +77 -0
  268. data/spec/unit/settings_spec.rb +96 -29
  269. data/spec/unit/type/file/ensure_spec.rb +75 -36
  270. data/spec/unit/type/file_spec.rb +0 -68
  271. data/spec/unit/type/group_spec.rb +10 -0
  272. data/spec/unit/util/autoload_spec.rb +6 -0
  273. data/spec/unit/util/command_line_spec.rb +54 -62
  274. data/spec/unit/util/manifest_filetype_helper_spec.rb +29 -0
  275. data/spec/unit/util/metric_spec.rb +0 -9
  276. data/spec/unit/util/posix_spec.rb +0 -4
  277. data/spec/unit/util/rdoc_spec.rb +0 -12
  278. data/spec/unit/util/zaml_spec.rb +188 -130
  279. data/spec/unit/version_spec.rb +42 -0
  280. metadata +123 -90
  281. data/README_HIERA.md +0 -148
  282. data/conf/epm.list +0 -8
  283. data/conf/namespaceauth.conf +0 -20
  284. data/conf/puppet-queue.conf +0 -10
  285. data/examples/allatonce +0 -13
  286. data/examples/assignments +0 -11
  287. data/examples/components +0 -73
  288. data/examples/etc/init.d/sleeper +0 -70
  289. data/examples/etc/otherfile +0 -0
  290. data/examples/etc/puppet/fileserver.conf +0 -13
  291. data/examples/etc/puppet/namespaceauth.conf +0 -20
  292. data/examples/etc/puppet/puppet.conf +0 -10
  293. data/examples/etc/puppet/tagmail.conf +0 -1
  294. data/examples/execs +0 -16
  295. data/examples/file.bl +0 -11
  296. data/examples/filedefaults +0 -10
  297. data/examples/fileparsing +0 -116
  298. data/examples/filerecursion +0 -15
  299. data/examples/functions +0 -3
  300. data/examples/groups +0 -7
  301. data/examples/head +0 -30
  302. data/examples/importing +0 -8
  303. data/examples/mac_dscl.pp +0 -28
  304. data/examples/mac_dscl_revert.pp +0 -26
  305. data/examples/mac_pkgdmg.pp +0 -7
  306. data/examples/modules/sample_module.pp +0 -10
  307. data/examples/modules/sample_module/lib/puppet/parser/functions/hostname_to_dn.rb +0 -36
  308. data/examples/modules/sample_module/manifests/init.pp +0 -12
  309. data/examples/modules/sample_module/templates/sample.erb +0 -5
  310. data/examples/nodes +0 -20
  311. data/examples/one +0 -8
  312. data/examples/relationships +0 -34
  313. data/examples/selectors +0 -28
  314. data/examples/simpletests +0 -11
  315. data/examples/svncommit +0 -13
  316. data/lib/puppet/dsl/resource_api.rb +0 -120
  317. data/lib/puppet/dsl/resource_type_api.rb +0 -34
  318. data/spec/integration/parser/ruby_manifest_spec.rb +0 -127
  319. data/spec/unit/dsl/resource_api_spec.rb +0 -180
  320. data/spec/unit/dsl/resource_type_api_spec.rb +0 -53
@@ -38,6 +38,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do
38
38
  "setm" => [ :path, :string, :string ],
39
39
  "rm" => [ :path ],
40
40
  "clear" => [ :path ],
41
+ "clearm" => [ :path, :string ],
41
42
  "mv" => [ :path, :path ],
42
43
  "insert" => [ :string, :string, :path ],
43
44
  "get" => [ :path, :comparator, :string ],
@@ -431,9 +432,13 @@ Puppet::Type.type(:augeas).provide(:augeas) do
431
432
  rv = aug.set(cmd_array[0], cmd_array[1])
432
433
  fail("Error sending command '#{command}' with params #{cmd_array.inspect}") if (!rv)
433
434
  when "setm"
434
- debug("sending command '#{command}' with params #{cmd_array.inspect}")
435
- rv = aug.setm(cmd_array[0], cmd_array[1], cmd_array[2])
436
- fail("Error sending command '#{command}' with params #{cmd_array.inspect}") if (rv == -1)
435
+ if aug.respond_to?(command)
436
+ debug("sending command '#{command}' with params #{cmd_array.inspect}")
437
+ rv = aug.setm(cmd_array[0], cmd_array[1], cmd_array[2])
438
+ fail("Error sending command '#{command}' with params #{cmd_array.inspect}") if (rv == -1)
439
+ else
440
+ fail("command '#{command}' not supported in installed version of ruby-augeas")
441
+ end
437
442
  when "rm", "remove"
438
443
  debug("sending command '#{command}' with params #{cmd_array.inspect}")
439
444
  rv = aug.rm(cmd_array[0])
@@ -442,6 +447,15 @@ Puppet::Type.type(:augeas).provide(:augeas) do
442
447
  debug("sending command '#{command}' with params #{cmd_array.inspect}")
443
448
  rv = aug.clear(cmd_array[0])
444
449
  fail("Error sending command '#{command}' with params #{cmd_array.inspect}") if (!rv)
450
+ when "clearm"
451
+ # Check command exists ... doesn't currently in ruby-augeas 0.4.1
452
+ if aug.respond_to?(command)
453
+ debug("sending command '#{command}' with params #{cmd_array.inspect}")
454
+ rv = aug.clearm(cmd_array[0], cmd_array[1])
455
+ fail("Error sending command '#{command}' with params #{cmd_array.inspect}") if (!rv)
456
+ else
457
+ fail("command '#{command}' not supported in installed version of ruby-augeas")
458
+ end
445
459
  when "insert", "ins"
446
460
  label = cmd_array[0]
447
461
  where = cmd_array[1]
@@ -1,15 +1,44 @@
1
1
  require 'puppet/provider/confine_collection'
2
2
 
3
+ # The Confiner module contains methods for managing a Provider's confinement (suitability under given
4
+ # conditions). The intent is to include this module in an object where confinement management is wanted.
5
+ # It lazily adds an instance variable `@confine_collection` to the object where it is included.
6
+ #
3
7
  module Puppet::Provider::Confiner
8
+ # Confines a provider to be suitable only under the given conditions.
9
+ # The hash describes a confine using mapping from symbols to values or predicate code.
10
+ #
11
+ # * _fact_name_ => value of fact (or array of facts)
12
+ # * `:exists` => the path to an existing file
13
+ # * `:true` => a predicate code block returning true
14
+ # * `:false` => a predicate code block returning false
15
+ # * `:feature` => name of system feature that must be present
16
+ #
17
+ # @example
18
+ # confine :operatingsystem => [:redhat, :fedora]
19
+ # confine :true { ... }
20
+ #
21
+ # @param hash [Hash<{Symbol => Object}>] hash of confines
22
+ # @return [void]
23
+ # @api public
24
+ #
4
25
  def confine(hash)
5
26
  confine_collection.confine(hash)
6
27
  end
7
28
 
29
+ # @return [Puppet::Provider::ConfineCollection] the collection of confines
30
+ # @api private
31
+ #
8
32
  def confine_collection
9
33
  @confine_collection ||= Puppet::Provider::ConfineCollection.new(self.to_s)
10
34
  end
11
35
 
12
- # Check whether this implementation is suitable for our platform.
36
+ # Checks whether this implementation is suitable for the current platform (or returns a summary
37
+ # of all confines if short == false).
38
+ # @return [Boolean. Hash] Returns whether the confines are all valid (if short == true), or a hash of all confines
39
+ # if short == false.
40
+ # @api public
41
+ #
13
42
  def suitable?(short = true)
14
43
  return(short ? confine_collection.valid? : confine_collection.summary)
15
44
  end
@@ -1,12 +1,12 @@
1
1
  require 'puppet/provider/nameservice/pw'
2
2
 
3
3
  Puppet::Type.type(:group).provide :pw, :parent => Puppet::Provider::NameService::PW do
4
- desc "Group management via `pw` on FreeBSD."
4
+ desc "Group management via `pw` on FreeBSD and DragonFly BSD."
5
5
 
6
6
  commands :pw => "pw"
7
7
  has_features :manages_members
8
8
 
9
- defaultfor :operatingsystem => :freebsd
9
+ defaultfor :operatingsystem => [:freebsd, :dragonfly]
10
10
 
11
11
  options :members, :flag => "-M", :method => :mem
12
12
 
@@ -64,7 +64,6 @@ Puppet::Type.type(:package).provide :pip,
64
64
  def install
65
65
  args = %w{install -q}
66
66
  if @resource[:source]
67
- args << "-e"
68
67
  if String === @resource[:ensure]
69
68
  args << "#{@resource[:source]}@#{@resource[:ensure]}#egg=#{
70
69
  @resource[:name]}"
@@ -5,6 +5,8 @@ Puppet::Type.type(:package).provide :pkgin, :parent => Puppet::Provider::Package
5
5
 
6
6
  commands :pkgin => "pkgin"
7
7
 
8
+ defaultfor :operatingsystem => :dragonfly
9
+
8
10
  has_feature :installable, :uninstallable
9
11
 
10
12
  def self.parse_pkgin_line(package, force_status=nil)
@@ -7,7 +7,7 @@ Puppet::Type.type(:service).provide :bsd, :parent => :init do
7
7
 
8
8
  EOT
9
9
 
10
- confine :operatingsystem => [:freebsd, :netbsd, :openbsd]
10
+ confine :operatingsystem => [:freebsd, :netbsd, :openbsd, :dragonfly]
11
11
 
12
12
  def rcconf_dir
13
13
  '/etc/rc.conf.d'
@@ -1,9 +1,9 @@
1
1
  Puppet::Type.type(:service).provide :freebsd, :parent => :init do
2
2
 
3
- desc "Provider for FreeBSD. Uses the `rcvar` argument of init scripts and parses/edits rc files."
3
+ desc "Provider for FreeBSD and DragonFly BSD. Uses the `rcvar` argument of init scripts and parses/edits rc files."
4
4
 
5
- confine :operatingsystem => [:freebsd]
6
- defaultfor :operatingsystem => [:freebsd]
5
+ confine :operatingsystem => [:freebsd, :dragonfly]
6
+ defaultfor :operatingsystem => [:freebsd, :dragonfly]
7
7
 
8
8
  def rcconf() '/etc/rc.conf' end
9
9
  def rcconf_local() '/etc/rc.conf.local' end
@@ -13,6 +13,10 @@ Puppet::Type.type(:service).provide :freebsd, :parent => :init do
13
13
  superclass.defpath
14
14
  end
15
15
 
16
+ def error(msg)
17
+ raise Puppet::Error, msg
18
+ end
19
+
16
20
  # Executing an init script with the 'rcvar' argument returns
17
21
  # the service name, rcvar name and whether it's enabled/disabled
18
22
  def rcvar
@@ -37,7 +41,7 @@ Puppet::Type.type(:service).provide :freebsd, :parent => :init do
37
41
  def rcvar_name
38
42
  name = self.rcvar[1]
39
43
  self.error("No rcvar name found in rcvar") if name.nil?
40
- name = name.gsub!(/(.*)_enable=(.*)/, '\1')
44
+ name = name.gsub!(/(.*)(_enable)?=(.*)/, '\1')
41
45
  self.error("rcvar name is empty") if name.nil?
42
46
  self.debug("rcvar name is #{name}")
43
47
  name
@@ -47,7 +51,7 @@ Puppet::Type.type(:service).provide :freebsd, :parent => :init do
47
51
  def rcvar_value
48
52
  value = self.rcvar[1]
49
53
  self.error("No rcvar value found in rcvar") if value.nil?
50
- value = value.gsub!(/(.*)_enable="?(\w+)"?/, '\2')
54
+ value = value.gsub!(/(.*)(_enable)?="?(\w+)"?/, '\3')
51
55
  self.error("rcvar value is empty") if value.nil?
52
56
  self.debug("rcvar value is #{value}")
53
57
  value
@@ -69,7 +73,7 @@ Puppet::Type.type(:service).provide :freebsd, :parent => :init do
69
73
  [rcconf, rcconf_local, rcconf_dir + "/#{service}"].each do |filename|
70
74
  if File.exists?(filename)
71
75
  s = File.read(filename)
72
- if s.gsub!(/(#{rcvar}_enable)=\"?(YES|NO)\"?/, "\\1=\"#{yesno}\"")
76
+ if s.gsub!(/(#{rcvar}(_enable)?)=\"?(YES|NO)\"?/, "\\1=\"#{yesno}\"")
73
77
  File.open(filename, File::WRONLY) { |f| f << s }
74
78
  self.debug("Replaced in #{filename}")
75
79
  success = true
@@ -5,7 +5,7 @@ Puppet::Type.type(:service).provide :init, :parent => :base do
5
5
 
6
6
  def self.defpath
7
7
  case Facter.value(:operatingsystem)
8
- when "FreeBSD"
8
+ when "FreeBSD", "DragonFly"
9
9
  ["/etc/rc.d", "/usr/local/etc/rc.d"]
10
10
  when "HP-UX"
11
11
  "/sbin/init.d"
@@ -23,7 +23,7 @@ Puppet::Type.type(:service).provide :service do
23
23
  def texecute(type, command, fof = true)
24
24
  begin
25
25
  # #565: Services generally produce no output, so squelch them.
26
- execute(command, :failonfail => fof, :squelch => true)
26
+ execute(command, :failonfail => fof, :override_locale => false, :squelch => true)
27
27
  rescue Puppet::ExecutionFailure => detail
28
28
  @resource.fail "Could not #{type} #{@resource.ref}: #{detail}"
29
29
  end
@@ -2,12 +2,12 @@ require 'puppet/provider/nameservice/pw'
2
2
  require 'open3'
3
3
 
4
4
  Puppet::Type.type(:user).provide :pw, :parent => Puppet::Provider::NameService::PW do
5
- desc "User management via `pw` on FreeBSD."
5
+ desc "User management via `pw` on FreeBSD and DragonFly BSD."
6
6
 
7
7
  commands :pw => "pw"
8
8
  has_features :manages_homedir, :allows_duplicates, :manages_passwords, :manages_expiry
9
9
 
10
- defaultfor :operatingsystem => :freebsd
10
+ defaultfor :operatingsystem => [:freebsd, :dragonfly]
11
11
 
12
12
  options :home, :flag => "-d", :method => :dir
13
13
  options :comment, :method => :gecos
@@ -34,7 +34,7 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
34
34
  cmd = []
35
35
  if @resource.managehome?
36
36
  cmd << "-m"
37
- elsif %w{Fedora RedHat CentOS OEL OVS}.include?(Facter.value(:operatingsystem))
37
+ elsif Facter.value(:osfamily) == 'RedHat'
38
38
  cmd << "-M"
39
39
  end
40
40
  cmd
@@ -80,7 +80,7 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
80
80
  cmd += check_system_users
81
81
  cmd << @resource[:name]
82
82
  end
83
-
83
+
84
84
  def deletecmd
85
85
  cmd = [command(:delete)]
86
86
  cmd += @resource.managehome? ? ['-r'] : []
@@ -124,4 +124,3 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
124
124
  :absent
125
125
  end
126
126
  end
127
-
@@ -53,6 +53,12 @@ config.header = <<EOT
53
53
  * Multiple values should be specified as comma-separated lists; multiple
54
54
  directories should be separated with the system path separator (usually
55
55
  a colon).
56
+ * Settings that represent time intervals should be specified in duration format:
57
+ an integer immediately followed by one of the units 'y' (years of 365 days),
58
+ 'd' (days), 'h' (hours), 'm' (minutes), or 's' (seconds). The unit cannot be
59
+ combined with other units, and defaults to seconds when omitted. Examples are
60
+ '3600' which is equivalent to '1h' (one hour), and '1825d' which is equivalent
61
+ to '5y' (5 years).
56
62
  * Settings that take a single file or directory can optionally set the owner,
57
63
  group, and mode for their value: `rundir = $vardir/run { owner = puppet,
58
64
  group = puppet, mode = 644 }`
@@ -1,6 +1,32 @@
1
1
  require 'puppet/util/instance_loader'
2
2
 
3
- # A simple mechanism for loading and returning reports.
3
+ # This class is an implementation of a simple mechanism for loading and returning reports.
4
+ # The intent is that a user registers a report by calling {register_report} and providing a code
5
+ # block that performs setup, and defines a method called `process`. The setup, and the `process` method
6
+ # are called in the context where `self` is an instance of {Puppet::Transaction::Report} which provides the actual
7
+ # data for the report via its methods.
8
+ #
9
+ # @example Minimal scaffolding for a report...
10
+ # Puppet::Reports::.register_report(:myreport) do
11
+ # # do setup here
12
+ # def process
13
+ # if self.status == 'failed'
14
+ # msg = "failed puppet run for #{self.host} #{self.status}"
15
+ # . . .
16
+ # else
17
+ # . . .
18
+ # end
19
+ # end
20
+ # end
21
+ #
22
+ # Required configuration:
23
+ # --
24
+ # * A .rb file that defines a new report should be placed in the master's directory `lib/puppet/reports`
25
+ # * The `puppet.conf` file must have `report = true` in the `[agent]` section
26
+ #
27
+ # @see Puppet::Transaction::Report
28
+ # @api public
29
+ #
4
30
  class Puppet::Reports
5
31
  extend Puppet::Util::ClassGen
6
32
  extend Puppet::Util::InstanceLoader
@@ -9,10 +35,22 @@ class Puppet::Reports
9
35
  instance_load :report, 'puppet/reports'
10
36
 
11
37
  class << self
38
+ # @api private
12
39
  attr_reader :hooks
13
40
  end
14
41
 
15
- # Add a new report type.
42
+ # Adds a new report type.
43
+ # The block should contain setup, and define a method with the name `process`. The `process` method is
44
+ # called when the report is executed; the `process` method has access to report data via methods available
45
+ # in its context where `self` is an instance of {Puppet::Transaction::Report}.
46
+ #
47
+ # For an example, see the overview of this class.
48
+ #
49
+ # @param name [Symbol] the name of the report (do not use whitespace in the name).
50
+ # @param options [Hash] a hash of options
51
+ # @option options [Boolean] :useyaml whether yaml should be used or not
52
+ # @todo Uncertain what the options :useyaml really does; "whether yaml should be used or not", used where/how?
53
+ #
16
54
  def self.register_report(name, options = {}, &block)
17
55
  name = name.intern
18
56
 
@@ -25,7 +63,8 @@ class Puppet::Reports
25
63
  end
26
64
  end
27
65
 
28
- # Collect the docs for all of our reports.
66
+ # Collects the docs for all reports.
67
+ # @api private
29
68
  def self.reportdocs
30
69
  docs = ""
31
70
 
@@ -41,7 +80,8 @@ class Puppet::Reports
41
80
  docs
42
81
  end
43
82
 
44
- # List each of the reports.
83
+ # Lists each of the reports.
84
+ # @api private
45
85
  def self.reports
46
86
  instance_loader(:report).loadall
47
87
  loaded_instances(:report)
@@ -35,7 +35,7 @@ Puppet::Reports.register_report(:tagmail) do
35
35
 
36
36
  If you are using anti-spam controls such as grey-listing on your mail
37
37
  server, you should whitelist the sending email address (controlled by
38
- `reportform` configuration option) to ensure your email is not discarded as spam.
38
+ `reportfrom` configuration option) to ensure your email is not discarded as spam.
39
39
  "
40
40
 
41
41
  # Find all matching messages.
@@ -90,6 +90,34 @@ class Puppet::Resource
90
90
  end
91
91
  end
92
92
 
93
+ def self.canonicalize_type(type)
94
+ type, _ = get_type_and_title type, ""
95
+ type
96
+ end
97
+
98
+ def self.get_type_and_title(type, title)
99
+ type, title = extract_type_and_title(type, title)
100
+ [munge_type_name(type), title]
101
+ end
102
+
103
+ def self.extract_type_and_title(argtype, argtitle)
104
+ if (argtitle || argtype) =~ /^([^\[\]]+)\[(.+)\]$/m then [ $1, $2 ]
105
+ elsif argtitle then [ argtype, argtitle ]
106
+ elsif argtype.is_a?(Puppet::Type) then [ argtype.class.name, argtype.title ]
107
+ elsif argtype.is_a?(Hash) then
108
+ raise ArgumentError, "Puppet::Resource.new does not take a hash as the first argument. "+
109
+ "Did you mean (#{(argtype[:type] || argtype["type"]).inspect}, #{(argtype[:title] || argtype["title"]).inspect }) ?"
110
+ else raise ArgumentError, "No title provided and #{argtype.inspect} is not a valid resource reference"
111
+ end
112
+ end
113
+
114
+ def self.munge_type_name(value)
115
+ return :main if value == :main
116
+ return "Class" if value == "" or value.nil? or value.to_s.downcase == "component"
117
+
118
+ value.to_s.split("::").collect { |s| s.capitalize }.join("::")
119
+ end
120
+
93
121
  def yaml_property_munge(x)
94
122
  case x
95
123
  when Hash
@@ -194,13 +222,12 @@ class Puppet::Resource
194
222
  send(attr.to_s + "=", value)
195
223
  end
196
224
 
197
- @type, @title = extract_type_and_title(type, title)
225
+ @type, @title = self.class.get_type_and_title(type, title)
198
226
 
199
- @type = munge_type_name(@type)
200
227
 
201
228
  if self.class?
202
229
  @title = :main if @title == ""
203
- @title = munge_type_name(@title)
230
+ @title = self.class.munge_type_name(@title)
204
231
  end
205
232
 
206
233
  if params = attributes[:parameters]
@@ -339,10 +366,14 @@ class Puppet::Resource
339
366
  missing_arguments.collect do |param, default|
340
367
  external_value = lookup_external_default_for(param, scope)
341
368
 
342
- if external_value.nil? && default.nil?
343
- next
344
- elsif external_value.nil?
345
- value = default.safeevaluate(scope)
369
+ if external_value.nil?
370
+ next if default.nil?
371
+
372
+ value = if default.respond_to? :safeevaluate
373
+ default.safeevaluate(scope)
374
+ else
375
+ default
376
+ end
346
377
  else
347
378
  value = external_value
348
379
  end
@@ -421,24 +452,6 @@ class Puppet::Resource
421
452
  end
422
453
  end
423
454
 
424
- def extract_type_and_title(argtype, argtitle)
425
- if (argtitle || argtype) =~ /^([^\[\]]+)\[(.+)\]$/m then [ $1, $2 ]
426
- elsif argtitle then [ argtype, argtitle ]
427
- elsif argtype.is_a?(Puppet::Type) then [ argtype.class.name, argtype.title ]
428
- elsif argtype.is_a?(Hash) then
429
- raise ArgumentError, "Puppet::Resource.new does not take a hash as the first argument. "+
430
- "Did you mean (#{(argtype[:type] || argtype["type"]).inspect}, #{(argtype[:title] || argtype["title"]).inspect }) ?"
431
- else raise ArgumentError, "No title provided and #{argtype.inspect} is not a valid resource reference"
432
- end
433
- end
434
-
435
- def munge_type_name(value)
436
- return :main if value == :main
437
- return "Class" if value == "" or value.nil? or value.to_s.downcase == "component"
438
-
439
- value.to_s.split("::").collect { |s| s.capitalize }.join("::")
440
- end
441
-
442
455
  def parse_title
443
456
  h = {}
444
457
  type = resource_type
@@ -27,7 +27,7 @@ class Puppet::Resource::Type
27
27
  }
28
28
  RESOURCE_EXTERNAL_NAMES_TO_KINDS = RESOURCE_KINDS_TO_EXTERNAL_NAMES.invert
29
29
 
30
- attr_accessor :file, :line, :doc, :code, :ruby_code, :parent, :resource_type_collection
30
+ attr_accessor :file, :line, :doc, :code, :parent, :resource_type_collection
31
31
  attr_reader :namespace, :arguments, :behaves_like, :module_name
32
32
 
33
33
  # This should probably be renamed to 'kind' eventually, in accordance with the changes
@@ -135,7 +135,11 @@ class Puppet::Resource::Type
135
135
 
136
136
  code.safeevaluate(scope) if code
137
137
 
138
- evaluate_ruby_code(resource, scope) if ruby_code
138
+ evaluate_ruby_code(scope) unless ruby_code.empty?
139
+ end
140
+
141
+ def ruby_code
142
+ @ruby_code ||= []
139
143
  end
140
144
 
141
145
  def initialize(type, name, options = {})
@@ -182,6 +186,10 @@ class Puppet::Resource::Type
182
186
  self.doc += other.doc
183
187
  end
184
188
 
189
+ other.ruby_code.each do |c|
190
+ self.ruby_code << c
191
+ end
192
+
185
193
  # This might just be an empty, stub class.
186
194
  return unless other.code
187
195
 
@@ -260,10 +268,10 @@ class Puppet::Resource::Type
260
268
 
261
269
  # MQR TODO:
262
270
  #
263
- # The change(s) introduced by the fix for #4270 are mostly silly & should be
271
+ # The change(s) introduced by the fix for #4270 are mostly silly & should be
264
272
  # removed, though we didn't realize it at the time. If it can be established/
265
273
  # ensured that nodes never call parent_type and that resource_types are always
266
- # (as they should be) members of exactly one resource_type_collection the
274
+ # (as they should be) members of exactly one resource_type_collection the
267
275
  # following method could / should be replaced with:
268
276
  #
269
277
  # def parent_type
@@ -361,8 +369,8 @@ class Puppet::Resource::Type
361
369
  parent_scope(resource.scope, klass)
362
370
  end
363
371
 
364
- def evaluate_ruby_code(resource, scope)
365
- Puppet::DSL::ResourceAPI.new(resource, scope, ruby_code).evaluate
372
+ def evaluate_ruby_code(scope)
373
+ ruby_code.each { |c| c.evaluate(scope, scope.known_resource_types) }
366
374
  end
367
375
 
368
376
  # Split an fq name into a namespace and name