puppet 4.2.3-x86-mingw32 → 4.3.0-x86-mingw32

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 (337) hide show
  1. data/Gemfile +3 -0
  2. data/README.md +1 -1
  3. data/ext/debian/puppet.init +0 -1
  4. data/ext/debian/puppet.logrotate +14 -5
  5. data/ext/osx/puppet.plist +0 -2
  6. data/ext/redhat/client.init +13 -5
  7. data/ext/redhat/logrotate +15 -3
  8. data/ext/redhat/puppet.spec.erb +5 -1
  9. data/ext/redhat/server.init +1 -1
  10. data/ext/systemd/puppet.service +1 -0
  11. data/lib/puppet.rb +12 -0
  12. data/lib/puppet/agent.rb +4 -4
  13. data/lib/puppet/agent/locker.rb +11 -2
  14. data/lib/puppet/application/agent.rb +5 -1
  15. data/lib/puppet/application/apply.rb +4 -0
  16. data/lib/puppet/application/filebucket.rb +78 -4
  17. data/lib/puppet/application/lookup.rb +356 -0
  18. data/lib/puppet/application/master.rb +3 -0
  19. data/lib/puppet/configurer.rb +9 -5
  20. data/lib/puppet/context.rb +16 -1
  21. data/lib/puppet/context/trusted_information.rb +21 -1
  22. data/lib/puppet/daemon.rb +17 -13
  23. data/lib/puppet/data_binding.rb +4 -2
  24. data/lib/puppet/data_providers.rb +12 -13
  25. data/lib/puppet/data_providers/data_adapter.rb +7 -68
  26. data/lib/puppet/data_providers/data_function_support.rb +5 -26
  27. data/lib/puppet/data_providers/function_env_data_provider.rb +0 -10
  28. data/lib/puppet/data_providers/function_module_data_provider.rb +0 -22
  29. data/lib/puppet/data_providers/hiera_config.rb +106 -0
  30. data/lib/puppet/data_providers/hiera_env_data_provider.rb +18 -0
  31. data/lib/puppet/data_providers/hiera_interpolate.rb +97 -0
  32. data/lib/puppet/data_providers/hiera_module_data_provider.rb +23 -0
  33. data/lib/puppet/data_providers/hiera_support.rb +37 -0
  34. data/lib/puppet/data_providers/json_data_provider_factory.rb +31 -0
  35. data/lib/puppet/data_providers/lookup_adapter.rb +200 -0
  36. data/lib/puppet/data_providers/yaml_data_provider_factory.rb +32 -0
  37. data/lib/puppet/defaults.rb +12 -2
  38. data/lib/puppet/error.rb +4 -0
  39. data/lib/puppet/face/module/changes.rb +2 -1
  40. data/lib/puppet/feature/cfacter.rb +1 -0
  41. data/lib/puppet/file_bucket/dipper.rb +58 -2
  42. data/lib/puppet/functions.rb +2 -4
  43. data/lib/puppet/functions/assert_type.rb +48 -12
  44. data/lib/puppet/functions/defined.rb +79 -48
  45. data/lib/puppet/functions/each.rb +85 -27
  46. data/lib/puppet/functions/filter.rb +58 -23
  47. data/lib/puppet/functions/hiera.rb +76 -3
  48. data/lib/puppet/functions/hiera_array.rb +65 -3
  49. data/lib/puppet/functions/hiera_hash.rb +74 -2
  50. data/lib/puppet/functions/hiera_include.rb +75 -2
  51. data/lib/puppet/functions/lookup.rb +19 -17
  52. data/lib/puppet/functions/map.rb +56 -21
  53. data/lib/puppet/functions/match.rb +29 -12
  54. data/lib/puppet/functions/reduce.rb +95 -58
  55. data/lib/puppet/functions/versioncmp.rb +36 -0
  56. data/lib/puppet/functions/with.rb +15 -7
  57. data/lib/puppet/indirector/catalog/compiler.rb +3 -3
  58. data/lib/puppet/indirector/catalog/static_compiler.rb +46 -30
  59. data/lib/puppet/indirector/data_binding/none.rb +4 -1
  60. data/lib/puppet/indirector/file_bucket_file/file.rb +58 -1
  61. data/lib/puppet/indirector/hiera.rb +4 -0
  62. data/lib/puppet/indirector/json.rb +1 -1
  63. data/lib/puppet/indirector/msgpack.rb +1 -1
  64. data/lib/puppet/indirector/request.rb +7 -8
  65. data/lib/puppet/indirector/resource_type/parser.rb +5 -3
  66. data/lib/puppet/info_service.rb +7 -0
  67. data/lib/puppet/info_service/class_information_service.rb +111 -0
  68. data/lib/puppet/module_tool/metadata.rb +32 -9
  69. data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +42 -38
  70. data/lib/puppet/network/authconfig.rb +21 -1
  71. data/lib/puppet/network/authorization.rb +8 -1
  72. data/lib/puppet/network/http/api/master/v3.rb +7 -1
  73. data/lib/puppet/network/http/api/master/v3/environment.rb +59 -0
  74. data/lib/puppet/node/environment.rb +9 -2
  75. data/lib/puppet/parser.rb +3 -0
  76. data/lib/puppet/parser/ast/pops_bridge.rb +39 -1
  77. data/lib/puppet/parser/compiler.rb +302 -12
  78. data/lib/puppet/parser/compiler/catalog_validator.rb +33 -0
  79. data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +64 -0
  80. data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +38 -0
  81. data/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +20 -0
  82. data/lib/puppet/parser/environment_compiler.rb +165 -0
  83. data/lib/puppet/parser/functions/assert_type.rb +46 -16
  84. data/lib/puppet/parser/functions/defined.rb +105 -68
  85. data/lib/puppet/parser/functions/each.rb +85 -27
  86. data/lib/puppet/parser/functions/filter.rb +59 -23
  87. data/lib/puppet/parser/functions/hiera.rb +83 -27
  88. data/lib/puppet/parser/functions/hiera_array.rb +71 -28
  89. data/lib/puppet/parser/functions/hiera_hash.rb +81 -30
  90. data/lib/puppet/parser/functions/hiera_include.rb +81 -40
  91. data/lib/puppet/parser/functions/map.rb +55 -20
  92. data/lib/puppet/parser/functions/match.rb +27 -12
  93. data/lib/puppet/parser/functions/reduce.rb +97 -60
  94. data/lib/puppet/parser/functions/with.rb +16 -8
  95. data/lib/puppet/parser/resource.rb +98 -19
  96. data/lib/puppet/plugins/configuration.rb +3 -2
  97. data/lib/puppet/plugins/data_providers.rb +12 -60
  98. data/lib/puppet/plugins/data_providers/data_provider.rb +283 -0
  99. data/lib/puppet/plugins/data_providers/registry.rb +84 -0
  100. data/lib/puppet/pops.rb +19 -17
  101. data/lib/puppet/pops/adapters.rb +12 -0
  102. data/lib/puppet/pops/binder/binder.rb +2 -2
  103. data/lib/puppet/pops/binder/bindings_checker.rb +1 -1
  104. data/lib/puppet/pops/binder/bindings_label_provider.rb +3 -1
  105. data/lib/puppet/pops/binder/bindings_loader.rb +6 -2
  106. data/lib/puppet/pops/binder/bindings_model_meta.rb +2 -2
  107. data/lib/puppet/pops/binder/config/binder_config.rb +1 -1
  108. data/lib/puppet/pops/binder/injector.rb +4 -4
  109. data/lib/puppet/pops/binder/key_factory.rb +3 -9
  110. data/lib/puppet/pops/binder/scheme_handler/module_scheme.rb +68 -9
  111. data/lib/puppet/pops/evaluator/access_operator.rb +27 -60
  112. data/lib/puppet/pops/evaluator/closure.rb +8 -8
  113. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
  114. data/lib/puppet/pops/evaluator/evaluator_impl.rb +5 -5
  115. data/lib/puppet/pops/evaluator/literal_evaluator.rb +87 -0
  116. data/lib/puppet/pops/evaluator/relationship_operator.rb +7 -1
  117. data/lib/puppet/pops/functions/dispatcher.rb +3 -3
  118. data/lib/puppet/pops/issues.rb +1 -1
  119. data/lib/puppet/pops/label_provider.rb +1 -1
  120. data/lib/puppet/pops/lookup.rb +25 -47
  121. data/lib/puppet/pops/lookup/explainer.rb +402 -0
  122. data/lib/puppet/pops/lookup/invocation.rb +117 -0
  123. data/lib/puppet/pops/merge_strategy.rb +73 -5
  124. data/lib/puppet/pops/model/factory.rb +34 -0
  125. data/lib/puppet/pops/model/model_label_provider.rb +10 -1
  126. data/lib/puppet/pops/model/model_meta.rb +15 -0
  127. data/lib/puppet/pops/model/model_tree_dumper.rb +18 -0
  128. data/lib/puppet/pops/parser/code_merger.rb +13 -1
  129. data/lib/puppet/pops/parser/egrammar.ra +56 -3
  130. data/lib/puppet/pops/parser/eparser.rb +1549 -1352
  131. data/lib/puppet/pops/parser/lexer2.rb +31 -6
  132. data/lib/puppet/pops/parser/locator.rb +1 -1
  133. data/lib/puppet/pops/parser/parser_support.rb +25 -13
  134. data/lib/puppet/pops/types/enumeration.rb +1 -2
  135. data/lib/puppet/pops/types/type_asserter.rb +16 -15
  136. data/lib/puppet/pops/types/type_assertion_error.rb +1 -0
  137. data/lib/puppet/pops/types/type_calculator.rb +171 -1020
  138. data/lib/puppet/pops/types/type_factory.rb +87 -148
  139. data/lib/puppet/pops/types/type_mismatch_describer.rb +743 -0
  140. data/lib/puppet/pops/types/type_parser.rb +116 -127
  141. data/lib/puppet/pops/types/types.rb +1394 -255
  142. data/lib/puppet/pops/types/types_meta.rb +0 -234
  143. data/lib/puppet/pops/validation.rb +7 -2
  144. data/lib/puppet/pops/validation/checker4_0.rb +28 -0
  145. data/lib/puppet/provider/augeas/augeas.rb +50 -0
  146. data/lib/puppet/provider/group/directoryservice.rb +10 -0
  147. data/lib/puppet/provider/package/dnf.rb +41 -0
  148. data/lib/puppet/provider/package/gem.rb +7 -2
  149. data/lib/puppet/provider/package/rpm.rb +1 -0
  150. data/lib/puppet/provider/package/windows/exe_package.rb +10 -8
  151. data/lib/puppet/provider/package/windows/msi_package.rb +4 -3
  152. data/lib/puppet/provider/package/windows/package.rb +9 -1
  153. data/lib/puppet/provider/package/yum.rb +14 -9
  154. data/lib/puppet/provider/service/bsd.rb +1 -1
  155. data/lib/puppet/provider/service/debian.rb +21 -0
  156. data/lib/puppet/provider/service/init.rb +6 -0
  157. data/lib/puppet/provider/service/rcng.rb +51 -0
  158. data/lib/puppet/provider/service/redhat.rb +2 -1
  159. data/lib/puppet/provider/service/smf.rb +43 -2
  160. data/lib/puppet/provider/service/src.rb +27 -0
  161. data/lib/puppet/provider/service/systemd.rb +15 -3
  162. data/lib/puppet/provider/sshkey/parsed.rb +19 -9
  163. data/lib/puppet/reference/report.rb +9 -12
  164. data/lib/puppet/reports.rb +5 -1
  165. data/lib/puppet/resource.rb +50 -73
  166. data/lib/puppet/resource/capability_finder.rb +95 -0
  167. data/lib/puppet/resource/catalog.rb +47 -7
  168. data/lib/puppet/resource/status.rb +0 -2
  169. data/lib/puppet/resource/type.rb +238 -44
  170. data/lib/puppet/resource/type_collection.rb +60 -2
  171. data/lib/puppet/settings.rb +2 -2
  172. data/lib/puppet/ssl/certificate_authority/interface.rb +2 -2
  173. data/lib/puppet/ssl/oids.rb +9 -1
  174. data/lib/puppet/transaction.rb +4 -1
  175. data/lib/puppet/transaction/additional_resource_generator.rb +71 -8
  176. data/lib/puppet/transaction/resource_harness.rb +9 -4
  177. data/lib/puppet/type.rb +74 -3
  178. data/lib/puppet/type/augeas.rb +8 -0
  179. data/lib/puppet/type/file/source.rb +14 -12
  180. data/lib/puppet/type/user.rb +4 -2
  181. data/lib/puppet/util/windows/security.rb +4 -1
  182. data/lib/puppet/util/windows/taskscheduler.rb +1 -1
  183. data/lib/puppet/version.rb +1 -1
  184. data/spec/fixtures/unit/application/environments/production/data/common.yaml +3 -0
  185. data/spec/fixtures/unit/application/environments/production/environment.conf +1 -0
  186. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/data/bad.json +3 -0
  187. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/environment.conf +2 -0
  188. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/hiera.yaml +5 -0
  189. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/manifests/site.pp +5 -0
  190. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/data/bad.yaml +3 -0
  191. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/environment.conf +2 -0
  192. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/hiera.yaml +5 -0
  193. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/manifests/site.pp +5 -0
  194. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/data/common.yaml +2 -0
  195. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/environment.conf +2 -0
  196. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/manifests/site.pp +1 -0
  197. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/data/common.yaml +2 -0
  198. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/manifests/init.pp +5 -0
  199. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/metadata.json +9 -0
  200. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/first.json +3 -0
  201. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/name.yaml +2 -0
  202. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/second.json +3 -0
  203. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/single.yaml +2 -0
  204. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data2/single.yaml +2 -0
  205. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/environment.conf +2 -0
  206. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/hiera.yaml +18 -0
  207. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/manifests/site.pp +5 -0
  208. data/spec/fixtures/unit/data_providers/environments/hiera_misc/data/common.yaml +46 -0
  209. data/spec/fixtures/unit/data_providers/environments/hiera_misc/environment.conf +2 -0
  210. data/spec/fixtures/unit/data_providers/environments/hiera_misc/manifests/site.pp +1 -0
  211. data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/data/common.yaml +30 -0
  212. data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/manifests/init.pp +13 -0
  213. data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/metadata.json +9 -0
  214. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/environment.conf +2 -0
  215. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/manifests/site.pp +1 -0
  216. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/first.json +3 -0
  217. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/name.yaml +1 -0
  218. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/second.json +3 -0
  219. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/single.yaml +2 -0
  220. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data2/single.yaml +2 -0
  221. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/hiera.yaml +18 -0
  222. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/manifests/init.pp +5 -0
  223. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/metadata.json +9 -0
  224. data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_env_data.rb +1 -0
  225. data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_module_data.rb +1 -0
  226. data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/data/first.json +3 -0
  227. data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/hiera.yaml +8 -0
  228. data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/manifests/init.pp +5 -0
  229. data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/metadata.json +9 -0
  230. data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/lib/puppet/functions/meta/data.rb +9 -0
  231. data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/manifests/init.pp +3 -0
  232. data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/metadata.json +9 -0
  233. data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet/bindings/metawcp/default.rb +10 -0
  234. data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet_x/thallgren/sample_module_data.rb +23 -0
  235. data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/manifests/init.pp +3 -0
  236. data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/metadata.json +9 -0
  237. data/spec/fixtures/unit/provider/package/yum/yum-check-update-security.txt +184 -0
  238. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +24 -0
  239. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +24 -0
  240. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +24 -0
  241. data/spec/integration/data_binding_spec.rb +229 -0
  242. data/spec/integration/file_bucket/file_spec.rb +2 -2
  243. data/spec/integration/parser/compiler_spec.rb +23 -19
  244. data/spec/integration/parser/resource_expressions_spec.rb +4 -4
  245. data/spec/integration/parser/undef_param_spec.rb +1 -1
  246. data/spec/integration/resource/catalog_spec.rb +1 -1
  247. data/spec/integration/type/package_spec.rb +2 -0
  248. data/spec/integration/util/windows/security_spec.rb +18 -0
  249. data/spec/lib/matchers/include_in_order.rb +2 -2
  250. data/spec/shared_behaviours/iterative_functions.rb +8 -8
  251. data/spec/spec_helper.rb +7 -0
  252. data/spec/unit/agent/locker_spec.rb +4 -4
  253. data/spec/unit/agent_spec.rb +0 -8
  254. data/spec/unit/application/agent_spec.rb +5 -0
  255. data/spec/unit/application/apply_spec.rb +8 -0
  256. data/spec/unit/application/filebucket_spec.rb +87 -1
  257. data/spec/unit/application/lookup_spec.rb +195 -0
  258. data/spec/unit/appmgmt_spec.rb +657 -0
  259. data/spec/unit/capability_spec.rb +414 -0
  260. data/spec/unit/configurer_spec.rb +7 -1
  261. data/spec/unit/context/trusted_information_spec.rb +24 -1
  262. data/spec/unit/daemon_spec.rb +18 -8
  263. data/spec/unit/data_providers/hiera_data_provider_spec.rb +201 -0
  264. data/spec/unit/file_bucket/dipper_spec.rb +210 -1
  265. data/spec/unit/functions/assert_type_spec.rb +5 -7
  266. data/spec/unit/functions/defined_spec.rb +2 -2
  267. data/spec/unit/functions/epp_spec.rb +2 -2
  268. data/spec/unit/functions/lookup_spec.rb +200 -9
  269. data/spec/unit/functions/regsubst_spec.rb +17 -8
  270. data/spec/unit/functions/scanf_spec.rb +1 -1
  271. data/spec/unit/functions/split_spec.rb +2 -2
  272. data/spec/unit/functions/versioncmp_spec.rb +36 -0
  273. data/spec/unit/functions4_spec.rb +58 -72
  274. data/spec/unit/indirector/catalog/compiler_spec.rb +28 -8
  275. data/spec/unit/indirector/catalog/static_compiler_spec.rb +38 -20
  276. data/spec/unit/indirector/data_binding/none_spec.rb +2 -2
  277. data/spec/unit/indirector/file_bucket_file/file_spec.rb +52 -1
  278. data/spec/unit/indirector/request_spec.rb +8 -8
  279. data/spec/unit/info_service_spec.rb +236 -0
  280. data/spec/unit/module_tool/metadata_spec.rb +31 -2
  281. data/spec/unit/network/authconfig_spec.rb +62 -32
  282. data/spec/unit/network/authorization_spec.rb +30 -2
  283. data/spec/unit/network/http/connection_spec.rb +14 -19
  284. data/spec/unit/parser/compiler_spec.rb +86 -2
  285. data/spec/unit/parser/functions/create_resources_spec.rb +1 -1
  286. data/spec/unit/parser/resource_spec.rb +2 -20
  287. data/spec/unit/pops/binder/config/binder_config_spec.rb +1 -1
  288. data/spec/unit/pops/binder/injector_spec.rb +3 -3
  289. data/spec/unit/pops/evaluator/access_ops_spec.rb +13 -11
  290. data/spec/unit/pops/evaluator/basic_expressions_spec.rb +1 -2
  291. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +19 -11
  292. data/spec/unit/pops/evaluator/literal_evaluator_spec.rb +43 -0
  293. data/spec/unit/pops/label_provider_spec.rb +5 -1
  294. data/spec/unit/pops/parser/lexer2_spec.rb +33 -7
  295. data/spec/unit/pops/parser/parse_application_spec.rb +40 -0
  296. data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +4 -0
  297. data/spec/unit/pops/parser/parse_capabilities_spec.rb +47 -0
  298. data/spec/unit/pops/parser/parse_site_spec.rb +38 -0
  299. data/spec/unit/pops/parser/parser_rspec_helper.rb +5 -0
  300. data/spec/unit/pops/parser/parser_spec.rb +18 -0
  301. data/spec/unit/pops/types/type_calculator_spec.rb +427 -444
  302. data/spec/unit/pops/types/type_factory_spec.rb +12 -12
  303. data/spec/unit/pops/types/type_parser_spec.rb +7 -12
  304. data/spec/unit/pops/validator/validator_spec.rb +25 -0
  305. data/spec/unit/provider/augeas/augeas_spec.rb +50 -0
  306. data/spec/unit/provider/group/directoryservice_spec.rb +33 -0
  307. data/spec/unit/provider/group/windows_adsi_spec.rb +3 -0
  308. data/spec/unit/provider/package/dnf_spec.rb +92 -0
  309. data/spec/unit/provider/package/gem_spec.rb +7 -0
  310. data/spec/unit/provider/package/rpm_spec.rb +25 -2
  311. data/spec/unit/provider/package/windows/package_spec.rb +41 -0
  312. data/spec/unit/provider/package/yum_spec.rb +21 -13
  313. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +10 -0
  314. data/spec/unit/provider/service/debian_spec.rb +27 -0
  315. data/spec/unit/provider/service/rcng_spec.rb +41 -0
  316. data/spec/unit/provider/service/redhat_spec.rb +8 -1
  317. data/spec/unit/provider/service/smf_spec.rb +30 -5
  318. data/spec/unit/provider/service/src_spec.rb +19 -4
  319. data/spec/unit/provider/service/systemd_spec.rb +78 -29
  320. data/spec/unit/provider/sshkey/parsed_spec.rb +23 -0
  321. data/spec/unit/reports_spec.rb +10 -0
  322. data/spec/unit/resource/capability_finder_spec.rb +56 -0
  323. data/spec/unit/resource/catalog_spec.rb +31 -8
  324. data/spec/unit/resource/type_collection_spec.rb +23 -2
  325. data/spec/unit/resource/type_spec.rb +1 -1
  326. data/spec/unit/resource_spec.rb +22 -4
  327. data/spec/unit/settings_spec.rb +90 -1
  328. data/spec/unit/ssl/certificate_authority/interface_spec.rb +4 -3
  329. data/spec/unit/ssl/oids_spec.rb +8 -0
  330. data/spec/unit/transaction/additional_resource_generator_spec.rb +78 -5
  331. data/spec/unit/transaction/report_spec.rb +24 -1
  332. data/spec/unit/type/package_spec.rb +1 -0
  333. data/spec/unit/type/user_spec.rb +14 -7
  334. data/spec/unit/type_spec.rb +1 -1
  335. metadata +169 -5
  336. data/lib/puppet/pops/evaluator/callable_mismatch_describer.rb +0 -175
  337. data/spec/integration/data_binding.rb +0 -104
@@ -5,19 +5,16 @@ report = Puppet::Util::Reference.newreference :report, :doc => "All available tr
5
5
  end
6
6
 
7
7
  report.header = "
8
- Puppet clients can report back to the server after each transaction. This
9
- transaction report is sent as a YAML dump of the
10
- `Puppet::Transaction::Report` class and includes every log message that was
11
- generated during the transaction along with as many metrics as Puppet knows how
12
- to collect. See [Reports and Reporting](http://docs.puppetlabs.com/guides/reporting.html) for more information on how to use reports.
8
+ Puppet can generate a report after applying a catalog. This report includes
9
+ events, log messages, resource statuses, and metrics and metadata about the run.
10
+ Puppet agent sends its report to a Puppet master server, and Puppet apply
11
+ processes its own reports.
13
12
 
14
- Currently, clients default to not sending in reports; you can enable reporting
15
- by setting the `report` parameter to true.
13
+ Puppet master and Puppet apply will handle every report with a set of report
14
+ processors, configurable with the `reports` setting in puppet.conf. This page
15
+ documents the built-in report processors.
16
16
 
17
- To use a report, set the `reports` parameter on the server; multiple
18
- reports must be comma-separated. You can also specify `none` to disable
19
- reports entirely.
20
-
21
- Puppet provides multiple report handlers that will process client reports:
17
+ See [About Reporting](https://docs.puppetlabs.com/puppet/latest/reference/reporting_about.html)
18
+ for more details.
22
19
 
23
20
  "
@@ -54,7 +54,11 @@ class Puppet::Reports
54
54
  def self.register_report(name, options = {}, &block)
55
55
  name = name.intern
56
56
 
57
- mod = genmodule(name, :extend => Puppet::Util::Docs, :hash => instance_hash(:report), :block => block)
57
+ mod = genmodule(name,
58
+ :extend => Puppet::Util::Docs,
59
+ :hash => instance_hash(:report),
60
+ :overwrite => true,
61
+ :block => block)
58
62
 
59
63
  mod.useyaml = true if options[:useyaml]
60
64
 
@@ -11,9 +11,12 @@ class Puppet::Resource
11
11
  include Puppet::Util::Tagging
12
12
 
13
13
  include Enumerable
14
- attr_accessor :file, :line, :catalog, :exported, :virtual, :validate_parameters, :strict
14
+ attr_accessor :file, :line, :catalog, :exported, :virtual, :strict
15
15
  attr_reader :type, :title
16
16
 
17
+ # @deprecated
18
+ attr_accessor :validate_parameters
19
+
17
20
  require 'puppet/indirector'
18
21
  extend Puppet::Indirector
19
22
  indirects :resource, :terminus_class => :ral
@@ -274,6 +277,29 @@ class Puppet::Resource
274
277
  catalog ? catalog.resource(to_s) : nil
275
278
  end
276
279
 
280
+ # A resource is an application component if it exports or consumes
281
+ # one or more capabilities, or if it requires a capability resource
282
+ def is_application_component?
283
+ return true if ! export.empty? || self[:consume]
284
+ # Array(self[:require]) does not work for Puppet::Resource instances
285
+ req = self[:require] || []
286
+ req = [ req ] unless req.is_a?(Array)
287
+ req.any? { |r| r.is_capability? }
288
+ end
289
+
290
+ # A resource is a capability (instance) if its underlying type is a
291
+ # capability type
292
+ def is_capability?
293
+ resource_type and resource_type.is_capability?
294
+ end
295
+
296
+ # Returns the value of the 'export' metaparam as an Array
297
+ # @api private
298
+ def export
299
+ v = self[:export] || []
300
+ v.is_a?(Array) ? v : [ v ]
301
+ end
302
+
277
303
  # The resource's type implementation
278
304
  # @return [Puppet::Type, Puppet::Resource::Type]
279
305
  # @api private
@@ -281,8 +307,14 @@ class Puppet::Resource
281
307
  @rstype ||= case type
282
308
  when "Class"; environment.known_resource_types.hostclass(title == :main ? "" : title)
283
309
  when "Node"; environment.known_resource_types.node(title)
310
+ when "Site"; environment.known_resource_types.site(nil)
284
311
  else
285
- Puppet::Type.type(type) || environment.known_resource_types.definition(type)
312
+ result = Puppet::Type.type(type)
313
+ if !result
314
+ krt = environment.known_resource_types
315
+ result = krt.definition(type) || krt.application(type)
316
+ end
317
+ result
286
318
  end
287
319
  end
288
320
 
@@ -364,7 +396,8 @@ class Puppet::Resource
364
396
  " %-#{attr_max}s => %s,\n" % [k, Puppet::Parameter.format_value_for_display(v)]
365
397
  }.join
366
398
 
367
- "%s { '%s':\n%s}" % [self.type.to_s.downcase, self.title, attributes]
399
+ escaped = self.title.gsub(/'/,"\\\\'")
400
+ "%s { '%s':\n%s}" % [self.type.to_s.downcase, escaped, attributes]
368
401
  end
369
402
 
370
403
  def to_ref
@@ -393,74 +426,11 @@ class Puppet::Resource
393
426
  end
394
427
  private :missing_arguments
395
428
 
396
- # Consult external data bindings for class parameter values which must be
397
- # namespaced in the backend.
398
- #
399
- # Example:
400
- #
401
- # class foo($port=0){ ... }
402
- #
403
- # We make a request to the backend for the key 'foo::port' not 'foo'
404
- #
405
- def lookup_external_default_for(param, scope)
406
- # Only lookup parameters for host classes
407
- return nil unless resource_type.type == :hostclass
408
-
409
- name = "#{resource_type.name}::#{param}"
410
- in_global = lambda { lookup_with_databinding(name, scope) }
411
- in_env = lambda { lookup_in_environment(name, scope) }
412
- in_module = lambda { lookup_in_module(name, scope) }
413
- search(in_global, in_env, in_module)
414
- end
415
-
416
- def search(*search_functions)
417
- search_functions.each {|f| x = f.call(); return x unless x.nil? }
418
- nil
419
- end
420
-
421
- private :lookup_external_default_for
422
-
423
- def lookup_with_databinding(name, scope)
424
- begin
425
- found = false
426
- value = catch(:no_such_key) do
427
- v = Puppet::DataBinding.indirection.find(
428
- name,
429
- :environment => scope.environment.to_s,
430
- :variables => scope)
431
- found = true
432
- v
433
- end
434
- found ? value : nil
435
- rescue Puppet::DataBinding::LookupError => e
436
- raise Puppet::Error.new("Error from DataBinding '#{Puppet[:data_binding_terminus]}' while looking up '#{name}': #{e.message}", e)
437
- end
438
- end
439
- private :lookup_with_databinding
440
-
441
- def lookup_in_environment(name, scope)
442
- found = false
443
- value = catch(:no_such_key) do
444
- v = Puppet::DataProviders.lookup_in_environment(name, scope, nil)
445
- found = true
446
- v
447
- end
448
- found ? value : nil
449
- end
450
- private :lookup_in_environment
451
-
452
- def lookup_in_module(name, scope)
453
- found = false
454
- value = catch(:no_such_key) do
455
- v = Puppet::DataProviders.lookup_in_module(name, scope, nil)
456
- found = true
457
- v
458
- end
459
- found ? value : nil
460
- end
461
- private :lookup_in_module
462
-
429
+ # @deprecated Not used by Puppet
430
+ # @api private
463
431
  def set_default_parameters(scope)
432
+ Puppet.deprecation_warning('The method Puppet::Resource.set_default_parameters is deprecated and will be removed in the next major release of Puppet.')
433
+
464
434
  return [] unless resource_type and resource_type.respond_to?(:arguments)
465
435
 
466
436
  unless is_a?(Puppet::Parser::Resource)
@@ -468,7 +438,9 @@ class Puppet::Resource
468
438
  end
469
439
 
470
440
  missing_arguments.collect do |param, default|
471
- external_value = lookup_external_default_for(param, scope)
441
+ # Using 'send' since this private method moved from here to type. The caller method is deprecated
442
+ # and doesn't really motivate making the callee public
443
+ external_value = resource_type.send(:lookup_external_default_for, param, scope)
472
444
 
473
445
  if external_value.nil? && default.nil?
474
446
  next
@@ -495,7 +467,12 @@ class Puppet::Resource
495
467
  # have been provided with defaults.
496
468
  # Must be called after 'set_default_parameters'. We can't join the methods
497
469
  # because Type#set_parameters needs specifically ordered behavior.
470
+ #
471
+ # @deprecated Not used by Puppet
472
+ # @api private
498
473
  def validate_complete
474
+ Puppet.deprecation_warning('The method Puppet::Resource.validate_complete is deprecated and will be removed in the next major release of Puppet.')
475
+
499
476
  return unless resource_type and resource_type.respond_to?(:arguments)
500
477
 
501
478
  resource_type.arguments.each do |param, default|
@@ -510,14 +487,14 @@ class Puppet::Resource
510
487
  next unless t = arg_types[name.to_s] # untyped, and parameters are symbols here (aargh, strings in the type)
511
488
  unless Puppet::Pops::Types::TypeCalculator.instance?(t, value.value)
512
489
  inferred_type = Puppet::Pops::Types::TypeCalculator.infer_set(value.value)
513
- actual = Puppet::Pops::Types::TypeCalculator.generalize!(inferred_type)
490
+ actual = inferred_type.generalize()
514
491
  fail Puppet::ParseError, "Expected parameter '#{name}' of '#{self}' to have type #{t.to_s}, got #{actual.to_s}"
515
492
  end
516
493
  end
517
494
  end
518
495
 
519
496
  def validate_parameter(name)
520
- raise ArgumentError, "Invalid parameter: '#{name}'" unless valid_parameter?(name)
497
+ raise Puppet::ParseError.new("no parameter named '#{name}'", file, line) unless valid_parameter?(name)
521
498
  end
522
499
 
523
500
  def prune_parameters(options = {})
@@ -0,0 +1,95 @@
1
+ #
2
+ # A helper module to look a capability up from PuppetDB
3
+ #
4
+ # @todo lutter 2015-03-10: determine whether this should be based on
5
+ # Puppet::Pops::Evaluator::Collectors, or at least use
6
+ # Puppet::Util::Puppetdb::Http
7
+
8
+ require 'net/http'
9
+ require 'cgi'
10
+ require 'json'
11
+
12
+ # @api private
13
+ module Puppet::Resource::CapabilityFinder
14
+
15
+ # Looks the capability resource from PuppetDB.
16
+ # @param environment [String] environment name
17
+ # @param code_id [String,nil] code_id of the catalog
18
+ # @param cap [Puppet::Type] the capability resource type instance
19
+ # @return [Puppet::Resource,nil] The found capability resource or `nil` if it could not be found
20
+ def self.find(environment, code_id, cap)
21
+ unless Puppet::Util.const_defined?('Puppetdb')
22
+ raise Puppet::DevError, 'PuppetDB is not available'
23
+ end
24
+
25
+ query_terms = [
26
+ 'and',
27
+ ['=', 'type', cap.type.capitalize],
28
+ ['=', 'title', cap.title.to_s],
29
+ ['=', 'tag', "producer:#{environment}"]
30
+ ]
31
+
32
+ unless code_id.nil?
33
+ query_terms << ['in', 'certname',
34
+ ['extract', 'certname',
35
+ ['select_catalogs',
36
+ ['=', 'code_id', code_id]]]]
37
+ end
38
+ query = query_terms.to_json
39
+
40
+ Puppet.notice "Capability lookup #{cap}]: #{query}"
41
+
42
+ http = Puppet::Util.const_get('Puppetdb').const_get('Http')
43
+ response = http.action("/pdb/query/v4/resources?query=#{CGI.escape(query)}") do |conn, uri|
44
+ conn.get(uri, { 'Accept' => 'application/json'})
45
+ end
46
+ json = response.body
47
+
48
+ # The format of the response body is documented at
49
+ # http://docs.puppetlabs.com/puppetdb/3.0/api/query/v4/resources.html#response-format
50
+ # In a nutshell, we expect to get an array of resources back. If the
51
+ # array is empty, the lookup failed and we return +nil+, if it
52
+ # contains exactly one, we turn that resource back into a Puppet
53
+ # ::Resource. If the array contains more than one entry, we have a
54
+ # bug in the overall system, as we allowed multiple capabilities with
55
+ # the same type and title to be produced in this environment.
56
+ begin
57
+ data = JSON.parse(json)
58
+ rescue JSON::JSONError => e
59
+ raise Puppet::DevError,
60
+ "Invalid JSON from PuppetDB when looking up #{cap}\n#{e}\nRaw JSON was:\n#{json}"
61
+ end
62
+ unless data.is_a?(Array)
63
+ raise Puppet::DevError,
64
+ "Unexpected response from PuppetDB when looking up #{cap}: " +
65
+ "expected an Array but got #{data.inspect}"
66
+ end
67
+ if data.size > 1
68
+ raise Puppet::DevError,
69
+ "Unexpected response from PuppetDB when looking up #{cap}:\n" +
70
+ "expected exactly one resource but got #{data.size};\n" +
71
+ "returned data is:\n#{data.inspect}"
72
+ end
73
+
74
+ unless data.empty?
75
+ resource_hash = data.first
76
+ resource = Puppet::Resource.new(resource_hash['type'],
77
+ resource_hash['title'])
78
+ real_type = Puppet::Type.type(resource.type)
79
+ if real_type.nil?
80
+ fail Puppet::ParseError,
81
+ "Could not find resource type #{resource.type} returned from PuppetDB"
82
+ end
83
+ real_type.parameters.each do |param|
84
+ param = param.to_s
85
+ next if param == 'name'
86
+ if value = resource_hash['parameters'][param]
87
+ resource[param] = value
88
+ else
89
+ Puppet.debug "No capability value for #{resource}->#{param}"
90
+ end
91
+ end
92
+ return resource
93
+ end
94
+ end
95
+ end
@@ -4,6 +4,8 @@ require 'puppet/transaction'
4
4
  require 'puppet/util/tagging'
5
5
  require 'puppet/graph'
6
6
 
7
+ require 'puppet/resource/capability_finder'
8
+
7
9
  # This class models a node catalog. It is the thing meant to be passed
8
10
  # from server to client, and it contains all of the information in the
9
11
  # catalog, including the resources and the relationships between them.
@@ -27,6 +29,9 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
27
29
  # is up to date.
28
30
  attr_accessor :version
29
31
 
32
+ # The id of the code input to the compiler.
33
+ attr_accessor :code_id
34
+
30
35
  # How long this catalog took to retrieve. Used for reporting stats.
31
36
  attr_accessor :retrieval_duration
32
37
 
@@ -71,6 +76,25 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
71
76
  return a
72
77
  end
73
78
 
79
+ def add_resource_before(other, *resources)
80
+ resources.each do |resource|
81
+ other_title_key = title_key_for_ref(other.ref)
82
+ idx = @resources.index(other_title_key)
83
+ raise ArgumentError, "Cannot add resource #{resource.ref} before #{other.ref} because #{other.ref} is not yet in the catalog" if idx.nil?
84
+ add_one_resource(resource, idx)
85
+ end
86
+ end
87
+
88
+ def add_resource_after(other, *resources)
89
+ resources.each do |resource|
90
+ other_title_key = title_key_for_ref(other.ref)
91
+ idx = @resources.index(other_title_key)
92
+ raise ArgumentError, "Cannot add resource #{resource.ref} after #{other.ref} because #{other.ref} is not yet in the catalog" if idx.nil?
93
+ add_one_resource(resource, idx+1)
94
+ end
95
+ end
96
+
97
+
74
98
  def add_resource(*resources)
75
99
  resources.each do |resource|
76
100
  add_one_resource(resource)
@@ -84,13 +108,13 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
84
108
  adjacent(resource, :direction => :in)[0]
85
109
  end
86
110
 
87
- def add_one_resource(resource)
111
+ def add_one_resource(resource, idx=-1)
88
112
  title_key = title_key_for_ref(resource.ref)
89
113
  if @resource_table[title_key]
90
114
  fail_on_duplicate_type_and_title(resource, title_key)
91
115
  end
92
116
 
93
- add_resource_to_table(resource, title_key)
117
+ add_resource_to_table(resource, title_key, idx)
94
118
  create_resource_aliases(resource)
95
119
 
96
120
  resource.catalog = self if resource.respond_to?(:catalog=)
@@ -98,9 +122,9 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
98
122
  end
99
123
  private :add_one_resource
100
124
 
101
- def add_resource_to_table(resource, title_key)
125
+ def add_resource_to_table(resource, title_key, idx)
102
126
  @resource_table[title_key] = resource
103
- @resources << title_key
127
+ @resources.insert(idx, title_key)
104
128
  end
105
129
  private :add_resource_to_table
106
130
 
@@ -245,7 +269,7 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
245
269
  host_config
246
270
  end
247
271
 
248
- def initialize(name = nil, environment = Puppet::Node::Environment::NONE)
272
+ def initialize(name = nil, environment = Puppet::Node::Environment::NONE, code_id = nil)
249
273
  super()
250
274
  @name = name
251
275
  @classes = []
@@ -256,6 +280,7 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
256
280
  @host_config = true
257
281
  @environment_instance = environment
258
282
  @environment = environment.to_s
283
+ @code_id = code_id
259
284
 
260
285
  @aliases = {}
261
286
 
@@ -293,7 +318,8 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
293
318
  remove_vertex!(resource) if vertex?(resource)
294
319
  @relationship_graph.remove_vertex!(resource) if @relationship_graph and @relationship_graph.vertex?(resource)
295
320
  @resources.delete(title_key)
296
- resource.remove
321
+ # Only Puppet::Type kind of resources respond to :remove, not Puppet::Resource
322
+ resource.remove if resource.respond_to?(:remove)
297
323
  end
298
324
  end
299
325
 
@@ -313,7 +339,15 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
313
339
  res.catalog = self
314
340
  title_key = [res.type, res.title.to_s]
315
341
  uniqueness_key = [res.type, res.uniqueness_key].flatten
316
- @resource_table[title_key] || @resource_table[uniqueness_key]
342
+ result = @resource_table[title_key] || @resource_table[uniqueness_key]
343
+ if ! result && res.resource_type && res.resource_type.is_capability?
344
+ # @todo lutter 2015-03-10: this assumes that it is legal to just
345
+ # mention a capability resource in code and have it automatically
346
+ # made available, even if the current component does not require it
347
+ result = Puppet::Resource::CapabilityFinder.find(environment, code_id, res)
348
+ add_resource(result) if result
349
+ end
350
+ result
317
351
  end
318
352
 
319
353
  def resource_refs
@@ -341,6 +375,10 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
341
375
  result.version = version
342
376
  end
343
377
 
378
+ if code_id = data['code_id']
379
+ result.code_id = code_id
380
+ end
381
+
344
382
  if environment = data['environment']
345
383
  result.environment = environment
346
384
  result.environment_instance = Puppet::Node::Environment.remote(environment.to_sym)
@@ -381,6 +419,7 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
381
419
  'tags' => tags,
382
420
  'name' => name,
383
421
  'version' => version,
422
+ 'code_id' => code_id,
384
423
  'environment' => environment.to_s,
385
424
  'resources' => @resources.collect { |v| @resource_table[v].to_data_hash },
386
425
  'edges' => edges. collect { |e| e.to_data_hash },
@@ -496,6 +535,7 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
496
535
  result = self.class.new(self.name, self.environment_instance)
497
536
 
498
537
  result.version = self.version
538
+ result.code_id = self.code_id
499
539
 
500
540
  map = {}
501
541
  resources.each do |resource|