puppet 4.2.3-x64-mingw32 → 4.3.0-x64-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
@@ -0,0 +1,356 @@
1
+ require 'puppet/application'
2
+ require 'puppet/pops'
3
+ require 'puppet/node'
4
+ require 'puppet/parser/compiler'
5
+
6
+ class Puppet::Application::Lookup < Puppet::Application
7
+
8
+ RUN_HELP = "Run 'puppet lookup --help' for more details".freeze
9
+ DEEP_MERGE_OPTIONS = '--knock-out-prefix, --sort-merged-arrays, --unpack-arrays, and --merge-hash-arrays'.freeze
10
+
11
+ run_mode :master
12
+
13
+ # Options for lookup
14
+ option('--merge TYPE') do |arg|
15
+ if %w{unique hash deep}.include?(arg)
16
+ options[:merge] = arg
17
+ else
18
+ raise "The --merge option only accepts 'unique', 'hash', or 'deep'.\n#{RUN_HELP}"
19
+ end
20
+ end
21
+
22
+ option('--debug', '-d')
23
+
24
+ option('--verbose', '-v')
25
+
26
+ option('--render-as FORMAT') do |format|
27
+ options[:render_as] = format.downcase.to_sym
28
+ end
29
+
30
+ option('--type TYPE_STRING') do |arg|
31
+ options[:type] = arg
32
+ end
33
+
34
+ option('--knock-out-prefix PREFIX_STRING') do |arg|
35
+ options[:prefix] = arg
36
+ end
37
+
38
+ option('--sort-merge-arrays')
39
+
40
+ option('--unpack-arrays') do |arg|
41
+ options[:unpack_arrays] = arg
42
+ end
43
+
44
+ option('--merge-hash-arrays')
45
+
46
+ option('--explain')
47
+
48
+ option('--default VALUE') do |arg|
49
+ options[:default_value] = arg
50
+ end
51
+
52
+ # not yet supported
53
+ option('--trusted')
54
+
55
+ # Options for facts/scope
56
+ option('--node NODE_NAME') do |arg|
57
+ options[:node] = arg
58
+ end
59
+
60
+ option('--facts FACT_FILE') do |arg|
61
+ if %w{.yaml .yml .json}.include?(arg.match(/\.[^.]*$/)[0])
62
+ options[:fact_file] = arg
63
+ else
64
+ raise "The --fact file only accepts yaml and json files.\n#{RUN_HELP}"
65
+ end
66
+ end
67
+
68
+ # Sets up the 'node_cache_terminus' default to use the Write Only Yaml terminus :write_only_yaml.
69
+ # If this is not wanted, the setting ´node_cache_terminus´ should be set to nil.
70
+ # @see Puppet::Node::WriteOnlyYaml
71
+ # @see #setup_node_cache
72
+ # @see puppet issue 16753
73
+ #
74
+ def app_defaults
75
+ super.merge({
76
+ :node_cache_terminus => :write_only_yaml,
77
+ :facts_terminus => 'yaml'
78
+ })
79
+ end
80
+
81
+ def setup_logs
82
+ # This sets up logging based on --debug or --verbose if they are set in `options`
83
+ set_log_level
84
+
85
+ # This uses console for everything that is not a compilation
86
+ Puppet::Util::Log.newdestination(:console)
87
+ end
88
+
89
+ def setup_terminuses
90
+ require 'puppet/file_serving/content'
91
+ require 'puppet/file_serving/metadata'
92
+
93
+ Puppet::FileServing::Content.indirection.terminus_class = :file_server
94
+ Puppet::FileServing::Metadata.indirection.terminus_class = :file_server
95
+
96
+ Puppet::FileBucket::File.indirection.terminus_class = :file
97
+ end
98
+
99
+ def setup_ssl
100
+ # Configure all of the SSL stuff.
101
+ if Puppet::SSL::CertificateAuthority.ca?
102
+ Puppet::SSL::Host.ca_location = :local
103
+ Puppet.settings.use :ca
104
+ Puppet::SSL::CertificateAuthority.instance
105
+ else
106
+ Puppet::SSL::Host.ca_location = :none
107
+ end
108
+ # These lines are not on stable (seems like a copy was made from master)
109
+ #
110
+ # Puppet::SSL::Oids.register_puppet_oids
111
+ # Puppet::SSL::Oids.load_custom_oid_file(Puppet[:trusted_oid_mapping_file])
112
+ end
113
+
114
+ # Sets up a special node cache "write only yaml" that collects and stores node data in yaml
115
+ # but never finds or reads anything (this since a real cache causes stale data to be served
116
+ # in circumstances when the cache can not be cleared).
117
+ # @see puppet issue 16753
118
+ # @see Puppet::Node::WriteOnlyYaml
119
+ # @return [void]
120
+ def setup_node_cache
121
+ Puppet::Node.indirection.cache_class = Puppet[:node_cache_terminus]
122
+ end
123
+
124
+ def setup
125
+ setup_logs
126
+
127
+ exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs?
128
+
129
+ Puppet.settings.use :main, :master, :ssl, :metrics
130
+
131
+ setup_terminuses
132
+
133
+ # TODO: Do we need this in lookup? It sets up a write only cache
134
+ setup_node_cache
135
+
136
+ setup_ssl
137
+ end
138
+
139
+ def help
140
+ <<-'HELP'
141
+
142
+ puppet-lookup(8) -- Data in modules lookup function
143
+ ========
144
+
145
+ SYNOPSIS
146
+ --------
147
+ The lookup command is used for debugging and testing a given data
148
+ configuration. For a given data key, lookup will produce either a
149
+ value or an explanation of how that value was obtained on the standard
150
+ output stream with the specified rendering format. Lookup is designed
151
+ to be run on a puppet master or a node in a masterless setup.
152
+
153
+ USAGE
154
+ -----
155
+ puppet lookup [--help] [--type <TYPESTRING>] [--merge unique|hash|deep]
156
+ [--knock-out-prefix <PREFIX-STRING>] [--sort-merged-arrays]
157
+ [--unpack-arrays <STRING-VALUE>] [--merge-hash-arrays] [--explain]
158
+ [--default <VALUE>] [--node <NODE-NAME>] [--facts <FILE>]
159
+ [--render-as s|json|yaml|binary|msgpack] <keys>
160
+
161
+ DESCRIPTION
162
+ -----------
163
+ The lookup command is a CLI interface for the puppet lookup function.
164
+ When given one or more keys, the lookup command will return the first
165
+ value found when run from the puppet master or a masterless node.
166
+
167
+ When an explanation has not been requested and
168
+ lookup is simply looking up a value, the application will exit with 0
169
+ if a value was found and 1 otherwise. When an explanation is requested,
170
+ lookup will always exit with 0 unless there is a major error.
171
+
172
+ The other options are as passed into the lookup function, and the effect
173
+ they have on the lookup is described in more detail in the header
174
+ for the lookup function:
175
+
176
+ http://links.puppetlabs.com/lookup-docs
177
+
178
+ OPTIONS
179
+ -------
180
+ These options and their effects are decribed in more detail in
181
+ the puppet lookup function linked to above.
182
+
183
+ * --help:
184
+ Print this help message.
185
+
186
+ * --type <TYPESTRING>:
187
+ Assert that the value has the specified type.
188
+
189
+ * --merge unique|hash|deep:
190
+ Specify the merge strategy. 'hash' performs a simple hash-merge by
191
+ overwriting keys of lower lookup priority. 'unique' appends everything
192
+ to an array containing no nested arrays and where all duplicates have been
193
+ removed. 'deep' Performs a deep merge on values of Array and Hash type. There
194
+ are additional option flags that can be used with 'deep'.
195
+
196
+ * --knock_out_prefix <PREFIX-STRING>
197
+ Can be used with the 'deep' merge strategy. Specify string value to signify
198
+ prefix which deletes elements from existing element.
199
+
200
+ * --sort_merged_arrays
201
+ Can be used with the 'deep' merge strategy. When this flag is used all
202
+ merged arrays will be sorted.
203
+
204
+ * --unpack_arrays <STRING-VALUE>
205
+ Can be used with the 'deep' merge strategy. Specify a string value used
206
+ as a deliminator to join all array values and then split them again.
207
+
208
+ * --merge_hash_arrays
209
+ Can be used with the 'deep' merge strategy. When this flag is used arrays
210
+ and hashes will be merged.
211
+
212
+ * --explain
213
+ Print an explanation for the details of how the lookup performed rather
214
+ than the value returned for the key. The explaination will describe how
215
+ the result was obtained or why lookup failed to obtain the result.
216
+
217
+ * --default <VALUE>
218
+ A value produced if no value was found in the lookup.
219
+
220
+ * --node <NODE-NAME>
221
+ Specify node which defines the scope in which the lookup will be performed.
222
+ If a node is not given, lookup will default to the machine from which the
223
+ lookup is being run (which should be the master).
224
+
225
+ * --facts <FILE>
226
+ Specify a .json, or .yaml file holding key => value mappings that will
227
+ override the facts for the current node. Any facts not specified by the
228
+ user will maintain their original value.
229
+
230
+ * --render-as s|json|yaml|binary|msgpack
231
+ Determines how the results will be rendered to the standard output where
232
+ s means plain text. The default when lookup is producing a value is yaml
233
+ and the default when producing an explanation is s.
234
+
235
+ EXAMPLE
236
+ -------
237
+ If you wanted to lookup 'key_name' within the scope of the master, you would
238
+ call lookup like this:
239
+ $ puppet lookup key_name
240
+
241
+ If you wanted to lookup 'key_name' within the scope of the agent.local node,
242
+ you would call lookup like this:
243
+ $ puppet lookup --node agent.local key_name
244
+
245
+ If you wanted to get the first value found for 'key_name_one' and 'key_name_two'
246
+ within the scope of the agent.local node while merging values and knocking out
247
+ the prefix 'foo' while merging, you would call lookup like this:
248
+ $ puppet lookup --node agent.local --merge deep --knock_out_prefix foo key_name_one key_name_two
249
+
250
+ If you wanted to lookup 'key_name' within the scope of the agent.local node,
251
+ and return a default value of 'bar' if nothing was found, you would call
252
+ lookup like this:
253
+ $ puppet lookup --node agent.local --default bar key_name
254
+
255
+ If you wanted to see an explanation of how the value for 'key_name' would be
256
+ obtained in the context of the agent.local node, you would call lookup like this:
257
+ $ puppet lookup --node agent.local --explain key_name
258
+
259
+ COPYRIGHT
260
+ ---------
261
+ Copyright (c) 2015 Puppet Labs, LLC Licensed under the Apache 2.0 License
262
+
263
+
264
+ HELP
265
+ end
266
+
267
+ def main
268
+ keys = command_line.args
269
+ raise 'No keys were given to lookup.' if keys.empty?
270
+
271
+ #unless options[:node]
272
+ # raise "No node was given via the '--node' flag for the scope of the lookup.\n#{RUN_HELP}"
273
+ #end
274
+
275
+ if (options[:sort_merge_arrays] || options[:merge_hash_arrays] || options[:prefix] || options[:unpack_arrays]) && options[:merge] != 'deep'
276
+ raise "The options #{DEEP_MERGE_OPTIONS} are only available with '--merge deep'\n#{RUN_HELP}"
277
+ end
278
+
279
+ use_default_value = !options[:default_value].nil?
280
+ merge_options = nil
281
+
282
+ if options[:merge]
283
+ if options[:merge] == 'deep'
284
+ merge_options = {'strategy' => 'deep',
285
+ 'sort_merge_arrays' => !options[:sort_merge_arrays].nil?,
286
+ 'merge_hash_arrays' => !options[:merge_hash_arrays].nil?}
287
+
288
+ if options[:prefix]
289
+ merge_options.merge({'prefix' => options[:prefix]})
290
+ end
291
+
292
+ if options[:unpack_arrays]
293
+ merge_options.merge({'unpack_arrays' => options[:unpack_arrays]})
294
+ end
295
+
296
+ else
297
+ merge_options = {'strategy' => options[:merge]}
298
+ end
299
+ end
300
+
301
+ explain = !!options[:explain]
302
+
303
+ # Format defaults to text (:s) when producing an explanation and :yaml when producing the value
304
+ format = options[:render_as] || (explain ? :s : :yaml)
305
+ renderer = Puppet::Network::FormatHandler.format(format == :json ? :pson : format)
306
+ raise "Unknown rendering format '#{format}'" if renderer.nil?
307
+
308
+ type = options.include?(:type) ? Puppet::Pops::Types::TypeParser.new.parse(options[:type]) : nil
309
+
310
+ generate_scope do |scope|
311
+ lookup_invocation = Puppet::Pops::Lookup::Invocation.new(scope, {}, {}, explain)
312
+ begin
313
+ result = Puppet::Pops::Lookup.lookup(keys, type, options[:default_value], use_default_value, merge_options, lookup_invocation)
314
+ puts renderer.render(result) unless explain
315
+ rescue Puppet::DataBinding::LookupError
316
+ exit(1) unless explain
317
+ end
318
+ puts format == :s ? lookup_invocation.explainer.to_s : renderer.render(lookup_invocation.explainer.to_hash) if explain
319
+ end
320
+ end
321
+
322
+ def generate_scope
323
+ if options[:node]
324
+ node = options[:node]
325
+ else
326
+ node = Puppet[:node_name_value]
327
+
328
+ # If we want to lookup the node we are currently on
329
+ # we must returning these settings to their default values
330
+ Puppet.settings[:facts_terminus] = 'facter'
331
+ Puppet.settings[:node_cache_terminus] = nil
332
+ end
333
+
334
+ node = Puppet::Node.indirection.find(node) unless node.is_a?(Puppet::Node) # to allow unit tests to pass a node instance
335
+
336
+ fact_file = options[:fact_file]
337
+
338
+ if fact_file
339
+ original_facts = node.facts.values
340
+ if fact_file.end_with?("json")
341
+ given_facts = JSON.parse(File.read(fact_file))
342
+ else
343
+ given_facts = YAML.load(File.read(fact_file))
344
+ end
345
+
346
+ unless given_facts.instance_of?(Hash)
347
+ raise "Incorrect formatted data in #{fact_file} given via the --facts flag"
348
+ end
349
+
350
+ node.facts.values = original_facts.merge(given_facts)
351
+ end
352
+
353
+ compiler = Puppet::Parser::Compiler.new(node)
354
+ compiler.compile { |catalog| yield(compiler.topscope); catalog }
355
+ end
356
+ end
@@ -295,6 +295,9 @@ Copyright (c) 2012 Puppet Labs, LLC Licensed under the Apache 2.0 License
295
295
  daemon.server = Puppet::Network::Server.new(Puppet[:bindaddress], Puppet[:masterport])
296
296
  daemon.daemonize if Puppet[:daemonize]
297
297
 
298
+ # Setup signal traps immediately after daemonization so we clean up the daemon
299
+ daemon.set_signal_traps
300
+
298
301
  announce_start_of_master
299
302
 
300
303
  daemon.start
@@ -154,12 +154,14 @@ class Puppet::Configurer
154
154
  query_options = get_facts(options)
155
155
  end
156
156
 
157
+ configured_environment = Puppet[:environment] if Puppet.settings.set_by_config?(:environment)
158
+
157
159
  # We only need to find out the environment to run in if we don't already have a catalog
158
160
  unless options[:catalog]
159
161
  begin
160
162
  if node = Puppet::Node.indirection.find(Puppet[:node_name_value],
161
163
  :environment => Puppet::Node::Environment.remote(@environment),
162
- :configured_environment => Puppet[:environment],
164
+ :configured_environment => configured_environment,
163
165
  :ignore_cache => true,
164
166
  :transaction_uuid => @transaction_uuid,
165
167
  :fail_on_404 => true)
@@ -171,10 +173,12 @@ class Puppet::Configurer
171
173
  end
172
174
 
173
175
  if node.environment.to_s != @environment
174
- Puppet.notice "Local environment: \"#{@environment}\" doesn't match server specified node environment \"#{node.environment}\", switching agent to \"#{node.environment}\"."
176
+ Puppet.notice "Local environment: '#{@environment}' doesn't match server specified node environment '#{node.environment}', switching agent to '#{node.environment}'."
175
177
  @environment = node.environment.to_s
176
178
  report.environment = @environment
177
179
  query_options = nil
180
+ else
181
+ Puppet.info "Using configured environment '#{@environment}'"
178
182
  end
179
183
  end
180
184
  rescue StandardError => detail
@@ -197,7 +201,7 @@ class Puppet::Configurer
197
201
 
198
202
  query_options = get_facts(options) unless query_options
199
203
  query_options[:transaction_uuid] = @transaction_uuid
200
- query_options[:configured_environment] = Puppet[:environment]
204
+ query_options[:configured_environment] = configured_environment
201
205
 
202
206
  unless catalog = prepare_and_retrieve_catalog(options, query_options)
203
207
  return nil
@@ -212,13 +216,13 @@ class Puppet::Configurer
212
216
  if tries > 3
213
217
  raise Puppet::Error, "Catalog environment didn't stabilize after #{tries} fetches, aborting run"
214
218
  end
215
- Puppet.notice "Local environment: \"#{@environment}\" doesn't match server specified environment \"#{catalog.environment}\", restarting agent run with environment \"#{catalog.environment}\""
219
+ Puppet.notice "Local environment: '#{@environment}' doesn't match server specified environment '#{catalog.environment}', restarting agent run with environment '#{catalog.environment}'"
216
220
  @environment = catalog.environment
217
221
  report.environment = @environment
218
222
 
219
223
  query_options = get_facts(options)
220
224
  query_options[:transaction_uuid] = @transaction_uuid
221
- query_options[:configured_environment] = Puppet[:environment]
225
+ query_options[:configured_environment] = configured_environment
222
226
 
223
227
  return nil unless catalog = prepare_and_retrieve_catalog(options, query_options)
224
228
  tries += 1
@@ -20,6 +20,7 @@ class Puppet::Context
20
20
  # @api private
21
21
  def initialize(initial_bindings)
22
22
  @table = initial_bindings
23
+ @ignores = []
23
24
  @description = "root"
24
25
  @id = 0
25
26
  @rollbacks = {}
@@ -45,7 +46,7 @@ class Puppet::Context
45
46
 
46
47
  # @api private
47
48
  def lookup(name, &block)
48
- if @table.include?(name)
49
+ if @table.include?(name) && !@ignores.include?(name)
49
50
  value = @table[name]
50
51
  value.is_a?(Proc) ? (@table[name] = value.call) : value
51
52
  elsif block
@@ -66,6 +67,20 @@ class Puppet::Context
66
67
  rollback(mark_point)
67
68
  end
68
69
 
70
+ # @api private
71
+ def ignore(name)
72
+ @ignores << name
73
+ end
74
+
75
+ # @api private
76
+ def restore(name)
77
+ if @ignores.include?(name)
78
+ @ignores.delete(name)
79
+ else
80
+ raise UndefinedBindingError, "no '#{name}' in ignores #{@ignores.inspect} at top of #{@stack.inspect}"
81
+ end
82
+ end
83
+
69
84
  # Mark a place on the context stack to later return to with {rollback}.
70
85
  #
71
86
  # @param name [Object] The identifier for the mark