puppet 6.18.0-x86-mingw32 → 6.19.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +8 -10
  3. data/README.md +1 -2
  4. data/Rakefile +4 -12
  5. data/lib/puppet/agent/locker.rb +0 -7
  6. data/lib/puppet/application/agent.rb +8 -3
  7. data/lib/puppet/application/doc.rb +1 -1
  8. data/lib/puppet/application/lookup.rb +5 -5
  9. data/lib/puppet/configurer.rb +39 -7
  10. data/lib/puppet/defaults.rb +55 -29
  11. data/lib/puppet/environments.rb +51 -10
  12. data/lib/puppet/face/catalog.rb +1 -1
  13. data/lib/puppet/face/config.rb +46 -16
  14. data/lib/puppet/face/node.rb +3 -3
  15. data/lib/puppet/face/node/clean.rb +2 -2
  16. data/lib/puppet/face/status.rb +1 -1
  17. data/lib/puppet/file_bucket/dipper.rb +1 -1
  18. data/lib/puppet/functions/new.rb +8 -3
  19. data/lib/puppet/http.rb +1 -0
  20. data/lib/puppet/http/client.rb +1 -1
  21. data/lib/puppet/http/resolver.rb +5 -8
  22. data/lib/puppet/http/resolver/server_list.rb +18 -36
  23. data/lib/puppet/http/resolver/settings.rb +4 -4
  24. data/lib/puppet/http/resolver/srv.rb +5 -5
  25. data/lib/puppet/http/service.rb +3 -1
  26. data/lib/puppet/http/service/compiler.rb +1 -1
  27. data/lib/puppet/http/service/file_server.rb +1 -1
  28. data/lib/puppet/http/service/puppetserver.rb +39 -0
  29. data/lib/puppet/http/session.rb +5 -4
  30. data/lib/puppet/indirector/catalog/compiler.rb +1 -1
  31. data/lib/puppet/indirector/facts/yaml.rb +1 -1
  32. data/lib/puppet/indirector/json.rb +1 -1
  33. data/lib/puppet/indirector/msgpack.rb +1 -1
  34. data/lib/puppet/indirector/request.rb +4 -4
  35. data/lib/puppet/indirector/yaml.rb +1 -1
  36. data/lib/puppet/network/http/api/master/v3/environments.rb +0 -1
  37. data/lib/puppet/node/facts.rb +17 -0
  38. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -3
  39. data/lib/puppet/pops/evaluator/runtime3_converter.rb +2 -2
  40. data/lib/puppet/pops/types/p_meta_type.rb +1 -1
  41. data/lib/puppet/pops/types/p_type_set_type.rb +4 -0
  42. data/lib/puppet/provider/package/dpkg.rb +1 -1
  43. data/lib/puppet/provider/package/pip2.rb +17 -0
  44. data/lib/puppet/provider/package/puppetserver_gem.rb +180 -0
  45. data/lib/puppet/provider/package/yum.rb +1 -0
  46. data/lib/puppet/resource/type.rb +2 -1
  47. data/lib/puppet/rest/route.rb +2 -2
  48. data/lib/puppet/settings.rb +19 -5
  49. data/lib/puppet/transaction/report.rb +11 -7
  50. data/lib/puppet/type/file/source.rb +1 -1
  51. data/lib/puppet/type/filebucket.rb +1 -1
  52. data/lib/puppet/util/connection.rb +8 -8
  53. data/lib/puppet/util/run_mode.rb +5 -1
  54. data/lib/puppet/version.rb +1 -1
  55. data/locales/puppet.pot +153 -156
  56. data/man/man5/puppet.conf.5 +29 -13
  57. data/man/man8/puppet-agent.8 +6 -3
  58. data/man/man8/puppet-apply.8 +1 -1
  59. data/man/man8/puppet-catalog.8 +1 -1
  60. data/man/man8/puppet-config.8 +6 -6
  61. data/man/man8/puppet-describe.8 +1 -1
  62. data/man/man8/puppet-device.8 +1 -1
  63. data/man/man8/puppet-doc.8 +1 -1
  64. data/man/man8/puppet-epp.8 +1 -1
  65. data/man/man8/puppet-facts.8 +1 -1
  66. data/man/man8/puppet-filebucket.8 +1 -1
  67. data/man/man8/puppet-generate.8 +1 -1
  68. data/man/man8/puppet-help.8 +1 -1
  69. data/man/man8/puppet-key.8 +1 -1
  70. data/man/man8/puppet-lookup.8 +1 -1
  71. data/man/man8/puppet-man.8 +1 -1
  72. data/man/man8/puppet-module.8 +1 -1
  73. data/man/man8/puppet-node.8 +4 -4
  74. data/man/man8/puppet-parser.8 +1 -1
  75. data/man/man8/puppet-plugin.8 +1 -1
  76. data/man/man8/puppet-report.8 +1 -1
  77. data/man/man8/puppet-resource.8 +1 -1
  78. data/man/man8/puppet-script.8 +1 -1
  79. data/man/man8/puppet-ssl.8 +1 -1
  80. data/man/man8/puppet-status.8 +2 -2
  81. data/man/man8/puppet.8 +2 -2
  82. data/spec/fixtures/unit/provider/package/puppetserver_gem/gem-list-local-packages +30 -0
  83. data/spec/integration/application/agent_spec.rb +23 -19
  84. data/spec/integration/application/filebucket_spec.rb +7 -7
  85. data/spec/integration/application/plugin_spec.rb +3 -3
  86. data/spec/integration/configurer_spec.rb +14 -0
  87. data/spec/integration/defaults_spec.rb +26 -1
  88. data/spec/integration/util/windows/adsi_spec.rb +2 -2
  89. data/spec/shared_contexts/types_setup.rb +2 -0
  90. data/spec/unit/application/doc_spec.rb +2 -2
  91. data/spec/unit/application/facts_spec.rb +3 -1
  92. data/spec/unit/application_spec.rb +9 -4
  93. data/spec/unit/configurer_spec.rb +39 -6
  94. data/spec/unit/environments_spec.rb +99 -32
  95. data/spec/unit/face/config_spec.rb +56 -0
  96. data/spec/unit/face/node_spec.rb +2 -2
  97. data/spec/unit/file_system_spec.rb +1 -2
  98. data/spec/unit/http/resolver_spec.rb +24 -4
  99. data/spec/unit/http/service/ca_spec.rb +2 -2
  100. data/spec/unit/http/service/compiler_spec.rb +2 -2
  101. data/spec/unit/http/service/file_server_spec.rb +2 -2
  102. data/spec/unit/http/service/puppetserver_spec.rb +82 -0
  103. data/spec/unit/http/service/report_spec.rb +2 -2
  104. data/spec/unit/http/session_spec.rb +8 -20
  105. data/spec/unit/indirector/catalog/json_spec.rb +1 -1
  106. data/spec/unit/indirector/catalog/rest_spec.rb +1 -1
  107. data/spec/unit/indirector/facts/rest_spec.rb +1 -1
  108. data/spec/unit/indirector/json_spec.rb +8 -8
  109. data/spec/unit/indirector/msgpack_spec.rb +8 -8
  110. data/spec/unit/indirector/node/rest_spec.rb +1 -1
  111. data/spec/unit/indirector/request_spec.rb +4 -4
  112. data/spec/unit/indirector/rest_spec.rb +1 -1
  113. data/spec/unit/indirector/status/rest_spec.rb +1 -1
  114. data/spec/unit/indirector/yaml_spec.rb +7 -7
  115. data/spec/unit/network/http/api/master/v3/environments_spec.rb +12 -23
  116. data/spec/unit/provider/exec_spec.rb +4 -3
  117. data/spec/unit/provider/package/dpkg_spec.rb +22 -7
  118. data/spec/unit/provider/package/openbsd_spec.rb +2 -0
  119. data/spec/unit/provider/package/pip2_spec.rb +36 -0
  120. data/spec/unit/provider/package/puppetserver_gem_spec.rb +137 -0
  121. data/spec/unit/provider/package/yum_spec.rb +31 -0
  122. data/spec/unit/provider/service/base_spec.rb +2 -4
  123. data/spec/unit/provider/service/bsd_spec.rb +5 -1
  124. data/spec/unit/provider/service/daemontools_spec.rb +1 -1
  125. data/spec/unit/provider/service/debian_spec.rb +3 -5
  126. data/spec/unit/provider/service/freebsd_spec.rb +1 -1
  127. data/spec/unit/provider/service/gentoo_spec.rb +4 -5
  128. data/spec/unit/provider/service/init_spec.rb +4 -5
  129. data/spec/unit/provider/service/launchd_spec.rb +5 -6
  130. data/spec/unit/provider/service/openrc_spec.rb +4 -5
  131. data/spec/unit/provider/service/openwrt_spec.rb +1 -1
  132. data/spec/unit/provider/service/redhat_spec.rb +1 -1
  133. data/spec/unit/provider/service/runit_spec.rb +2 -1
  134. data/spec/unit/provider/service/smf_spec.rb +1 -1
  135. data/spec/unit/provider/service/src_spec.rb +3 -5
  136. data/spec/unit/provider/service/systemd_spec.rb +3 -1
  137. data/spec/unit/provider/service/upstart_spec.rb +4 -5
  138. data/spec/unit/rest/route_spec.rb +4 -4
  139. data/spec/unit/settings_spec.rb +44 -22
  140. data/spec/unit/transaction/report_spec.rb +2 -0
  141. data/spec/unit/type/file/source_spec.rb +1 -1
  142. data/spec/unit/type/filebucket_spec.rb +1 -1
  143. data/spec/unit/util/run_mode_spec.rb +6 -6
  144. metadata +13 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3a421a136fd994beaae6beec099968982c0073946e7cc02fc03a760e071e024
4
- data.tar.gz: ec0d6af5176799cad98d02d82f93b3fc17bbc71207a1422fa249c85d4f61f65c
3
+ metadata.gz: 1615d1d29b75fe44fd65ed6dc2d48298340d0fa0edbfb1734aa9bdaf9cc39ec9
4
+ data.tar.gz: 3ca003bdffb4f95ccca4bbfca3d7788efdf47ef0f4930e5df97e336021fc7f99
5
5
  SHA512:
6
- metadata.gz: 3fd0384b11647ff2a6996e48b843927dc85b22f20ca7accea06acbb75b1b4f455cac0eda1bf4524b6d98696284901bb38ac3e0ce2d62fa7184abfb5193cb7bcd
7
- data.tar.gz: 15e9a585b45e2f5525fa96f52b8188a9859002aa885e54b118ce9d80c92d1c1df3bc6bd2dbc63117a8c904eb7fa2ddfa7069c5555d488fab3e74ebb0c60baa5d
6
+ metadata.gz: efdaa4c37bc9aee7cecfb81f59c3cd0a1a9c8fe8210330a09b1911e94b0cd6169635db957cb8c1a6c9f2e5c027a3b87acaa29db34c06e145010ddb7fb545da04
7
+ data.tar.gz: 43e61b831bb76498ac3dab3312f02ac1437643c962b2e1328d0c9a8348c249b5bc6f2d2ddf8e97d850434005a0a26b61e405d9a66adabcefa720fe182103ded8
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- puppet (6.18.0)
4
+ puppet (6.19.0)
5
5
  CFPropertyList (~> 2.2)
6
6
  concurrent-ruby (~> 1.0)
7
7
  deep_merge (~> 1.0)
@@ -23,13 +23,12 @@ GEM
23
23
  ast (2.4.1)
24
24
  coderay (1.1.3)
25
25
  concurrent-ruby (1.1.7)
26
- crack (0.4.3)
27
- safe_yaml (~> 1.0.0)
26
+ crack (0.4.4)
28
27
  csv (3.1.5)
29
28
  deep_merge (1.2.1)
30
29
  diff-lcs (1.4.4)
31
30
  docopt (0.6.1)
32
- facter (4.0.35)
31
+ facter (4.0.43)
33
32
  hocon (~> 1.3)
34
33
  thor (>= 1.0.1, < 2.0)
35
34
  fast_gettext (1.1.2)
@@ -59,19 +58,19 @@ GEM
59
58
  multi_json (1.15.0)
60
59
  mustache (1.1.1)
61
60
  optimist (3.0.1)
62
- packaging (0.99.68)
61
+ packaging (0.99.71)
63
62
  artifactory (~> 2)
64
63
  csv (= 3.1.5)
65
64
  rake (>= 12.3)
66
65
  release-metrics
67
66
  parallel (1.19.2)
68
- parser (2.7.1.4)
67
+ parser (2.7.2.0)
69
68
  ast (~> 2.4.1)
70
69
  powerpack (0.1.2)
71
70
  pry (0.13.1)
72
71
  coderay (~> 1.1)
73
72
  method_source (~> 1.0)
74
- public_suffix (4.0.5)
73
+ public_suffix (4.0.6)
75
74
  puppet-resource_api (1.8.13)
76
75
  hocon (>= 1.0)
77
76
  puppetserver-ca (1.8.0)
@@ -93,7 +92,7 @@ GEM
93
92
  rspec-core (~> 3.9.0)
94
93
  rspec-expectations (~> 3.9.0)
95
94
  rspec-mocks (~> 3.9.0)
96
- rspec-core (3.9.2)
95
+ rspec-core (3.9.3)
97
96
  rspec-support (~> 3.9.3)
98
97
  rspec-expectations (3.9.2)
99
98
  diff-lcs (>= 1.2.0, < 2.0)
@@ -116,13 +115,12 @@ GEM
116
115
  rubocop (~> 0.49.0)
117
116
  ruby-prof (1.4.1)
118
117
  ruby-progressbar (1.10.1)
119
- safe_yaml (1.0.5)
120
118
  semantic_puppet (1.0.2)
121
119
  text (1.3.1)
122
120
  thor (1.0.1)
123
121
  unicode-display_width (1.7.0)
124
122
  vcr (5.1.0)
125
- webmock (3.8.3)
123
+ webmock (3.9.3)
126
124
  addressable (>= 2.3.6)
127
125
  crack (>= 0.3.2)
128
126
  hashdiff (>= 0.4.0, < 2.0.0)
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Puppet
2
2
 
3
- [![Travis Status](https://travis-ci.com/puppetlabs/puppet.svg?branch=master)](https://travis-ci.com/puppetlabs/puppet)
4
- [![Appveyor Status](https://ci.appveyor.com/api/projects/status/cvhpypd4504sevqq/branch/master?svg=true)](https://ci.appveyor.com/project/puppetlabs/puppet/branch/master)
3
+ ![RSpec tests](https://github.com/puppetlabs/puppet/workflows/RSpec%20tests/badge.svg)
5
4
  [![Gem Version](https://badge.fury.io/rb/puppet.svg)](https://badge.fury.io/rb/puppet)
6
5
  [![Inline docs](https://inch-ci.org/github/puppetlabs/puppet.svg)](https://inch-ci.org/github/puppetlabs/puppet)
7
6
 
data/Rakefile CHANGED
@@ -61,12 +61,8 @@ end
61
61
  desc "verify that commit messages match CONTRIBUTING.md requirements"
62
62
  task(:commits) do
63
63
  # This rake task looks at the summary from every commit from this branch not
64
- # in the branch targeted for a PR. This is accomplished by using the
65
- # TRAVIS_COMMIT_RANGE environment variable, which is present in travis CI and
66
- # populated with the range of commits the PR contains. If not available, this
67
- # falls back to `master..HEAD` as a next best bet as `master` is unlikely to
68
- # ever be absent.
69
- commit_range = ENV['TRAVIS_COMMIT_RANGE'].nil? ? 'master..HEAD' : ENV['TRAVIS_COMMIT_RANGE'].sub(/\.\.\./, '..')
64
+ # in the branch targeted for a PR.
65
+ commit_range = 'HEAD^..HEAD'
70
66
  puts "Checking commits #{commit_range}"
71
67
  %x{git log --no-merges --pretty=%s #{commit_range}}.each_line do |commit_summary|
72
68
  # This regex tests for the currently supported commit summary tokens: maint, doc, packaging, or pup-<number>.
@@ -91,12 +87,8 @@ end
91
87
 
92
88
  desc "verify that changed files are clean of Ruby warnings"
93
89
  task(:warnings) do
94
- # This rake task looks at all files modified in this branch. This is
95
- # accomplished by using the TRAVIS_COMMIT_RANGE environment variable, which
96
- # is present in travis CI and populated with the range of commits the PR
97
- # contains. If not available, this falls back to `master..HEAD` as a next
98
- # best bet as `master` is unlikely to ever be absent.
99
- commit_range = ENV['TRAVIS_COMMIT_RANGE'].nil? ? 'master...HEAD' : ENV['TRAVIS_COMMIT_RANGE']
90
+ # This rake task looks at all files modified in this branch.
91
+ commit_range = 'HEAD^..HEAD'
100
92
  ruby_files_ok = true
101
93
  puts "Checking modified files #{commit_range}"
102
94
  %x{git diff --diff-filter=ACM --name-only #{commit_range}}.each_line do |modified_file|
@@ -27,14 +27,7 @@ module Puppet::Agent::Locker
27
27
  end
28
28
  end
29
29
 
30
- # @deprecated
31
30
  def running?
32
- #TRANSLATORS 'Puppet::Agent::Locker.running?' is a method name and should not be translated
33
- message = _('Puppet::Agent::Locker.running? is deprecated as it is inherently unsafe.')
34
- #TRANSLATORS 'LockError' should not be translated
35
- message += ' ' + _('The only safe way to know if the lock is locked is to try lock and perform some '\
36
- 'action and then handle the LockError that may result.')
37
- Puppet.deprecation_warning(message)
38
31
  lockfile.locked?
39
32
  end
40
33
 
@@ -103,7 +103,7 @@ USAGE
103
103
  puppet agent [--certname <NAME>] [-D|--daemonize|--no-daemonize]
104
104
  [-d|--debug] [--detailed-exitcodes] [--digest <DIGEST>] [--disable [MESSAGE]] [--enable]
105
105
  [--fingerprint] [-h|--help] [-l|--logdest syslog|eventlog|<ABS FILEPATH>|console]
106
- [--masterport <PORT>] [--noop] [-o|--onetime] [--sourceaddress <IP_ADDRESS>] [-t|--test]
106
+ [--serverport <PORT>] [--noop] [-o|--onetime] [--sourceaddress <IP_ADDRESS>] [-t|--test]
107
107
  [-v|--verbose] [-V|--version] [-w|--waitforcert <SECONDS>]
108
108
 
109
109
 
@@ -277,8 +277,9 @@ generated by running puppet agent with '--genconfig'.
277
277
  format.
278
278
 
279
279
  * --masterport:
280
- The port on which to contact the puppet master.
281
- (This is a Puppet setting, and can go in puppet.conf.)
280
+ The port on which to contact the Puppet Server.
281
+ (This is a Puppet setting, and can go in puppet.conf.
282
+ Deprecated in favor of the 'serverport' setting.)
282
283
 
283
284
  * --noop:
284
285
  Use 'noop' mode where the daemon runs in a no-op or dry-run mode. This
@@ -294,6 +295,10 @@ generated by running puppet agent with '--genconfig'.
294
295
  (This is a Puppet setting, and can go in puppet.conf. Note the special 'no-'
295
296
  prefix for boolean settings on the command line.)
296
297
 
298
+ * --serverport:
299
+ The port on which to contact the Puppet Server.
300
+ (This is a Puppet setting, and can go in puppet.conf.)
301
+
297
302
  * --sourceaddress:
298
303
  Set the source IP address for transactions. This defaults to automatically selected.
299
304
  (This is a Puppet setting, and can go in puppet.conf.)
@@ -1,7 +1,7 @@
1
1
  require 'puppet/application'
2
2
 
3
3
  class Puppet::Application::Doc < Puppet::Application
4
- run_mode :master
4
+ run_mode :server
5
5
 
6
6
  attr_accessor :unknown_args, :manifest
7
7
 
@@ -8,7 +8,7 @@ class Puppet::Application::Lookup < Puppet::Application
8
8
  RUN_HELP = _("Run 'puppet lookup --help' for more details").freeze
9
9
  DEEP_MERGE_OPTIONS = '--knock-out-prefix, --sort-merged-arrays, and --merge-hash-arrays'.freeze
10
10
 
11
- run_mode :master
11
+ run_mode :server
12
12
 
13
13
  # Options for lookup
14
14
  option('--merge TYPE') do |arg|
@@ -92,12 +92,12 @@ class Puppet::Application::Lookup < Puppet::Application
92
92
 
93
93
  if options[:node]
94
94
  Puppet::Util.skip_external_facts do
95
- Puppet.settings.use :main, :master, :ssl, :metrics
95
+ Puppet.settings.use :main, :server, :ssl, :metrics
96
96
  end
97
97
  else
98
- Puppet.settings.use :main, :master, :ssl, :metrics
98
+ Puppet.settings.use :main, :server, :ssl, :metrics
99
99
  end
100
-
100
+
101
101
  setup_terminuses
102
102
  end
103
103
 
@@ -371,7 +371,7 @@ Copyright (c) 2015 Puppet Inc., LLC Licensed under the Apache 2.0 License
371
371
  Puppet[:code] = 'undef' unless options[:compile]
372
372
  compiler = Puppet::Parser::Compiler.new(node)
373
373
  if options[:node]
374
- Puppet::Util.skip_external_facts do
374
+ Puppet::Util.skip_external_facts do
375
375
  compiler.compile { |catalog| yield(compiler.topscope); catalog }
376
376
  end
377
377
  else
@@ -53,6 +53,7 @@ class Puppet::Configurer
53
53
  def initialize(transaction_uuid = nil, job_id = nil)
54
54
  @running = false
55
55
  @splayed = false
56
+ @running_failure = false
56
57
  @cached_catalog_status = 'not_used'
57
58
  @environment = Puppet[:environment]
58
59
  @transaction_uuid = transaction_uuid || SecureRandom.uuid
@@ -65,9 +66,16 @@ class Puppet::Configurer
65
66
  # Get the remote catalog, yo. Returns nil if no catalog can be found.
66
67
  def retrieve_catalog(facts, query_options)
67
68
  query_options ||= {}
68
- result = retrieve_catalog_from_cache(query_options) if Puppet[:use_cached_catalog]
69
+ if Puppet[:use_cached_catalog] || @running_failure
70
+ result = retrieve_catalog_from_cache(query_options)
71
+ end
72
+
69
73
  if result
70
- @cached_catalog_status = 'explicitly_requested'
74
+ if Puppet[:use_cached_catalog]
75
+ @cached_catalog_status = 'explicitly_requested'
76
+ elsif @running_failure
77
+ @cached_catalog_status = 'on_failure'
78
+ end
71
79
 
72
80
  Puppet.info _("Using cached catalog from environment '%{environment}'") % { environment: result.environment }
73
81
  else
@@ -215,10 +223,26 @@ class Puppet::Configurer
215
223
  # mode. We shouldn't try to do any failover in that case.
216
224
  if options[:catalog].nil? && do_failover
217
225
  server, port = find_functional_server
218
- if server.nil?
219
- raise Puppet::Error, _("Could not select a functional puppet master from server_list: '%{server_list}'") % { server_list: Puppet.settings.value(:server_list, Puppet[:environment].to_sym, true) }
220
- else
221
- report.master_used = "#{server}:#{port}"
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
235
+ if Puppet[:usecacheonfailure]
236
+ options[:pluginsync] = false
237
+ @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)
243
+ else
244
+ raise detail
245
+ end
222
246
  end
223
247
  Puppet.override(server: server, serverport: port) do
224
248
  completed = run_internal(options)
@@ -538,6 +562,14 @@ class Puppet::Configurer
538
562
  end
539
563
 
540
564
  def download_plugins(remote_environment_for_plugins)
541
- @handler.download_plugins(remote_environment_for_plugins)
565
+ begin
566
+ @handler.download_plugins(remote_environment_for_plugins)
567
+ rescue Puppet::Error => detail
568
+ if !Puppet[:ignore_plugin_errors] && Puppet[:usecacheonfailure]
569
+ @running_failure = true
570
+ else
571
+ raise detail
572
+ end
573
+ end
542
574
  end
543
575
  end
@@ -374,7 +374,7 @@ module Puppet
374
374
  from the parent process.
375
375
 
376
376
  This setting can only be set in the `[main]` section of puppet.conf; it cannot
377
- be set in `[master]`, `[agent]`, or an environment config section.",
377
+ be set in `[server]`, `[agent]`, or an environment config section.",
378
378
  :call_hook => :on_define_and_write,
379
379
  :hook => proc do |value|
380
380
  Puppet::Util.set_env('PATH', '') if Puppet::Util.get_env('PATH').nil?
@@ -562,7 +562,7 @@ module Puppet
562
562
  config = File.expand_path(File.join(settings[:confdir], 'hiera.yaml')) if config.nil?
563
563
  config
564
564
  end,
565
- :desc => "The hiera configuration file. Puppet only reads this file on startup, so you must restart the puppet master every time you edit it.",
565
+ :desc => "The hiera configuration file. Puppet only reads this file on startup, so you must restart the puppet server every time you edit it.",
566
566
  :type => :file,
567
567
  },
568
568
  :binder_config => {
@@ -700,40 +700,54 @@ Valid values are 0 (never cache) and 15 (15 second minimum wait time).
700
700
  :environment_timeout => {
701
701
  :default => "0",
702
702
  :type => :ttl,
703
- :desc => "How long the Puppet master should cache data it loads from an
703
+ :desc => "How long the Puppet server should cache data it loads from an
704
704
  environment.
705
705
 
706
706
  A value of `0` will disable caching. This setting can also be set to
707
- `unlimited`, which will cache environments until the master is restarted
708
- or told to refresh the cache.
707
+ `unlimited`, which will cache environments until the server is restarted
708
+ or told to refresh the cache. All other values will result in Puppet
709
+ server evicting expired environments. The expiration time is computed
710
+ based on either when the environment was created or last accessed, see
711
+ `environment_timeout_mode`.
709
712
 
710
713
  You should change this setting once your Puppet deployment is doing
711
714
  non-trivial work. We chose the default value of `0` because it lets new
712
715
  users update their code without any extra steps, but it lowers the
713
- performance of your Puppet master.
714
-
715
- We recommend setting this to `unlimited` and explicitly refreshing your
716
- Puppet master as part of your code deployment process.
717
-
718
- * With Puppet Server, you should refresh environments by calling the
719
- `environment-cache` API endpoint. See the docs for the Puppet Server
720
- [administrative API](https://puppet.com/docs/puppetserver/latest/admin-api/v1/environment-cache.html).
721
-
722
- Any value other than `0` or `unlimited` is deprecated, since most Puppet
723
- servers use a pool of Ruby interpreters which all have their own cache
724
- timers. When these timers drift out of sync, agents can be served
725
- inconsistent catalogs.",
716
+ performance of your Puppet server. We recommend either:
717
+
718
+ * Setting this to `unlimited` and explicitly refreshing your Puppet server
719
+ as part of your code deployment process.
720
+
721
+ * Setting this to a number that will keep your most actively used
722
+ environments cached, but allow testing environments to fall out of the
723
+ cache and reduce memory usage. A value of 3 minutes (3m) is a reasonable
724
+ value. This option requires setting `environment_timeout_mode` to
725
+ `from_last_used`.
726
+
727
+ Once you set `environment_timeout` to a non-zero value, you need to tell
728
+ Puppet server to read new code from disk using the `environment-cache` API
729
+ endpoint after you deploy new code. See the docs for the Puppet Server
730
+ [administrative API](https://puppet.com/docs/puppetserver/latest/admin-api/v1/environment-cache.html).
731
+ ",
726
732
  :hook => proc do |val|
727
- unless [0, 'unlimited', Float::INFINITY].include?(val)
728
- Puppet.deprecation_warning(<<-WARNING)
729
- Fine grained control of environment timeouts is deprecated,
730
- please use `0` or `unlimited` to control default caching behavior
731
- and the environment-cache endpoint in Puppet Server's administrative
732
- API to expire the cache as needed
733
- WARNING
733
+ if Puppet[:environment_timeout_mode] == :from_created
734
+ unless [0, 'unlimited', Float::INFINITY].include?(val)
735
+ Puppet.deprecation_warning("Evicting environments based on their creation time is deprecated, please set `environment_timeout_mode` to `from_last_used` instead.")
736
+ end
734
737
  end
735
738
  end
736
739
  },
740
+ :environment_timeout_mode => {
741
+ :default => :from_created,
742
+ :type => :symbolic_enum,
743
+ :values => [:from_created, :from_last_used],
744
+ :desc => "How Puppet interprets the `environment_timeout` setting when
745
+ `environment_timeout` is neither `0` nor `unlimited`. If set to
746
+ `from_created`, then the environment will be evicted `environment_timeout`
747
+ seconds from when it was created. If set to `from_last_used` then the
748
+ environment will be evicted `environment_timeout` seconds from when it
749
+ was last used."
750
+ },
737
751
  :environment_data_provider => {
738
752
  :desc => "The name of a registered environment data provider used when obtaining environment
739
753
  specific data. The three built in and registered providers are 'none' (no data), 'function' (data
@@ -1303,7 +1317,7 @@ EOT
1303
1317
  }
1304
1318
  )
1305
1319
 
1306
- settings.define_settings(:master,
1320
+ settings.define_settings(:server,
1307
1321
  :user => {
1308
1322
  :default => "puppet",
1309
1323
  :desc => "The user Puppet Server will run as. Used to ensure
@@ -1353,11 +1367,23 @@ EOT
1353
1367
  by `puppet`, and should only be set if you're writing your own Puppet
1354
1368
  executable.",
1355
1369
  },
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
+ },
1356
1379
  :masterport => {
1357
1380
  :default => 8140,
1358
1381
  :desc => "The default port puppet subcommands use to communicate
1359
1382
  with Puppet Server. (eg `puppet facts upload`, `puppet agent`). May be
1360
1383
  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
1361
1387
  },
1362
1388
  :node_name => {
1363
1389
  :default => 'cert',
@@ -1719,7 +1745,7 @@ EOT
1719
1745
  and does not need to horizontally scale.",
1720
1746
  },
1721
1747
  :ca_port => {
1722
- :default => "$masterport",
1748
+ :default => "$serverport",
1723
1749
  :desc => "The port to use for the certificate authority.",
1724
1750
  },
1725
1751
  :preferred_serialization_format => {
@@ -1808,7 +1834,7 @@ EOT
1808
1834
  :desc => "The server to send transaction reports to.",
1809
1835
  },
1810
1836
  :report_port => {
1811
- :default => "$masterport",
1837
+ :default => "$serverport",
1812
1838
  :desc => "The port to communicate with the report_server.",
1813
1839
  },
1814
1840
  :report => {
@@ -2123,7 +2149,7 @@ EOT
2123
2149
  }
2124
2150
  )
2125
2151
 
2126
- settings.define_settings(:master,
2152
+ settings.define_settings(:server,
2127
2153
  :storeconfigs => {
2128
2154
  :default => false,
2129
2155
  :type => :boolean,
@@ -159,8 +159,8 @@ module Puppet::Environments
159
159
  # Reads environments from a directory on disk. Each environment is
160
160
  # represented as a sub-directory. The environment's manifest setting is the
161
161
  # `manifest` directory of the environment directory. The environment's
162
- # modulepath setting is the global modulepath (from the `[master]` section
163
- # for the master) prepended with the `modules` directory of the environment
162
+ # modulepath setting is the global modulepath (from the `[server]` section
163
+ # for the server) prepended with the `modules` directory of the environment
164
164
  # directory.
165
165
  #
166
166
  # @api private
@@ -277,7 +277,7 @@ module Puppet::Environments
277
277
  def get(name)
278
278
  @loaders.each do |loader|
279
279
  env = loader.get(name)
280
- if env
280
+ if env
281
281
  return env
282
282
  end
283
283
  end
@@ -305,13 +305,23 @@ module Puppet::Environments
305
305
  include Puppet::Concurrent::Synchronized
306
306
 
307
307
  class DefaultCacheExpirationService
308
+ # Called when the environment is created.
309
+ #
310
+ # @param [Puppet::Node::Environment] env
308
311
  def created(env)
309
312
  end
310
313
 
314
+ # Is the environment with this name expired?
315
+ #
316
+ # @param [Symbol] env_name The symbolic environment name
317
+ # @return [Boolean]
311
318
  def expired?(env_name)
312
319
  false
313
320
  end
314
321
 
322
+ # The environment with this name was evicted.
323
+ #
324
+ # @param [Symbol] env_name The symbolic environment name
315
325
  def evicted(env_name)
316
326
  end
317
327
  end
@@ -362,7 +372,9 @@ module Puppet::Environments
362
372
  clear_all_expired
363
373
  result = @cache[name]
364
374
  if result
375
+ Puppet.debug {"Found in cache '#{name}' #{result.label}"}
365
376
  # found in cache
377
+ result.touch
366
378
  return result.value
367
379
  elsif (result = @loader.get(name))
368
380
  # environment loaded, cache it
@@ -411,7 +423,7 @@ module Puppet::Environments
411
423
  to_expire = @cache.select { |name, entry| entry.expires < t || @cache_expiration_service.expired?(name.to_sym) }
412
424
  to_expire.each do |name, entry|
413
425
  Puppet.debug {"Evicting cache entry for environment '#{name}'"}
414
- @cache_expiration_service.evicted(name)
426
+ @cache_expiration_service.evicted(name.to_sym)
415
427
  clear(name)
416
428
  @expirations.delete(entry.expires)
417
429
  Puppet.settings.clear_environment_settings(name)
@@ -435,23 +447,32 @@ module Puppet::Environments
435
447
  # Creates a suitable cache entry given the time to live for one environment
436
448
  #
437
449
  def entry(env)
438
- ttl = (conf = get_conf(env.name)) ? conf.environment_timeout : Puppet.settings.value(:environment_timeout)
450
+ ttl = if (conf = get_conf(env.name))
451
+ conf.environment_timeout
452
+ else
453
+ Puppet[:environment_timeout]
454
+ end
455
+
439
456
  case ttl
440
457
  when 0
441
458
  NotCachedEntry.new(env) # Entry that is always expired (avoids syscall to get time)
442
459
  when Float::INFINITY
443
460
  Entry.new(env) # Entry that never expires (avoids syscall to get time)
444
461
  else
445
- TTLEntry.new(env, ttl)
462
+ if Puppet[:environment_timeout_mode] == :from_last_used
463
+ MRUEntry.new(env, ttl) # Entry that expires in ttl from when it was last touched
464
+ else
465
+ TTLEntry.new(env, ttl) # Entry that expires in ttl from when it was created
466
+ end
446
467
  end
447
468
  end
448
469
 
449
470
  # Evicts the entry if it has expired
450
471
  # Also clears caches in Settings that may prevent the entry from being updated
451
472
  def evict_if_expired(name)
452
- if (result = @cache[name]) && (result.expired? || @cache_expiration_service.expired?(name))
473
+ if (result = @cache[name]) && (result.expired? || @cache_expiration_service.expired?(name.to_sym))
453
474
  Puppet.debug {"Evicting cache entry for environment '#{name}'"}
454
- @cache_expiration_service.evicted(name)
475
+ @cache_expiration_service.evicted(name.to_sym)
455
476
  clear(name)
456
477
  Puppet.settings.clear_environment_settings(name)
457
478
  end
@@ -465,6 +486,9 @@ module Puppet::Environments
465
486
  @value = value
466
487
  end
467
488
 
489
+ def touch
490
+ end
491
+
468
492
  def expired?
469
493
  false
470
494
  end
@@ -493,10 +517,10 @@ module Puppet::Environments
493
517
  end
494
518
  end
495
519
 
496
- # Time to Live eviction policy entry
520
+ # Policy that expires in ttl_seconds from when it was created
497
521
  class TTLEntry < Entry
498
522
  def initialize(value, ttl_seconds)
499
- super value
523
+ super(value)
500
524
  @ttl = Time.now + ttl_seconds
501
525
  @ttl_seconds = ttl_seconds
502
526
  end
@@ -513,5 +537,22 @@ module Puppet::Environments
513
537
  @ttl
514
538
  end
515
539
  end
540
+
541
+ # Policy that expires if it hasn't been touched within ttl_seconds
542
+ class MRUEntry < TTLEntry
543
+ def initialize(value, ttl_seconds)
544
+ super(value, ttl_seconds)
545
+
546
+ touch
547
+ end
548
+
549
+ def touch
550
+ @ttl = Time.now + @ttl_seconds
551
+ end
552
+
553
+ def label
554
+ "(mru = #{@ttl_seconds} sec)"
555
+ end
556
+ end
516
557
  end
517
558
  end