puppet 6.19.1-x64-mingw32 → 6.23.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 (293) hide show
  1. checksums.yaml +4 -4
  2. data/CODEOWNERS +2 -16
  3. data/Gemfile +3 -1
  4. data/Gemfile.lock +51 -40
  5. data/ext/osx/puppet.plist +2 -0
  6. data/ext/project_data.yaml +2 -2
  7. data/lib/puppet/application.rb +10 -6
  8. data/lib/puppet/application/agent.rb +12 -4
  9. data/lib/puppet/application/apply.rb +4 -2
  10. data/lib/puppet/application/device.rb +2 -0
  11. data/lib/puppet/application/filebucket.rb +2 -2
  12. data/lib/puppet/application/resource.rb +2 -1
  13. data/lib/puppet/application/script.rb +2 -0
  14. data/lib/puppet/application/ssl.rb +11 -0
  15. data/lib/puppet/application_support.rb +7 -0
  16. data/lib/puppet/configurer.rb +28 -18
  17. data/lib/puppet/configurer/downloader.rb +2 -1
  18. data/lib/puppet/defaults.rb +51 -23
  19. data/lib/puppet/environments.rb +54 -55
  20. data/lib/puppet/face/config.rb +10 -0
  21. data/lib/puppet/face/epp.rb +12 -2
  22. data/lib/puppet/face/facts.rb +158 -0
  23. data/lib/puppet/ffi/posix.rb +10 -0
  24. data/lib/puppet/ffi/posix/constants.rb +14 -0
  25. data/lib/puppet/ffi/posix/functions.rb +24 -0
  26. data/lib/puppet/file_serving/fileset.rb +14 -2
  27. data/lib/puppet/file_system/memory_file.rb +8 -1
  28. data/lib/puppet/file_system/windows.rb +2 -0
  29. data/lib/puppet/functions/all.rb +1 -1
  30. data/lib/puppet/functions/camelcase.rb +1 -1
  31. data/lib/puppet/functions/capitalize.rb +2 -2
  32. data/lib/puppet/functions/downcase.rb +2 -2
  33. data/lib/puppet/functions/epp.rb +1 -0
  34. data/lib/puppet/functions/get.rb +5 -5
  35. data/lib/puppet/functions/group_by.rb +13 -5
  36. data/lib/puppet/functions/inline_epp.rb +1 -0
  37. data/lib/puppet/functions/lest.rb +1 -1
  38. data/lib/puppet/functions/new.rb +100 -100
  39. data/lib/puppet/functions/partition.rb +12 -4
  40. data/lib/puppet/functions/require.rb +5 -5
  41. data/lib/puppet/functions/sort.rb +3 -3
  42. data/lib/puppet/functions/tree_each.rb +7 -9
  43. data/lib/puppet/functions/type.rb +4 -4
  44. data/lib/puppet/functions/upcase.rb +2 -2
  45. data/lib/puppet/http/resolver/server_list.rb +15 -4
  46. data/lib/puppet/http/service/compiler.rb +69 -0
  47. data/lib/puppet/http/service/file_server.rb +2 -1
  48. data/lib/puppet/indirector/catalog/compiler.rb +1 -0
  49. data/lib/puppet/indirector/fact_search.rb +60 -0
  50. data/lib/puppet/indirector/facts/facter.rb +24 -3
  51. data/lib/puppet/indirector/facts/json.rb +27 -0
  52. data/lib/puppet/indirector/facts/yaml.rb +3 -58
  53. data/lib/puppet/indirector/file_metadata/rest.rb +1 -0
  54. data/lib/puppet/indirector/json.rb +5 -1
  55. data/lib/puppet/indirector/node/json.rb +8 -0
  56. data/lib/puppet/indirector/report/json.rb +34 -0
  57. data/lib/puppet/module_tool/applications/installer.rb +48 -2
  58. data/lib/puppet/module_tool/errors/shared.rb +17 -2
  59. data/lib/puppet/network/formats.rb +69 -1
  60. data/lib/puppet/network/http/factory.rb +4 -0
  61. data/lib/puppet/pal/pal_impl.rb +70 -17
  62. data/lib/puppet/parser/ast/leaf.rb +3 -2
  63. data/lib/puppet/parser/functions/fqdn_rand.rb +14 -6
  64. data/lib/puppet/parser/templatewrapper.rb +1 -1
  65. data/lib/puppet/pops/evaluator/deferred_resolver.rb +5 -3
  66. data/lib/puppet/pops/evaluator/evaluator_impl.rb +22 -3
  67. data/lib/puppet/pops/model/ast_transformer.rb +1 -1
  68. data/lib/puppet/pops/types/p_sem_ver_type.rb +8 -2
  69. data/lib/puppet/pops/types/p_sensitive_type.rb +10 -0
  70. data/lib/puppet/property/list.rb +1 -1
  71. data/lib/puppet/provider/group/groupadd.rb +13 -8
  72. data/lib/puppet/provider/package/apt.rb +34 -2
  73. data/lib/puppet/provider/package/aptitude.rb +6 -0
  74. data/lib/puppet/provider/package/dnfmodule.rb +1 -1
  75. data/lib/puppet/provider/package/nim.rb +11 -6
  76. data/lib/puppet/provider/service/debian.rb +2 -0
  77. data/lib/puppet/provider/service/systemd.rb +14 -4
  78. data/lib/puppet/provider/service/windows.rb +38 -0
  79. data/lib/puppet/provider/user/aix.rb +2 -2
  80. data/lib/puppet/provider/user/directoryservice.rb +25 -12
  81. data/lib/puppet/provider/user/useradd.rb +62 -8
  82. data/lib/puppet/reference/configuration.rb +7 -6
  83. data/lib/puppet/settings.rb +33 -28
  84. data/lib/puppet/settings/alias_setting.rb +37 -0
  85. data/lib/puppet/settings/base_setting.rb +26 -2
  86. data/lib/puppet/settings/environment_conf.rb +1 -0
  87. data/lib/puppet/transaction/additional_resource_generator.rb +1 -1
  88. data/lib/puppet/type/file.rb +19 -1
  89. data/lib/puppet/type/file/selcontext.rb +1 -1
  90. data/lib/puppet/type/package.rb +3 -3
  91. data/lib/puppet/type/service.rb +18 -38
  92. data/lib/puppet/type/tidy.rb +21 -2
  93. data/lib/puppet/type/user.rb +38 -20
  94. data/lib/puppet/util/autoload.rb +1 -8
  95. data/lib/puppet/util/fact_dif.rb +81 -0
  96. data/lib/puppet/util/monkey_patches.rb +7 -0
  97. data/lib/puppet/util/posix.rb +54 -5
  98. data/lib/puppet/util/rubygems.rb +5 -1
  99. data/lib/puppet/util/selinux.rb +30 -4
  100. data/lib/puppet/util/windows/adsi.rb +46 -0
  101. data/lib/puppet/util/windows/api_types.rb +1 -1
  102. data/lib/puppet/util/windows/principal.rb +9 -2
  103. data/lib/puppet/util/windows/service.rb +1 -1
  104. data/lib/puppet/util/windows/sid.rb +4 -2
  105. data/lib/puppet/version.rb +1 -1
  106. data/locales/puppet.pot +372 -288
  107. data/man/man5/puppet.conf.5 +282 -254
  108. data/man/man8/puppet-agent.8 +2 -2
  109. data/man/man8/puppet-apply.8 +2 -2
  110. data/man/man8/puppet-catalog.8 +1 -1
  111. data/man/man8/puppet-config.8 +1 -1
  112. data/man/man8/puppet-describe.8 +1 -1
  113. data/man/man8/puppet-device.8 +2 -2
  114. data/man/man8/puppet-doc.8 +1 -1
  115. data/man/man8/puppet-epp.8 +1 -1
  116. data/man/man8/puppet-facts.8 +90 -1
  117. data/man/man8/puppet-filebucket.8 +3 -3
  118. data/man/man8/puppet-generate.8 +1 -1
  119. data/man/man8/puppet-help.8 +1 -1
  120. data/man/man8/puppet-key.8 +1 -1
  121. data/man/man8/puppet-lookup.8 +1 -1
  122. data/man/man8/puppet-man.8 +1 -1
  123. data/man/man8/puppet-module.8 +1 -1
  124. data/man/man8/puppet-node.8 +4 -1
  125. data/man/man8/puppet-parser.8 +1 -1
  126. data/man/man8/puppet-plugin.8 +1 -1
  127. data/man/man8/puppet-report.8 +4 -1
  128. data/man/man8/puppet-resource.8 +1 -1
  129. data/man/man8/puppet-script.8 +2 -2
  130. data/man/man8/puppet-ssl.8 +5 -1
  131. data/man/man8/puppet-status.8 +1 -1
  132. data/man/man8/puppet.8 +2 -2
  133. data/spec/fixtures/integration/application/agent/cached_deferred_catalog.json +91 -0
  134. data/spec/fixtures/ssl/127.0.0.1-key.pem +107 -57
  135. data/spec/fixtures/ssl/127.0.0.1.pem +52 -31
  136. data/spec/fixtures/ssl/bad-basic-constraints.pem +57 -35
  137. data/spec/fixtures/ssl/bad-int-basic-constraints.pem +57 -35
  138. data/spec/fixtures/ssl/ca.pem +57 -35
  139. data/spec/fixtures/ssl/crl.pem +28 -18
  140. data/spec/fixtures/ssl/ec-key.pem +11 -11
  141. data/spec/fixtures/ssl/ec.pem +33 -24
  142. data/spec/fixtures/ssl/encrypted-ec-key.pem +12 -12
  143. data/spec/fixtures/ssl/encrypted-key.pem +108 -58
  144. data/spec/fixtures/ssl/intermediate-agent-crl.pem +28 -19
  145. data/spec/fixtures/ssl/intermediate-agent.pem +57 -36
  146. data/spec/fixtures/ssl/intermediate-crl.pem +31 -21
  147. data/spec/fixtures/ssl/intermediate.pem +57 -36
  148. data/spec/fixtures/ssl/pluto-key.pem +107 -57
  149. data/spec/fixtures/ssl/pluto.pem +52 -30
  150. data/spec/fixtures/ssl/request-key.pem +107 -57
  151. data/spec/fixtures/ssl/request.pem +47 -26
  152. data/spec/fixtures/ssl/revoked-key.pem +107 -57
  153. data/spec/fixtures/ssl/revoked.pem +52 -30
  154. data/spec/fixtures/ssl/signed-key.pem +107 -57
  155. data/spec/fixtures/ssl/signed.pem +52 -30
  156. data/spec/fixtures/ssl/tampered-cert.pem +52 -30
  157. data/spec/fixtures/ssl/tampered-csr.pem +47 -26
  158. data/spec/fixtures/ssl/unknown-127.0.0.1-key.pem +107 -57
  159. data/spec/fixtures/ssl/unknown-127.0.0.1.pem +50 -29
  160. data/spec/fixtures/ssl/unknown-ca-key.pem +107 -57
  161. data/spec/fixtures/ssl/unknown-ca.pem +55 -33
  162. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services_vendor_preset +9 -0
  163. data/spec/fixtures/unit/provider/user/aix/aix_passwd_file.out +4 -0
  164. data/spec/integration/application/agent_spec.rb +160 -3
  165. data/spec/integration/application/apply_spec.rb +19 -0
  166. data/spec/integration/application/plugin_spec.rb +1 -1
  167. data/spec/integration/application/resource_spec.rb +30 -0
  168. data/spec/integration/defaults_spec.rb +0 -7
  169. data/spec/integration/environments/setting_hooks_spec.rb +1 -1
  170. data/spec/integration/http/client_spec.rb +12 -0
  171. data/spec/integration/indirector/direct_file_server_spec.rb +1 -3
  172. data/spec/integration/resource/type_collection_spec.rb +2 -6
  173. data/spec/integration/transaction_spec.rb +4 -9
  174. data/spec/integration/util/windows/adsi_spec.rb +21 -1
  175. data/spec/integration/util/windows/principal_spec.rb +21 -0
  176. data/spec/integration/util/windows/registry_spec.rb +6 -10
  177. data/spec/lib/puppet/test_ca.rb +2 -2
  178. data/spec/lib/puppet_spec/settings.rb +6 -1
  179. data/spec/spec_helper.rb +12 -5
  180. data/spec/unit/agent_spec.rb +8 -6
  181. data/spec/unit/application/agent_spec.rb +7 -3
  182. data/spec/unit/application/config_spec.rb +224 -4
  183. data/spec/unit/application/facts_spec.rb +482 -3
  184. data/spec/unit/application/filebucket_spec.rb +0 -2
  185. data/spec/unit/application/ssl_spec.rb +23 -0
  186. data/spec/unit/application_spec.rb +51 -9
  187. data/spec/unit/configurer/downloader_spec.rb +6 -0
  188. data/spec/unit/configurer_spec.rb +23 -0
  189. data/spec/unit/confine/feature_spec.rb +1 -1
  190. data/spec/unit/confine_spec.rb +8 -2
  191. data/spec/unit/defaults_spec.rb +36 -1
  192. data/spec/unit/environments_spec.rb +221 -68
  193. data/spec/unit/face/config_spec.rb +27 -32
  194. data/spec/unit/face/facts_spec.rb +4 -0
  195. data/spec/unit/face/node_spec.rb +0 -11
  196. data/spec/unit/file_serving/configuration/parser_spec.rb +0 -1
  197. data/spec/unit/file_serving/fileset_spec.rb +60 -0
  198. data/spec/unit/file_serving/metadata_spec.rb +3 -3
  199. data/spec/unit/file_serving/terminus_helper_spec.rb +11 -4
  200. data/spec/unit/file_system_spec.rb +9 -0
  201. data/spec/unit/forge/module_release_spec.rb +2 -7
  202. data/spec/unit/functions/inline_epp_spec.rb +26 -1
  203. data/spec/unit/gettext/config_spec.rb +12 -0
  204. data/spec/unit/http/service/compiler_spec.rb +172 -0
  205. data/spec/unit/http/service_spec.rb +1 -1
  206. data/spec/unit/indirector/catalog/compiler_spec.rb +14 -10
  207. data/spec/unit/indirector/face_spec.rb +0 -1
  208. data/spec/unit/indirector/facts/facter_spec.rb +95 -1
  209. data/spec/unit/indirector/facts/json_spec.rb +255 -0
  210. data/spec/unit/indirector/file_bucket_file/selector_spec.rb +26 -8
  211. data/spec/unit/indirector/indirection_spec.rb +8 -12
  212. data/spec/unit/indirector/key/file_spec.rb +0 -1
  213. data/spec/unit/indirector/node/json_spec.rb +33 -0
  214. data/spec/{integration/indirector/report/yaml.rb → unit/indirector/report/json_spec.rb} +13 -24
  215. data/spec/unit/indirector/report/yaml_spec.rb +72 -8
  216. data/spec/unit/indirector_spec.rb +2 -2
  217. data/spec/unit/module_tool/applications/installer_spec.rb +66 -0
  218. data/spec/unit/network/authconfig_spec.rb +0 -3
  219. data/spec/unit/network/formats_spec.rb +41 -0
  220. data/spec/unit/network/http/api/indirected_routes_spec.rb +0 -9
  221. data/spec/unit/network/http/factory_spec.rb +19 -0
  222. data/spec/unit/network/http/handler_spec.rb +0 -5
  223. data/spec/unit/parser/compiler_spec.rb +3 -19
  224. data/spec/unit/parser/functions/fqdn_rand_spec.rb +15 -1
  225. data/spec/unit/parser/resource_spec.rb +14 -8
  226. data/spec/unit/parser/templatewrapper_spec.rb +4 -3
  227. data/spec/unit/pops/evaluator/deferred_resolver_spec.rb +20 -0
  228. data/spec/unit/pops/types/p_sem_ver_type_spec.rb +18 -0
  229. data/spec/unit/pops/types/p_sensitive_type_spec.rb +18 -0
  230. data/spec/unit/property_spec.rb +1 -0
  231. data/spec/unit/provider/group/groupadd_spec.rb +5 -2
  232. data/spec/unit/provider/nameservice_spec.rb +66 -65
  233. data/spec/unit/provider/package/apt_spec.rb +28 -23
  234. data/spec/unit/provider/package/aptitude_spec.rb +1 -1
  235. data/spec/unit/provider/package/base_spec.rb +6 -5
  236. data/spec/unit/provider/package/dnfmodule_spec.rb +10 -1
  237. data/spec/unit/provider/package/nim_spec.rb +42 -0
  238. data/spec/unit/provider/package/pacman_spec.rb +18 -12
  239. data/spec/unit/provider/package/pip_spec.rb +6 -11
  240. data/spec/unit/provider/package/pkgdmg_spec.rb +0 -4
  241. data/spec/unit/provider/service/init_spec.rb +1 -0
  242. data/spec/unit/provider/service/openwrt_spec.rb +3 -1
  243. data/spec/unit/provider/service/systemd_spec.rb +53 -8
  244. data/spec/unit/provider/service/windows_spec.rb +202 -0
  245. data/spec/unit/provider/user/aix_spec.rb +5 -0
  246. data/spec/unit/provider/user/directoryservice_spec.rb +67 -35
  247. data/spec/unit/provider/user/hpux_spec.rb +1 -1
  248. data/spec/unit/provider/user/pw_spec.rb +2 -0
  249. data/spec/unit/provider/user/useradd_spec.rb +71 -3
  250. data/spec/unit/provider_spec.rb +8 -10
  251. data/spec/unit/puppet_pal_catalog_spec.rb +45 -0
  252. data/spec/unit/resource/capability_finder_spec.rb +6 -1
  253. data/spec/unit/resource/catalog_spec.rb +1 -1
  254. data/spec/unit/resource/type_spec.rb +1 -1
  255. data/spec/unit/resource_spec.rb +11 -10
  256. data/spec/unit/settings_spec.rb +419 -242
  257. data/spec/unit/ssl/base_spec.rb +0 -1
  258. data/spec/unit/ssl/host_spec.rb +0 -5
  259. data/spec/unit/ssl/ssl_provider_spec.rb +14 -8
  260. data/spec/unit/ssl/state_machine_spec.rb +19 -5
  261. data/spec/unit/transaction/additional_resource_generator_spec.rb +3 -9
  262. data/spec/unit/transaction/event_manager_spec.rb +14 -11
  263. data/spec/unit/transaction_spec.rb +18 -11
  264. data/spec/unit/type/file/content_spec.rb +0 -1
  265. data/spec/unit/type/file/selinux_spec.rb +3 -5
  266. data/spec/unit/type/file_spec.rb +0 -6
  267. data/spec/unit/type/group_spec.rb +13 -6
  268. data/spec/unit/type/resources_spec.rb +7 -7
  269. data/spec/unit/type/service_spec.rb +60 -189
  270. data/spec/unit/type/tidy_spec.rb +17 -8
  271. data/spec/unit/type/user_spec.rb +45 -0
  272. data/spec/unit/type_spec.rb +2 -2
  273. data/spec/unit/util/at_fork_spec.rb +2 -2
  274. data/spec/unit/util/autoload_spec.rb +5 -1
  275. data/spec/unit/util/backups_spec.rb +1 -2
  276. data/spec/unit/util/execution_spec.rb +15 -11
  277. data/spec/unit/util/inifile_spec.rb +6 -14
  278. data/spec/unit/util/log_spec.rb +8 -7
  279. data/spec/unit/util/logging_spec.rb +3 -3
  280. data/spec/unit/util/posix_spec.rb +363 -15
  281. data/spec/unit/util/rubygems_spec.rb +2 -2
  282. data/spec/unit/util/selinux_spec.rb +163 -68
  283. data/spec/unit/util/storage_spec.rb +3 -1
  284. data/spec/unit/util/suidmanager_spec.rb +44 -41
  285. data/spec/unit/util/windows/sid_spec.rb +6 -0
  286. data/spec/unit/util_spec.rb +13 -6
  287. data/tasks/generate_cert_fixtures.rake +2 -2
  288. metadata +33 -16
  289. data/spec/integration/application/config_spec.rb +0 -74
  290. data/spec/lib/matchers/include.rb +0 -27
  291. data/spec/lib/matchers/include_spec.rb +0 -32
  292. data/spec/unit/face/catalog_spec.rb +0 -6
  293. data/spec/unit/face/module_spec.rb +0 -3
@@ -112,7 +112,7 @@ class Puppet::Configurer
112
112
  catalog_conversion_time = thinmark do
113
113
  # Will mutate the result and replace all Deferred values with resolved values
114
114
  if facts
115
- Puppet::Pops::Evaluator::DeferredResolver.resolve_and_replace(facts, result)
115
+ Puppet::Pops::Evaluator::DeferredResolver.resolve_and_replace(facts, result, Puppet.lookup(:current_environment))
116
116
  end
117
117
 
118
118
  catalog = result.to_ral
@@ -223,26 +223,23 @@ class Puppet::Configurer
223
223
  # mode. We shouldn't try to do any failover in that case.
224
224
  if options[:catalog].nil? && do_failover
225
225
  server, port = find_functional_server
226
- begin
227
- if server.nil?
228
- raise Puppet::Error, _("Could not select a functional puppet server from server_list: '%{server_list}'") % { server_list: Puppet.settings.value(:server_list, Puppet[:environment].to_sym, true) }
229
- else
230
- #TRANSLATORS 'server_list' is the name of a setting and should not be translated
231
- Puppet.debug _("Selected puppet server from the `server_list` setting: %{server}:%{port}") % { server: server, port: port }
232
- report.server_used = "#{server}:#{port}"
233
- end
234
- rescue Puppet::Error => detail
226
+ if server.nil?
227
+ detail = _("Could not select a functional puppet server from server_list: '%{server_list}'") % { server_list: Puppet.settings.value(:server_list, Puppet[:environment].to_sym, true) }
235
228
  if Puppet[:usecacheonfailure]
236
229
  options[:pluginsync] = false
237
230
  @running_failure = true
238
- if server.nil?
239
- server = Puppet[:server_list].first[0]
240
- port = Puppet[:server_list].first[1] || Puppet[:serverport]
241
- end
242
- Puppet.log_exception(detail)
231
+
232
+ server = Puppet[:server_list].first[0]
233
+ port = Puppet[:server_list].first[1] || Puppet[:serverport]
234
+
235
+ Puppet.err(detail)
243
236
  else
244
- raise detail
237
+ raise Puppet::Error, detail
245
238
  end
239
+ else
240
+ #TRANSLATORS 'server_list' is the name of a setting and should not be translated
241
+ Puppet.debug _("Selected puppet server from the `server_list` setting: %{server}:%{port}") % { server: server, port: port }
242
+ report.server_used = "#{server}:#{port}"
246
243
  end
247
244
  Puppet.override(server: server, serverport: port) do
248
245
  completed = run_internal(options)
@@ -400,16 +397,29 @@ class Puppet::Configurer
400
397
  if !cached_catalog && options[:catalog]
401
398
  ral_catalog = options[:catalog]
402
399
  else
400
+ # Ordering here matters. We have to resolve deferred resources in the
401
+ # resource catalog, convert the resource catalog to a RAL catalog (which
402
+ # triggers type/provider validation), and only if that is successful,
403
+ # should we cache the *original* resource catalog. However, deferred
404
+ # evaluation mutates the resource catalog, so we need to make a copy of
405
+ # it here. If PUP-9323 is ever implemented so that we resolve deferred
406
+ # resources in the RAL catalog as they are needed, then we could eliminate
407
+ # this step.
408
+ catalog_to_cache = Puppet.override(:rich_data => Puppet[:rich_data]) do
409
+ Puppet::Resource::Catalog.from_data_hash(catalog.to_data_hash)
410
+ end
411
+
403
412
  # REMIND @duration is the time spent loading the last catalog, and doesn't
404
413
  # account for things like we failed to download and fell back to the cache
405
414
  ral_catalog = convert_catalog(catalog, @duration, facts, options)
406
415
 
407
- # If not noop, commit the cached resource catalog (not ral catalog). Ideally
416
+ # Validation succeeded, so commit the `catalog_to_cache` for non-noop runs. Don't
417
+ # commit `catalog` since it contains the result of deferred evaluation. Ideally
408
418
  # we'd just copy the downloaded response body, instead of serializing the
409
419
  # in-memory catalog, but that's hard due to the indirector.
410
420
  indirection = Puppet::Resource::Catalog.indirection
411
421
  if !Puppet[:noop] && indirection.cache?
412
- request = indirection.request(:save, nil, catalog, environment: Puppet::Node::Environment.remote(catalog.environment))
422
+ request = indirection.request(:save, nil, catalog_to_cache, environment: Puppet::Node::Environment.remote(catalog_to_cache.environment))
413
423
  Puppet.info("Caching catalog for #{request.key}")
414
424
  indirection.cache.save(request)
415
425
  end
@@ -73,7 +73,8 @@ class Puppet::Configurer::Downloader
73
73
  :purge => true,
74
74
  :force => true,
75
75
  :backup => false,
76
- :noop => false
76
+ :noop => false,
77
+ :max_files => -1
77
78
  }
78
79
  if !Puppet::Util::Platform.windows?
79
80
  defargs[:owner] = Process.uid
@@ -58,6 +58,18 @@ module Puppet
58
58
  end
59
59
  end
60
60
 
61
+ def self.default_cadir
62
+ return "" if Puppet::Util::Platform.windows?
63
+ old_ca_dir = "#{Puppet[:ssldir]}/ca"
64
+ new_ca_dir = '/etc/puppetlabs/puppetserver/ca'
65
+
66
+ if File.exist?("#{new_ca_dir}/ca_crt.pem")
67
+ new_ca_dir
68
+ else
69
+ old_ca_dir
70
+ end
71
+ end
72
+
61
73
  ############################################################################################
62
74
  # NOTE: For information about the available values for the ":type" property of settings,
63
75
  # see the docs for Settings.define_settings
@@ -77,7 +89,8 @@ module Puppet
77
89
  the "facter-ng" gem). This is not necessary if Facter 3.x or later is installed.
78
90
  This setting is still experimental.',
79
91
  :hook => proc do |value|
80
- if value
92
+ value = munge(value)
93
+ if value && Puppet::Util::Package.versioncmp(Facter.value('facterversion'), '4.0.0') < 0
81
94
  begin
82
95
  original_facter = Object.const_get(:Facter)
83
96
  Object.send(:remove_const, :Facter)
@@ -632,7 +645,7 @@ module Puppet
632
645
  :http_proxy_password =>{
633
646
  :default => "none",
634
647
  :hook => proc do |value|
635
- if settings[:http_proxy_password] =~ /[@!# \/]/
648
+ if value =~ /[@!# \/]/
636
649
  raise "Passwords set in the http_proxy_password setting must be valid as part of a URL, and any reserved characters must be URL-encoded. We received: #{value}"
637
650
  end
638
651
  end,
@@ -841,7 +854,10 @@ Valid values are 0 (never cache) and 15 (15 second minimum wait time).
841
854
  **Note:** You must set the certname in the main section of the puppet.conf file. Setting it in a different section causes errors.
842
855
 
843
856
  Defaults to the node's fully qualified domain name.",
844
- :hook => proc { |value| raise(ArgumentError, _("Certificate names must be lower case")) unless value == value.downcase }},
857
+ :call_hook => :on_initialize_and_write,
858
+ :hook => proc { |value|
859
+ raise(ArgumentError, _("Certificate names must be lower case")) unless value == value.downcase
860
+ }},
845
861
  :dns_alt_names => {
846
862
  :default => '',
847
863
  :desc => <<EOT,
@@ -862,8 +878,8 @@ names.
862
878
  **Note:** The list of alternate names is locked in when the server's
863
879
  certificate is signed. If you need to change the list later, you can't just
864
880
  change this setting; you also need to regenerate the certificate. For more
865
- information on that process, see the [cert regen docs]
866
- (https://puppet.com/docs/puppet/latest/ssl_regenerate_certificates.html).
881
+ information on that process, see the
882
+ [cert regen docs](https://puppet.com/docs/puppet/latest/ssl_regenerate_certificates.html).
867
883
 
868
884
  To see all the alternate names your servers are using, log into your CA server
869
885
  and run `puppetserver ca list --all`, then check the output for `(alt names: ...)`.
@@ -1081,6 +1097,14 @@ EOT
1081
1097
  certificate revocation checking and does not attempt to download the CRL.
1082
1098
  EOT
1083
1099
  },
1100
+ :ciphers => {
1101
+ :default => 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256',
1102
+ :type => :string,
1103
+ :desc => "The list of ciphersuites for TLS connections initiated by puppet. The
1104
+ default value is chosen to support TLS 1.0 and up, but can be made
1105
+ more restrictive if needed. The ciphersuites must be specified in OpenSSL
1106
+ format, not IANA."
1107
+ },
1084
1108
  :key_type => {
1085
1109
  :default => 'rsa',
1086
1110
  :type => :enum,
@@ -1124,7 +1148,7 @@ EOT
1124
1148
  :type => :string,
1125
1149
  :desc => "Where to send log messages. Choose between 'syslog' (the POSIX syslog
1126
1150
  service), 'eventlog' (the Windows Event Log), 'console', or the path to a log
1127
- file."
1151
+ file. Multiple destinations can be set using a comma separated list (eg: `/path/file1,console,/path/file2`)"
1128
1152
  # Sure would be nice to set the Puppet::Util::Log destination here in an :on_initialize_and_write hook,
1129
1153
  # unfortunately we have a large number of tests that rely on the logging not resetting itself when the
1130
1154
  # settings are initialized as they test what gets logged during settings initialization.
@@ -1138,7 +1162,7 @@ EOT
1138
1162
  :desc => "The name to use the Certificate Authority certificate.",
1139
1163
  },
1140
1164
  :cadir => {
1141
- :default => "$ssldir/ca",
1165
+ :default => lambda { default_cadir },
1142
1166
  :type => :directory,
1143
1167
  :desc => "The root directory for the certificate authority.",
1144
1168
  },
@@ -1367,23 +1391,15 @@ EOT
1367
1391
  by `puppet`, and should only be set if you're writing your own Puppet
1368
1392
  executable.",
1369
1393
  },
1370
- :serverport => {
1371
- :default => 8140,
1372
- :desc => "The default port puppet subcommands use to communicate
1373
- with Puppet Server. (eg `puppet facts upload`, `puppet agent`). May be
1374
- overridden by more specific settings (see `ca_port`, `report_port`).",
1375
- :hook => proc do |value|
1376
- Puppet[:masterport] = value unless Puppet.settings.set_by_config?(:masterport)
1377
- end
1378
- },
1379
1394
  :masterport => {
1380
1395
  :default => 8140,
1381
1396
  :desc => "The default port puppet subcommands use to communicate
1382
1397
  with Puppet Server. (eg `puppet facts upload`, `puppet agent`). May be
1383
1398
  overridden by more specific settings (see `ca_port`, `report_port`).",
1384
- :hook => proc do |value|
1385
- Puppet[:serverport] = value unless Puppet.settings.set_by_config?(:serverport)
1386
- end
1399
+ },
1400
+ :serverport => {
1401
+ :type => :alias,
1402
+ :alias_for => :masterport
1387
1403
  },
1388
1404
  :node_name => {
1389
1405
  :default => 'cert',
@@ -1501,7 +1517,9 @@ EOT
1501
1517
  See the report reference for information on the built-in report
1502
1518
  handlers; custom report handlers can also be loaded from modules.
1503
1519
  (Report handlers are loaded from the lib directory, at
1504
- `puppet/reports/NAME.rb`.)",
1520
+ `puppet/reports/NAME.rb`.)
1521
+
1522
+ To turn off reports entirely, set this to `none`",
1505
1523
  },
1506
1524
  :reportdir => {
1507
1525
  :default => "$vardir/reports",
@@ -1764,7 +1782,7 @@ EOT
1764
1782
  },
1765
1783
  :agent_disabled_lockfile => {
1766
1784
  :default => "$statedir/agent_disabled.lock",
1767
- :type => :file,
1785
+ :type => :string,
1768
1786
  :desc => "A lock file to indicate that puppet agent runs have been administratively
1769
1787
  disabled. File contains a JSON object with state information.",
1770
1788
  },
@@ -1874,7 +1892,11 @@ EOT
1874
1892
  :default => "$statedir/last_run_report.yaml",
1875
1893
  :type => :file,
1876
1894
  :mode => "0640",
1877
- :desc => "Where puppet agent stores the last run report in yaml format."
1895
+ :desc => "Where Puppet Agent stores the last run report, by default, in yaml format.
1896
+ The format of the report can be changed by setting the `cache` key of the `report` terminus
1897
+ in the [routes.yaml](https://puppet.com/docs/puppet/latest/config_file_routes.html) file.
1898
+ To avoid mismatches between content and file extension, this setting needs to be
1899
+ manually updated to reflect the terminus changes."
1878
1900
  },
1879
1901
  :graph => {
1880
1902
  :default => false,
@@ -2218,12 +2240,18 @@ EOT
2218
2240
  :func3x_check => {
2219
2241
  :default => true,
2220
2242
  :type => :boolean,
2221
- :desc => <<-'EOT'
2243
+ :desc => <<-'EOT',
2222
2244
  Causes validation of loaded legacy Ruby functions (3x API) to raise errors about illegal constructs that
2223
2245
  could cause harm or that simply does not work. This flag is on by default. This flag is made available
2224
2246
  so that the validation can be turned off in case the method of validation is faulty - if encountered, please
2225
2247
  file a bug report.
2226
2248
  EOT
2249
+ :call_hook => :on_initialize_and_write,
2250
+ :hook => proc do |value|
2251
+ unless value
2252
+ Puppet.deprecation_warning(_("The 'func3x_check' setting is deprecated and will be removed in a future release."))
2253
+ end
2254
+ end
2227
2255
  },
2228
2256
  :tasks => {
2229
2257
  :default => false,
@@ -225,6 +225,9 @@ module Puppet::Environments
225
225
  private
226
226
 
227
227
  def create_environment(name)
228
+ # interpolated modulepaths may be cached from prior environment instances
229
+ Puppet.settings.clear_environment_settings(name)
230
+
228
231
  env_symbol = name.intern
229
232
  setting_values = Puppet.settings.values(env_symbol, Puppet.settings.preferred_run_mode)
230
233
  env = Puppet::Node::Environment.create(
@@ -346,17 +349,23 @@ module Puppet::Environments
346
349
  @loader = loader
347
350
  @cache_expiration_service = Puppet::Environments::Cached.cache_expiration_service
348
351
  @cache = {}
349
-
350
- # Holds expiration times in sorted order - next to expire is first
351
- @expirations = SortedSet.new
352
-
353
- # Infinity since it there are no entries, this is a cache of the first to expire time
354
- @next_expiration = END_OF_TIME
355
352
  end
356
353
 
357
354
  # @!macro loader_list
358
355
  def list
359
- @loader.list
356
+ # Evict all that have expired, in the same way as `get`
357
+ clear_all_expired
358
+
359
+ @loader.list.map do |env|
360
+ name = env.name
361
+ old_entry = @cache[name]
362
+ if old_entry
363
+ old_entry.value
364
+ else
365
+ add_entry(name, entry(env))
366
+ env
367
+ end
368
+ end
360
369
  end
361
370
 
362
371
  # @!macro loader_search_paths
@@ -379,7 +388,6 @@ module Puppet::Environments
379
388
  elsif (result = @loader.get(name))
380
389
  # environment loaded, cache it
381
390
  cache_entry = entry(result)
382
- @cache_expiration_service.created(result)
383
391
  add_entry(name, cache_entry)
384
392
  result
385
393
  end
@@ -389,28 +397,36 @@ module Puppet::Environments
389
397
  def add_entry(name, cache_entry)
390
398
  Puppet.debug {"Caching environment '#{name}' #{cache_entry.label}"}
391
399
  @cache[name] = cache_entry
392
- expires = cache_entry.expires
393
- @expirations.add(expires)
394
- if @next_expiration > expires
395
- @next_expiration = expires
396
- end
400
+ @cache_expiration_service.created(cache_entry.value)
397
401
  end
398
402
  private :add_entry
399
403
 
404
+ def clear_entry(name, entry)
405
+ @cache.delete(name)
406
+ Puppet.debug {"Evicting cache entry for environment '#{name}'"}
407
+ @cache_expiration_service.evicted(name.to_sym)
408
+ Puppet::GettextConfig.delete_text_domain(name)
409
+ Puppet.settings.clear_environment_settings(name)
410
+ end
411
+ private :clear_entry
412
+
400
413
  # Clears the cache of the environment with the given name.
401
414
  # (The intention is that this could be used from a MANUAL cache eviction command (TBD)
402
415
  def clear(name)
403
- @cache.delete(name)
404
- Puppet::GettextConfig.delete_text_domain(name)
416
+ entry = @cache[name]
417
+ clear_entry(name, entry) if entry
405
418
  end
406
419
 
407
420
  # Clears all cached environments.
408
421
  # (The intention is that this could be used from a MANUAL cache eviction command (TBD)
409
- def clear_all()
422
+ def clear_all
410
423
  super
424
+
425
+ @cache.each_pair do |name, entry|
426
+ clear_entry(name, entry)
427
+ end
428
+
411
429
  @cache = {}
412
- @expirations.clear
413
- @next_expiration = END_OF_TIME
414
430
  Puppet::GettextConfig.delete_environment_text_domains
415
431
  end
416
432
 
@@ -419,18 +435,24 @@ module Puppet::Environments
419
435
  #
420
436
  def clear_all_expired()
421
437
  t = Time.now
422
- return if t < @next_expiration && ! @cache.any? {|name, _| @cache_expiration_service.expired?(name.to_sym) }
423
- to_expire = @cache.select { |name, entry| entry.expires < t || @cache_expiration_service.expired?(name.to_sym) }
424
- to_expire.each do |name, entry|
425
- Puppet.debug {"Evicting cache entry for environment '#{name}'"}
426
- @cache_expiration_service.evicted(name.to_sym)
427
- clear(name)
428
- @expirations.delete(entry.expires)
429
- Puppet.settings.clear_environment_settings(name)
438
+
439
+ @cache.each_pair do |name, entry|
440
+ clear_if_expired(name, entry, t)
430
441
  end
431
- @next_expiration = @expirations.first || END_OF_TIME
432
442
  end
433
443
 
444
+ # Clear an environment if it is expired, either by exceeding its time to live, or
445
+ # through an explicit eviction determined by the cache expiration service.
446
+ #
447
+ def clear_if_expired(name, entry, t = Time.now)
448
+ return unless entry
449
+
450
+ if entry.expired?(t) || @cache_expiration_service.expired?(name.to_sym)
451
+ clear_entry(name, entry)
452
+ end
453
+ end
454
+ private :clear_if_expired
455
+
434
456
  # This implementation evicts the cache, and always gets the current
435
457
  # configuration of the environment
436
458
  #
@@ -440,7 +462,7 @@ module Puppet::Environments
440
462
  #
441
463
  # @!macro loader_get_conf
442
464
  def get_conf(name)
443
- evict_if_expired(name)
465
+ clear_if_expired(name, @cache[name])
444
466
  @loader.get_conf(name)
445
467
  end
446
468
 
@@ -467,17 +489,6 @@ module Puppet::Environments
467
489
  end
468
490
  end
469
491
 
470
- # Evicts the entry if it has expired
471
- # Also clears caches in Settings that may prevent the entry from being updated
472
- def evict_if_expired(name)
473
- if (result = @cache[name]) && (result.expired? || @cache_expiration_service.expired?(name.to_sym))
474
- Puppet.debug {"Evicting cache entry for environment '#{name}'"}
475
- @cache_expiration_service.evicted(name.to_sym)
476
- clear(name)
477
- Puppet.settings.clear_environment_settings(name)
478
- end
479
- end
480
-
481
492
  # Never evicting entry
482
493
  class Entry
483
494
  attr_reader :value
@@ -489,32 +500,24 @@ module Puppet::Environments
489
500
  def touch
490
501
  end
491
502
 
492
- def expired?
503
+ def expired?(now)
493
504
  false
494
505
  end
495
506
 
496
507
  def label
497
508
  ""
498
509
  end
499
-
500
- def expires
501
- END_OF_TIME
502
- end
503
510
  end
504
511
 
505
512
  # Always evicting entry
506
513
  class NotCachedEntry < Entry
507
- def expired?
514
+ def expired?(now)
508
515
  true
509
516
  end
510
517
 
511
518
  def label
512
519
  "(ttl = 0 sec)"
513
520
  end
514
-
515
- def expires
516
- START_OF_TIME
517
- end
518
521
  end
519
522
 
520
523
  # Policy that expires in ttl_seconds from when it was created
@@ -525,17 +528,13 @@ module Puppet::Environments
525
528
  @ttl_seconds = ttl_seconds
526
529
  end
527
530
 
528
- def expired?
529
- Time.now > @ttl
531
+ def expired?(now)
532
+ now > @ttl
530
533
  end
531
534
 
532
535
  def label
533
536
  "(ttl = #{@ttl_seconds} sec)"
534
537
  end
535
-
536
- def expires
537
- @ttl
538
- end
539
538
  end
540
539
 
541
540
  # Policy that expires if it hasn't been touched within ttl_seconds