puppet 4.2.3 → 4.3.0

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
@@ -20,7 +20,7 @@ class Puppet::Provider::Package::Windows
20
20
  inst = installer
21
21
 
22
22
  if inst.ProductState(name) == INSTALLSTATE_DEFAULT
23
- MsiPackage.new(values['DisplayName'],
23
+ MsiPackage.new(get_display_name(values),
24
24
  values['DisplayVersion'],
25
25
  name, # productcode
26
26
  inst.ProductInfo(name, 'PackageCode'))
@@ -31,8 +31,9 @@ class Puppet::Provider::Package::Windows
31
31
  # Is this a valid MSI package we should manage?
32
32
  def self.valid?(name, values)
33
33
  # See http://community.spiceworks.com/how_to/show/2238
34
- !!(values['DisplayName'] and values['DisplayName'].length > 0 and
35
- values['WindowsInstaller'] == 1 and # DWORD
34
+ displayName = get_display_name(values)
35
+ !!(displayName && displayName.length > 0 &&
36
+ values['WindowsInstaller'] == 1 && # DWORD
36
37
  name =~ /\A\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}\Z/i)
37
38
  end
38
39
 
@@ -71,7 +71,7 @@ class Puppet::Provider::Package::Windows
71
71
 
72
72
  def self.replace_forward_slashes(value)
73
73
  if value.include?('/')
74
- value.gsub!('/', "\\")
74
+ value.gsub!('/', "\\")
75
75
  Puppet.debug('Package source parameter contained /s - replaced with \\s')
76
76
  end
77
77
  value
@@ -81,6 +81,14 @@ class Puppet::Provider::Package::Windows
81
81
  value.include?(' ') ? %Q["#{value.gsub(/"/, '\"')}"] : value
82
82
  end
83
83
 
84
+ def self.get_display_name(values)
85
+ return if values.nil?
86
+ return values['DisplayName'] if values['DisplayName'] && values['DisplayName'].length > 0
87
+ return values['QuietDisplayName'] if values['QuietDisplayName'] && values['QuietDisplayName'].length > 0
88
+
89
+ ''
90
+ end
91
+
84
92
  def initialize(name, version)
85
93
  @name = name
86
94
  @version = version
@@ -11,7 +11,7 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
11
11
 
12
12
  has_feature :install_options, :versionable, :virtual_packages
13
13
 
14
- commands :yum => "yum", :rpm => "rpm"
14
+ commands :cmd => "yum", :rpm => "rpm"
15
15
 
16
16
  if command('rpm')
17
17
  confine :true => begin
@@ -67,7 +67,7 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
67
67
  # @return [Hash<String, Array<Hash<String, String>>>] All packages that were
68
68
  # found with a list of found versions for each package.
69
69
  def self.check_updates(enablerepo, disablerepo, disableexcludes)
70
- args = [command(:yum), 'check-update']
70
+ args = [command(:cmd), 'check-update']
71
71
  args.concat(enablerepo.map { |repo| ["--enablerepo=#{repo}"] }.flatten)
72
72
  args.concat(disablerepo.map { |repo| ["--disablerepo=#{repo}"] }.flatten)
73
73
  args.concat(disableexcludes.map { |repo| ["--disableexcludes=#{repo}"] }.flatten)
@@ -78,9 +78,9 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
78
78
  if output.exitstatus == 100
79
79
  updates = parse_updates(output)
80
80
  elsif output.exitstatus == 0
81
- self.debug "yum check-update exited with 0; no package updates available."
81
+ self.debug "#{command(:cmd)} check-update exited with 0; no package updates available."
82
82
  else
83
- self.warn "Could not check for updates, 'yum check-update' exited with #{output.exitstatus}"
83
+ self.warn "Could not check for updates, '#{command(:cmd)} check-update' exited with #{output.exitstatus}"
84
84
  end
85
85
  updates
86
86
  end
@@ -91,7 +91,7 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
91
91
 
92
92
  updates = Hash.new { |h, k| h[k] = [] }
93
93
  body.split.each_slice(3) do |tuple|
94
- break if tuple[0] =~ /^Obsoleting/
94
+ break if tuple[0] =~ /^(Obsoleting|Security:)/
95
95
  hash = update_to_hash(*tuple[0..1])
96
96
  # Create entries for both the package name without a version and a
97
97
  # version since yum considers those as mostly interchangeable.
@@ -126,11 +126,16 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
126
126
  @latest_versions = nil
127
127
  end
128
128
 
129
+ def self.error_level
130
+ '0'
131
+ end
132
+
129
133
  def install
130
134
  wanted = @resource[:name]
135
+ error_level = self.class.error_level
131
136
  # If not allowing virtual packages, do a query to ensure a real package exists
132
137
  unless @resource.allow_virtual?
133
- yum *['-d', '0', '-e', '0', '-y', install_options, :list, wanted].compact
138
+ execute([command(:cmd), '-d', '0', '-e', error_level, '-y', install_options, :list, wanted].compact)
134
139
  end
135
140
 
136
141
  should = @resource.should(:ensure)
@@ -154,8 +159,8 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
154
159
  # Yum on el-4 and el-5 returns exit status 0 when trying to install a package it doesn't recognize;
155
160
  # ensure we capture output to check for errors.
156
161
  no_debug = if Facter.value(:operatingsystemmajrelease).to_i > 5 then ["-d", "0"] else [] end
157
- args = no_debug + ["-e", "0", "-y", install_options, operation, wanted].compact
158
- output = yum *args
162
+ command = [command(:cmd)] + no_debug + ["-e", error_level, "-y", install_options, operation, wanted].compact
163
+ output = execute(command)
159
164
 
160
165
  if output =~ /^No package #{wanted} available\.$/
161
166
  raise Puppet::Error, "Could not find package #{wanted}"
@@ -194,7 +199,7 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
194
199
  end
195
200
 
196
201
  def purge
197
- yum "-y", :erase, @resource[:name]
202
+ execute([command(:cmd), "-y", :erase, @resource[:name]])
198
203
  end
199
204
 
200
205
  # parse a yum "version" specification
@@ -5,7 +5,7 @@ Puppet::Type.type(:service).provide :bsd, :parent => :init do
5
5
  Uses `rc.conf.d` for service enabling and disabling.
6
6
  EOT
7
7
 
8
- confine :operatingsystem => [:freebsd, :netbsd, :dragonfly]
8
+ confine :operatingsystem => [:freebsd, :dragonfly]
9
9
 
10
10
  def rcconf_dir
11
11
  '/etc/rc.conf.d'
@@ -63,4 +63,25 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do
63
63
  update_rc "-f", @resource[:name], "remove"
64
64
  update_rc @resource[:name], "defaults"
65
65
  end
66
+
67
+ def statuscmd
68
+ os = Facter.value(:operatingsystem).downcase
69
+
70
+ if os == 'debian'
71
+ majversion = Facter.value(:operatingsystemmajrelease).to_i
72
+ else
73
+ majversion = Facter.value(:operatingsystemmajrelease).split('.')[0].to_i
74
+ end
75
+
76
+
77
+ if ((os == 'debian' && majversion >= 8) || (os == 'ubuntu' && majversion >= 15))
78
+ # SysVInit scripts will always return '0' for status when the service is masked,
79
+ # even if the service is actually stopped. Use the SysVInit-Systemd compatibility
80
+ # layer to determine the actual status. This is only necessary when the SysVInit
81
+ # version of a service is queried. I.e, 'ntp' instead of 'ntp.service'.
82
+ (@resource[:hasstatus] == :true) && ["systemctl", "is-active", @resource[:name]]
83
+ else
84
+ super
85
+ end
86
+ end
66
87
  end
@@ -16,6 +16,12 @@ Puppet::Type.type(:service).provide :init, :parent => :base do
16
16
  end
17
17
  end
18
18
 
19
+ # Debian and Ubuntu should use the Debian provider.
20
+ confine :true => begin
21
+ os = Facter.value(:operatingsystem).downcase
22
+ !(os == 'debian' || os == 'ubuntu')
23
+ end
24
+
19
25
  # We can't confine this here, because the init path can be overridden.
20
26
  #confine :exists => defpath
21
27
 
@@ -0,0 +1,51 @@
1
+ Puppet::Type.type(:service).provide :rcng, :parent => :bsd do
2
+ desc <<-EOT
3
+ RCng service management with rc.d
4
+ EOT
5
+
6
+ defaultfor :operatingsystem => [:netbsd, :cargos]
7
+ confine :operatingsystem => [:netbsd, :cargos]
8
+
9
+ def self.defpath
10
+ "/etc/rc.d"
11
+ end
12
+
13
+ # if the service file exists in rc.conf.d AND matches an expected pattern
14
+ # then it's already enabled
15
+ def enabled?
16
+ rcfile = File.join(rcconf_dir, @resource[:name])
17
+ if Puppet::FileSystem.exist?(rcfile)
18
+ File.open(rcfile).readlines.each do |line|
19
+ # Now look for something that looks like "service=${service:=YES}" or "service=YES"
20
+ if line.match(/^\s*#{@resource[:name]}=(?:YES|\${#{@resource[:name]}:=YES})/)
21
+ return :true
22
+ end
23
+ end
24
+ end
25
+
26
+ :false
27
+ end
28
+
29
+ # enable service by creating a service file under rc.conf.d with the
30
+ # proper contents, or by modifying it's contents to to enable the service.
31
+ def enable
32
+ Dir.mkdir(rcconf_dir) if not Puppet::FileSystem.exist?(rcconf_dir)
33
+ rcfile = File.join(rcconf_dir, @resource[:name])
34
+ if Puppet::FileSystem.exist?(rcfile)
35
+ newcontents = []
36
+ File.open(rcfile).readlines.each do |line|
37
+ if line.match(/^\s*#{@resource[:name]}=(NO|\$\{#{@resource[:name]}:NO\})/)
38
+ line = "#{@resource[:name]}=${#{@resource[:name]}:=YES}"
39
+ end
40
+ newcontents.push(line)
41
+ end
42
+ Puppet::Util.replace_file(rcfile, 0644) do |f|
43
+ f.puts newcontents
44
+ end
45
+ else
46
+ Puppet::Util.replace_file(rcfile, 0644) do |f|
47
+ f.puts "%s=${%s:=YES}\n" % [@resource[:name], @resource[:name]]
48
+ end
49
+ end
50
+ end
51
+ end
@@ -8,7 +8,8 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init, :source => :init
8
8
 
9
9
  commands :chkconfig => "/sbin/chkconfig", :service => "/sbin/service"
10
10
 
11
- defaultfor :osfamily => [:redhat, :suse]
11
+ defaultfor :osfamily => :redhat
12
+ defaultfor :osfamily => :suse, :operatingsystemmajrelease => ["10", "11"]
12
13
 
13
14
  # Remove the symlinks
14
15
  def disable
@@ -1,3 +1,5 @@
1
+ require 'timeout'
2
+
1
3
  # Solaris 10 SMF-style services.
2
4
  Puppet::Type.type(:service).provide :smf, :parent => :base do
3
5
  desc <<-EOT
@@ -32,7 +34,7 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do
32
34
  end
33
35
 
34
36
  def self.instances
35
- svcs.split("\n").select{|l| l !~ /^legacy_run/ }.collect do |line|
37
+ svcs("-H").split("\n").select{|l| l !~ /^legacy_run/ }.collect do |line|
36
38
  state,stime,fmri = line.split(/\s+/)
37
39
  status = case state
38
40
  when /online/; :running
@@ -74,6 +76,45 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do
74
76
  end
75
77
  end
76
78
 
79
+ # Wait for the service to transition into the specified state before returning.
80
+ # This is necessary due to the asynchronous nature of SMF services.
81
+ # desired_state should be online, offline, disabled, or uninitialized.
82
+ # See PUP-5474 for long-term solution to this issue.
83
+ def wait(*desired_state)
84
+ Timeout.timeout(60) do
85
+ loop do
86
+ states = self.service_states
87
+ break if desired_state.include?(states[0]) && states[1] == '-'
88
+ sleep(1)
89
+ end
90
+ end
91
+ rescue Timeout::Error
92
+ raise Puppet::Error.new("Timed out waiting for #{@resource[:name]} to transition states")
93
+ end
94
+
95
+ def start
96
+ # Wait for the service to actually start before returning.
97
+ super
98
+ self.wait('online')
99
+ end
100
+
101
+ def stop
102
+ # Wait for the service to actually stop before returning.
103
+ super
104
+ self.wait('offline', 'disabled', 'uninitialized')
105
+ end
106
+
107
+ def restart
108
+ # Wait for the service to actually start before returning.
109
+ super
110
+ self.wait('online')
111
+ end
112
+
113
+ # Determine the current and next states of a service.
114
+ def service_states
115
+ svcs("-H", "-o", "state,nstate", @resource[:name]).chomp.split
116
+ end
117
+
77
118
  def status
78
119
  if @resource[:status]
79
120
  super
@@ -83,7 +124,7 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do
83
124
  begin
84
125
  # get the current state and the next state, and if the next
85
126
  # state is set (i.e. not "-") use it for state comparison
86
- states = svcs("-H", "-o", "state,nstate", @resource[:name]).chomp.split
127
+ states = service_states
87
128
  state = states[1] == "-" ? states[0] : states[1]
88
129
  rescue Puppet::ExecutionFailure
89
130
  info "Could not get status on service #{self.name}"
@@ -1,3 +1,5 @@
1
+ require 'timeout'
2
+
1
3
  # AIX System Resource controller (SRC)
2
4
  Puppet::Type.type(:service).provide :src, :parent => :base do
3
5
 
@@ -63,6 +65,31 @@ Puppet::Type.type(:service).provide :src, :parent => :base do
63
65
  rmitab(@resource[:name])
64
66
  end
65
67
 
68
+ # Wait for the service to transition into the specified state before returning.
69
+ # This is necessary due to the asynchronous nature of AIX services.
70
+ # desired_state should either be :running or :stopped.
71
+ def wait(desired_state)
72
+ Timeout.timeout(60) do
73
+ loop do
74
+ status = self.status
75
+ break if status == desired_state.to_sym
76
+ sleep(1)
77
+ end
78
+ end
79
+ rescue Timeout::Error
80
+ raise Puppet::Error.new("Timed out waiting for #{@resource[:name]} to transition states")
81
+ end
82
+
83
+ def start
84
+ super
85
+ self.wait(:running)
86
+ end
87
+
88
+ def stop
89
+ super
90
+ self.wait(:stopped)
91
+ end
92
+
66
93
  def restart
67
94
  execute([command(:lssrc), "-Ss", @resource[:name]]).each_line do |line|
68
95
  args = line.split(":")
@@ -10,7 +10,7 @@ Puppet::Type.type(:service).provide :systemd, :parent => :base do
10
10
  defaultfor :osfamily => [:archlinux]
11
11
  defaultfor :osfamily => :redhat, :operatingsystemmajrelease => "7"
12
12
  defaultfor :osfamily => :redhat, :operatingsystem => :fedora
13
- defaultfor :osfamily => :suse, :operatingsystemmajrelease => ["12", "13"]
13
+ defaultfor :osfamily => :suse
14
14
  defaultfor :operatingsystem => :debian, :operatingsystemmajrelease => "8"
15
15
  defaultfor :operatingsystem => :ubuntu, :operatingsystemmajrelease => "15.04"
16
16
 
@@ -32,7 +32,14 @@ Puppet::Type.type(:service).provide :systemd, :parent => :base do
32
32
  end
33
33
 
34
34
  def get_start_link_count
35
- Dir.glob("/etc/rc*.d/S??#{@resource[:name]}").length
35
+ # Start links don't include '.service'. Just search for the service name.
36
+ if @resource[:name].match(/\.service/)
37
+ link_name = @resource[:name].split('.')[0]
38
+ else
39
+ link_name = @resource[:name]
40
+ end
41
+
42
+ Dir.glob("/etc/rc*.d/S??#{link_name}").length
36
43
  end
37
44
 
38
45
  def enabled?
@@ -59,7 +66,7 @@ Puppet::Type.type(:service).provide :systemd, :parent => :base do
59
66
  # flapping when simply trying to disable a masked service.
60
67
  return :mask if (@resource[:enable] == :mask) && (svc_info[:LoadState] == 'masked')
61
68
  return :true if svc_info[:UnitFileState] == 'enabled'
62
- if Facter.value(:osfamily) == 'debian'
69
+ if Facter.value(:osfamily).downcase == 'debian'
63
70
  ret = debian_enabled?(svc_info)
64
71
  return ret if ret
65
72
  end
@@ -72,6 +79,11 @@ Puppet::Type.type(:service).provide :systemd, :parent => :base do
72
79
  return :false
73
80
  end
74
81
 
82
+ # This method is required for Debian systems due to the way the SysVInit-Systemd
83
+ # compatibility layer works. When we are trying to manage a service which does not
84
+ # have a Systemd unit file, we need to go through the old init script to determine
85
+ # whether it is enabled or not. See PUP-5016 for more details.
86
+ #
75
87
  def debian_enabled?(svc_info)
76
88
  # If UnitFileState == UnitFileState then we query the older way.
77
89
  if svc_info[:UnitFileState] == 'UnitFileState'
@@ -1,17 +1,8 @@
1
1
  require 'puppet/provider/parsedfile'
2
2
 
3
- known = nil
4
- case Facter.value(:operatingsystem)
5
- when "Darwin"; known = "/etc/ssh_known_hosts"
6
- else
7
- known = "/etc/ssh/ssh_known_hosts"
8
- end
9
-
10
-
11
3
  Puppet::Type.type(:sshkey).provide(
12
4
  :parsed,
13
5
  :parent => Puppet::Provider::ParsedFile,
14
- :default_target => known,
15
6
  :filetype => :flat
16
7
  ) do
17
8
  desc "Parse and generate host-wide known hosts files for SSH."
@@ -36,5 +27,24 @@ Puppet::Type.type(:sshkey).provide(
36
27
  def self.default_mode
37
28
  0644
38
29
  end
30
+
31
+ def self.default_target
32
+ case Facter.value(:operatingsystem)
33
+ when "Darwin"
34
+ # Versions 10.11 and up use /etc/ssh/ssh_known_hosts
35
+ version = Facter.value(:macosx_productversion_major)
36
+ if version
37
+ if Puppet::Util::Package.versioncmp(version, '10.11') >= 0
38
+ "/etc/ssh/ssh_known_hosts"
39
+ else
40
+ "/etc/ssh_known_hosts"
41
+ end
42
+ else
43
+ "/etc/ssh_known_hosts"
44
+ end
45
+ else
46
+ "/etc/ssh/ssh_known_hosts"
47
+ end
48
+ end
39
49
  end
40
50
 
@@ -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
  "