puppet 6.15.0-universal-darwin → 6.16.0-universal-darwin

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 (132) hide show
  1. checksums.yaml +4 -4
  2. data/CODEOWNERS +2 -7
  3. data/Gemfile.lock +17 -14
  4. data/lib/puppet.rb +32 -8
  5. data/lib/puppet/agent.rb +18 -4
  6. data/lib/puppet/application/agent.rb +1 -2
  7. data/lib/puppet/application/device.rb +1 -1
  8. data/lib/puppet/application/plugin.rb +1 -0
  9. data/lib/puppet/application/ssl.rb +1 -1
  10. data/lib/puppet/configurer.rb +2 -2
  11. data/lib/puppet/context/trusted_information.rb +14 -8
  12. data/lib/puppet/daemon.rb +13 -27
  13. data/lib/puppet/defaults.rb +19 -0
  14. data/lib/puppet/face/facts.rb +1 -1
  15. data/lib/puppet/face/help.rb +29 -3
  16. data/lib/puppet/face/module/search.rb +5 -0
  17. data/lib/puppet/face/plugin.rb +1 -1
  18. data/lib/puppet/file_serving/http_metadata.rb +1 -1
  19. data/lib/puppet/file_system/uniquefile.rb +4 -0
  20. data/lib/puppet/forge/repository.rb +7 -6
  21. data/lib/puppet/functions/filter.rb +1 -0
  22. data/lib/puppet/http/client.rb +22 -11
  23. data/lib/puppet/http/external_client.rb +0 -6
  24. data/lib/puppet/indirector/file_content/http.rb +5 -0
  25. data/lib/puppet/indirector/file_metadata/http.rb +4 -4
  26. data/lib/puppet/indirector/rest.rb +7 -1
  27. data/lib/puppet/network/http/compression.rb +7 -0
  28. data/lib/puppet/network/http/connection.rb +2 -0
  29. data/lib/puppet/network/http/connection_adapter.rb +182 -0
  30. data/lib/puppet/network/http/nocache_pool.rb +1 -0
  31. data/lib/puppet/network/http_pool.rb +2 -2
  32. data/lib/puppet/pal/catalog_compiler.rb +5 -0
  33. data/lib/puppet/pal/pal_impl.rb +4 -1
  34. data/lib/puppet/parser/compiler.rb +28 -25
  35. data/lib/puppet/parser/functions/filter.rb +1 -0
  36. data/lib/puppet/provider/package/aix.rb +17 -2
  37. data/lib/puppet/provider/package/apt.rb +4 -1
  38. data/lib/puppet/provider/package/dnfmodule.rb +24 -4
  39. data/lib/puppet/provider/package/pip.rb +60 -37
  40. data/lib/puppet/provider/package/portage.rb +2 -2
  41. data/lib/puppet/provider/package/yum.rb +7 -0
  42. data/lib/puppet/provider/package/zypper.rb +59 -1
  43. data/lib/puppet/provider/service/systemd.rb +21 -4
  44. data/lib/puppet/provider/user/useradd.rb +5 -1
  45. data/lib/puppet/reports/http.rb +5 -3
  46. data/lib/puppet/runtime.rb +25 -2
  47. data/lib/puppet/ssl/state_machine.rb +33 -8
  48. data/lib/puppet/ssl/verifier_adapter.rb +9 -1
  49. data/lib/puppet/test/test_helper.rb +1 -1
  50. data/lib/puppet/type/file/source.rb +1 -1
  51. data/lib/puppet/type/package.rb +16 -1
  52. data/lib/puppet/type/service.rb +6 -8
  53. data/lib/puppet/type/user.rb +1 -7
  54. data/lib/puppet/util/autoload.rb +1 -18
  55. data/lib/puppet/util/log/destinations.rb +1 -10
  56. data/lib/puppet/util/package/version/range.rb +4 -1
  57. data/lib/puppet/util/package/version/range/eq.rb +14 -0
  58. data/lib/puppet/version.rb +1 -1
  59. data/locales/puppet.pot +191 -111
  60. data/man/man5/puppet.conf.5 +21 -2
  61. data/man/man8/puppet-agent.8 +1 -1
  62. data/man/man8/puppet-apply.8 +1 -1
  63. data/man/man8/puppet-catalog.8 +1 -1
  64. data/man/man8/puppet-config.8 +1 -1
  65. data/man/man8/puppet-describe.8 +1 -1
  66. data/man/man8/puppet-device.8 +1 -1
  67. data/man/man8/puppet-doc.8 +1 -1
  68. data/man/man8/puppet-epp.8 +1 -1
  69. data/man/man8/puppet-facts.8 +1 -1
  70. data/man/man8/puppet-filebucket.8 +1 -1
  71. data/man/man8/puppet-generate.8 +1 -1
  72. data/man/man8/puppet-help.8 +6 -3
  73. data/man/man8/puppet-key.8 +1 -1
  74. data/man/man8/puppet-lookup.8 +1 -1
  75. data/man/man8/puppet-man.8 +1 -1
  76. data/man/man8/puppet-module.8 +4 -1
  77. data/man/man8/puppet-node.8 +1 -1
  78. data/man/man8/puppet-parser.8 +1 -1
  79. data/man/man8/puppet-plugin.8 +1 -1
  80. data/man/man8/puppet-report.8 +1 -1
  81. data/man/man8/puppet-resource.8 +1 -1
  82. data/man/man8/puppet-script.8 +1 -1
  83. data/man/man8/puppet-ssl.8 +1 -1
  84. data/man/man8/puppet-status.8 +1 -1
  85. data/man/man8/puppet.8 +2 -2
  86. data/spec/fixtures/unit/provider/package/dnfmodule/{dnf-module-list-enabled.txt → dnf-module-list.txt} +6 -0
  87. data/spec/fixtures/unit/provider/package/zypper/zypper-search-uninstalled.out +13 -0
  88. data/spec/integration/application/agent_spec.rb +66 -1
  89. data/spec/integration/application/plugin_spec.rb +23 -0
  90. data/spec/integration/http/client_spec.rb +6 -1
  91. data/spec/integration/network/http_pool_spec.rb +56 -0
  92. data/spec/integration/util/windows/adsi_spec.rb +5 -0
  93. data/spec/lib/puppet_spec/https.rb +6 -0
  94. data/spec/unit/agent_spec.rb +47 -1
  95. data/spec/unit/application/agent_spec.rb +4 -4
  96. data/spec/unit/context/trusted_information_spec.rb +17 -0
  97. data/spec/unit/daemon_spec.rb +5 -64
  98. data/spec/unit/face/module/search_spec.rb +17 -0
  99. data/spec/unit/file_system/uniquefile_spec.rb +11 -0
  100. data/spec/unit/http/client_spec.rb +10 -10
  101. data/spec/unit/http/external_client_spec.rb +9 -9
  102. data/spec/unit/indirector/catalog/compiler_spec.rb +1 -0
  103. data/spec/unit/indirector/file_metadata/http_spec.rb +167 -0
  104. data/spec/unit/indirector/file_metadata/rest_spec.rb +15 -14
  105. data/spec/unit/indirector/rest_spec.rb +13 -0
  106. data/spec/unit/network/http/connection_spec.rb +542 -190
  107. data/spec/unit/network/http/nocache_pool_spec.rb +22 -0
  108. data/spec/unit/network/http_pool_spec.rb +63 -57
  109. data/spec/unit/network/http_spec.rb +1 -1
  110. data/spec/unit/provider/package/aix_spec.rb +29 -0
  111. data/spec/unit/provider/package/dnfmodule_spec.rb +25 -5
  112. data/spec/unit/provider/package/pip_spec.rb +42 -16
  113. data/spec/unit/provider/package/portage_spec.rb +5 -0
  114. data/spec/unit/provider/package/yum_spec.rb +16 -8
  115. data/spec/unit/provider/package/zypper_spec.rb +84 -0
  116. data/spec/unit/provider/service/init_spec.rb +1 -0
  117. data/spec/unit/provider/service/openbsd_spec.rb +9 -0
  118. data/spec/unit/provider/service/openwrt_spec.rb +1 -0
  119. data/spec/unit/provider/service/redhat_spec.rb +9 -0
  120. data/spec/unit/provider/service/systemd_spec.rb +84 -13
  121. data/spec/unit/provider/user/useradd_spec.rb +8 -0
  122. data/spec/unit/puppet_pal_catalog_spec.rb +43 -0
  123. data/spec/unit/puppet_spec.rb +33 -0
  124. data/spec/unit/reports/http_spec.rb +1 -1
  125. data/spec/unit/ssl/state_machine_spec.rb +52 -8
  126. data/spec/unit/type/service_spec.rb +9 -8
  127. data/spec/unit/type/user_spec.rb +1 -1
  128. data/spec/unit/util/autoload_spec.rb +2 -1
  129. data/spec/unit/util/log/destinations_spec.rb +1 -29
  130. data/spec/unit/util/package/version/range_spec.rb +22 -1
  131. data/tasks/manpages.rake +5 -35
  132. metadata +10 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 799de4826be20694f329d3ab8d2e5f74c6e347b5f1a90a2c568073567eaba0aa
4
- data.tar.gz: b159338a79e3bf9ba9f8ed2ba106ff47f8348d72d01c2b91baaede85dd87d1b8
3
+ metadata.gz: f7064d29333b18df07d4c488db3f8467f20bdf950e574ef7ca69efdd9720b5a9
4
+ data.tar.gz: 8bc256737ac5510ee41887b4baa265192cabfcb5e9dd35845aaec43b878cece2
5
5
  SHA512:
6
- metadata.gz: feb2df24a40555df272fdeaf014377cb034ac9789bc42bf05592d54848130c817683cc8edfbac7e207af9c5b208a43ec355fdcaf062f9fe80790c7438a859cac
7
- data.tar.gz: af68bac1aa1d0f8757e3eb910a2d5ff8665a03d9a59374284420fccd0eadee7365ec16bf8d781cae3d1802679ee42277fe6d2e501bd910968f2d073f1804acd3
6
+ metadata.gz: 9975d18863323ec983022ae7597cdf39881cae07bba8e1563979a0c56b7ae6ca7f78453c8298ab9f36cda3af743c9bc93c1c1b18114fa2ddaed28ba0683436cd
7
+ data.tar.gz: 346632f11b0236699c41b94994d76792d5fe8c5570b4ae7c6de3999ae7ece9f87ec94e7c924397994e050c385536a3a1559e67e82450c383e8f269ef52a27807
data/CODEOWNERS CHANGED
@@ -11,13 +11,8 @@
11
11
  /lib/puppet/provider/service @puppetlabs/night-s-watch
12
12
  /lib/puppet/provider/user @puppetlabs/night-s-watch
13
13
 
14
- # language
15
- /lib/puppet/datatypes @puppetlabs/language
16
- /lib/puppet/functions @puppetlabs/language
17
- /lib/puppet/pal @puppetlabs/language
18
- /lib/puppet/parser @puppetlabs/language
19
- /lib/puppet/pops @puppetlabs/language
20
- /lib/puppet/syntax_checkers @puppetlabs/language
14
+ # PAL
15
+ /lib/puppet/pal @puppetlabs/bolt
21
16
 
22
17
  # puppet device
23
18
  /lib/puppet/application/device.rb @puppetlabs/networking
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- puppet (6.15.0)
4
+ puppet (6.16.0)
5
5
  CFPropertyList (~> 2.2)
6
6
  concurrent-ruby (~> 1.0)
7
7
  deep_merge (~> 1.0)
@@ -25,11 +25,13 @@ GEM
25
25
  concurrent-ruby (1.1.6)
26
26
  crack (0.4.3)
27
27
  safe_yaml (~> 1.0.0)
28
- csv (3.1.2)
28
+ csv (3.1.5)
29
29
  deep_merge (1.2.1)
30
30
  diff-lcs (1.3)
31
31
  docopt (0.6.1)
32
- facter (2.5.7)
32
+ facter (4.0.25)
33
+ hocon (~> 1.3)
34
+ thor (>= 1.0.1, < 2.0)
33
35
  fast_gettext (1.1.2)
34
36
  gettext (3.2.9)
35
37
  locale (>= 2.0.5)
@@ -44,7 +46,7 @@ GEM
44
46
  highline (~> 1.6.19)
45
47
  optimist
46
48
  highline (1.6.21)
47
- hocon (1.3.0)
49
+ hocon (1.3.1)
48
50
  hpricot (0.8.6)
49
51
  httpclient (2.8.3)
50
52
  json-schema (2.8.1)
@@ -62,17 +64,17 @@ GEM
62
64
  rake (>= 12.3)
63
65
  release-metrics
64
66
  parallel (1.19.1)
65
- parser (2.7.1.1)
67
+ parser (2.7.1.3)
66
68
  ast (~> 2.4.0)
67
69
  powerpack (0.1.2)
68
70
  pry (0.13.1)
69
71
  coderay (~> 1.1)
70
72
  method_source (~> 1.0)
71
- public_suffix (4.0.4)
73
+ public_suffix (4.0.5)
72
74
  puppet-resource_api (1.8.13)
73
75
  hocon (>= 1.0)
74
- puppetserver-ca (1.7.0)
75
- facter (>= 2.0.1, < 4)
76
+ puppetserver-ca (1.8.0)
77
+ facter (>= 2.0.1, < 5)
76
78
  racc (1.4.9)
77
79
  rainbow (2.2.2)
78
80
  rake
@@ -90,9 +92,9 @@ GEM
90
92
  rspec-core (~> 3.9.0)
91
93
  rspec-expectations (~> 3.9.0)
92
94
  rspec-mocks (~> 3.9.0)
93
- rspec-core (3.9.1)
94
- rspec-support (~> 3.9.1)
95
- rspec-expectations (3.9.1)
95
+ rspec-core (3.9.2)
96
+ rspec-support (~> 3.9.3)
97
+ rspec-expectations (3.9.2)
96
98
  diff-lcs (>= 1.2.0, < 2.0)
97
99
  rspec-support (~> 3.9.0)
98
100
  rspec-its (1.3.0)
@@ -101,7 +103,7 @@ GEM
101
103
  rspec-mocks (3.9.1)
102
104
  diff-lcs (>= 1.2.0, < 2.0)
103
105
  rspec-support (~> 3.9.0)
104
- rspec-support (3.9.2)
106
+ rspec-support (3.9.3)
105
107
  rubocop (0.49.1)
106
108
  parallel (~> 1.10)
107
109
  parser (>= 2.3.3.1, < 3.0)
@@ -111,18 +113,19 @@ GEM
111
113
  unicode-display_width (~> 1.0, >= 1.0.1)
112
114
  rubocop-i18n (1.2.0)
113
115
  rubocop (~> 0.49.0)
114
- ruby-prof (1.3.2)
116
+ ruby-prof (1.4.1)
115
117
  ruby-progressbar (1.10.1)
116
118
  safe_yaml (1.0.5)
117
119
  semantic_puppet (1.0.2)
118
120
  text (1.3.1)
121
+ thor (1.0.1)
119
122
  unicode-display_width (1.7.0)
120
123
  vcr (5.1.0)
121
124
  webmock (3.8.3)
122
125
  addressable (>= 2.3.6)
123
126
  crack (>= 0.3.2)
124
127
  hashdiff (>= 0.4.0, < 2.0.0)
125
- yard (0.9.24)
128
+ yard (0.9.25)
126
129
 
127
130
  PLATFORMS
128
131
  ruby
@@ -1,4 +1,5 @@
1
1
  require 'puppet/version'
2
+ require 'puppet/concurrent/synchronized'
2
3
 
3
4
  if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new("2.3.0")
4
5
  raise LoadError, "Puppet #{Puppet.version} requires Ruby 2.3.0 or greater, found Ruby #{RUBY_VERSION.dup}."
@@ -6,6 +7,8 @@ end
6
7
 
7
8
  Puppet::OLDEST_RECOMMENDED_RUBY_VERSION = '2.3.0'
8
9
 
10
+ $LOAD_PATH.extend(Puppet::Concurrent::Synchronized)
11
+
9
12
  # see the bottom of the file for further inclusions
10
13
  # Also see the new Vendor support - towards the end
11
14
  #
@@ -150,21 +153,45 @@ module Puppet
150
153
  # @param args [Array<String>] the command line arguments to use for initialization
151
154
  # @param require_config [Boolean] controls loading of Puppet configuration files
152
155
  # @param global_settings [Boolean] controls push to global context after settings object initialization
156
+ # @param runtime_implementations [Hash<Symbol, Object>] runtime implementations to register
153
157
  # @return [void]
154
- def self.initialize_settings(args = [], require_config = true, push_settings_globally = true)
155
- do_initialize_settings_for_run_mode(:user, args, require_config, push_settings_globally)
158
+ def self.initialize_settings(args = [], require_config = true, push_settings_globally = true, runtime_implementations = {})
159
+ do_initialize_settings_for_run_mode(:user, args, require_config, push_settings_globally, runtime_implementations)
160
+ end
161
+
162
+ def self.vendored_modules
163
+ dir = Puppet[:vendormoduledir]
164
+ if dir && File.directory?(dir)
165
+ Dir.entries(dir)
166
+ .reject { |f| f =~ /^\./ }
167
+ .map { |f| File.join(dir, f, "lib") }
168
+ .select { |d| FileTest.directory?(d) }
169
+ else
170
+ []
171
+ end
156
172
  end
173
+ private_class_method :vendored_modules
174
+
175
+ def self.initialize_load_path
176
+ $LOAD_PATH.unshift(Puppet[:libdir])
177
+ $LOAD_PATH.concat(vendored_modules)
178
+ end
179
+ private_class_method :initialize_load_path
157
180
 
158
181
  # private helper method to provide the implementation details of initializing for a run mode,
159
182
  # but allowing us to control where the deprecation warning is issued
160
- def self.do_initialize_settings_for_run_mode(run_mode, args, require_config = true, push_settings_globally = true)
183
+ def self.do_initialize_settings_for_run_mode(run_mode, args, require_config, push_settings_globally, runtime_implementations)
161
184
  Puppet.settings.initialize_global_settings(args, require_config)
162
185
  run_mode = Puppet::Util::RunMode[run_mode]
163
186
  Puppet.settings.initialize_app_defaults(Puppet::Settings.app_defaults_for_run_mode(run_mode))
164
187
  if push_settings_globally
188
+ initialize_load_path
165
189
  push_context_global(Puppet.base_context(Puppet.settings), "Initial context after settings initialization")
166
190
  Puppet::Parser::Functions.reset
167
191
  end
192
+ runtime_implementations.each_pair do |name, impl|
193
+ Puppet.runtime[name] = impl
194
+ end
168
195
  end
169
196
  private_class_method :do_initialize_settings_for_run_mode
170
197
 
@@ -218,10 +245,7 @@ module Puppet
218
245
 
219
246
  {
220
247
  :environments => Puppet::Environments::Cached.new(Puppet::Environments::Combined.new(*loaders)),
221
- :http_pool => proc {
222
- require 'puppet/network/http'
223
- Puppet::Network::HTTP::NoCachePool.new
224
- },
248
+ :http_pool => proc { Puppet.runtime[:http].pool },
225
249
  :ssl_context => proc {
226
250
  begin
227
251
  cert = Puppet::X509::CertProvider.new
@@ -237,7 +261,7 @@ module Puppet
237
261
  end
238
262
  },
239
263
  :ssl_host => proc { Puppet::SSL::Host.localhost(true) },
240
- :http_session => proc { Puppet.runtime["http"].create_session },
264
+ :http_session => proc { Puppet.runtime[:http].create_session },
241
265
  :plugins => proc { Puppet::Plugins::Configuration.load_plugins },
242
266
  :rich_data => false
243
267
  }
@@ -43,6 +43,7 @@ class Puppet::Agent
43
43
  end
44
44
 
45
45
  result = nil
46
+ wait_for_lock_deadline = nil
46
47
  block_run = Puppet::Application.controlled_run do
47
48
  splay client_options.fetch :splay, Puppet[:splay]
48
49
  result = run_in_fork(should_fork) do
@@ -60,16 +61,29 @@ class Puppet::Agent
60
61
  end
61
62
  end
62
63
  rescue Puppet::LockError
63
- Puppet.notice _("Run of %{client_class} already in progress; skipping (%{lockfile_path} exists)") % { client_class: client_class, lockfile_path: lockfile_path }
64
- return
64
+ now = Time.now.to_i
65
+ wait_for_lock_deadline ||= now + Puppet[:maxwaitforlock]
66
+
67
+ if Puppet[:waitforlock] < 1
68
+ Puppet.notice _("Run of %{client_class} already in progress; skipping (%{lockfile_path} exists)") % { client_class: client_class, lockfile_path: lockfile_path }
69
+ nil
70
+ elsif now > wait_for_lock_deadline
71
+ Puppet.notice _("Exiting now because the maxwaitforlock timeout has been exceeded.")
72
+ nil
73
+ else
74
+ Puppet.info _("Another puppet instance is already running; --waitforlock flag used, waiting for running instance to finish.")
75
+ Puppet.info _("Will try again in %{time} seconds.") % {time: Puppet[:waitforlock]}
76
+ sleep Puppet[:waitforlock]
77
+ retry
78
+ end
65
79
  rescue RunTimeoutError => detail
66
80
  Puppet.log_exception(detail, _("Execution of %{client_class} did not complete within %{runtimeout} seconds and was terminated.") %
67
81
  {client_class: client_class,
68
82
  runtimeout: Puppet[:runtimeout]})
69
- return 1
83
+ nil
70
84
  rescue StandardError => detail
71
85
  Puppet.log_exception(detail, _("Could not run %{client_class}: %{detail}") % { client_class: client_class, detail: detail })
72
- 1
86
+ nil
73
87
  end
74
88
  end
75
89
  end
@@ -489,9 +489,8 @@ Copyright (c) 2011 Puppet Inc., LLC Licensed under the Apache 2.0 License
489
489
  end
490
490
 
491
491
  def daemonize_process_when(should_daemonize)
492
- daemon = Puppet::Daemon.new(Puppet::Util::Pidlock.new(Puppet[:pidfile]))
492
+ daemon = Puppet::Daemon.new(@agent, Puppet::Util::Pidlock.new(Puppet[:pidfile]))
493
493
  daemon.argv = @argv
494
- daemon.agent = @agent
495
494
 
496
495
  daemon.daemonize if should_daemonize
497
496
 
@@ -259,7 +259,7 @@ Licensed under the Apache 2.0 License
259
259
  end
260
260
  end
261
261
  devices.collect do |devicename,device|
262
- pool = Puppet.runtime['http'].pool
262
+ pool = Puppet.runtime[:http].pool
263
263
  Puppet.override(:http_pool => pool) do
264
264
  # TODO when we drop support for ruby < 2.5 we can remove the extra block here
265
265
  begin
@@ -1,3 +1,4 @@
1
1
  require 'puppet/application/face_base'
2
2
  class Puppet::Application::Plugin < Puppet::Application::FaceBase
3
+ environment_mode :not_required
3
4
  end
@@ -90,7 +90,7 @@ HELP
90
90
  @cert_provider = Puppet::X509::CertProvider.new
91
91
  @ssl_provider = Puppet::SSL::SSLProvider.new
92
92
  @machine = Puppet::SSL::StateMachine.new
93
- @session = Puppet.runtime['http'].create_session
93
+ @session = Puppet.runtime[:http].create_session
94
94
  end
95
95
 
96
96
  def setup_logs
@@ -194,7 +194,7 @@ class Puppet::Configurer
194
194
  # This just passes any options on to the catalog,
195
195
  # which accepts :tags and :ignoreschedules.
196
196
  def run(options = {})
197
- pool = Puppet.runtime['http'].pool
197
+ pool = Puppet.runtime[:http].pool
198
198
  # We create the report pre-populated with default settings for
199
199
  # environment and transaction_uuid very early, this is to ensure
200
200
  # they are sent regardless of any catalog compilation failures or
@@ -459,7 +459,7 @@ class Puppet::Configurer
459
459
  ::Facter.clear
460
460
  facts = find_facts
461
461
 
462
- client = Puppet.runtime['http']
462
+ client = Puppet.runtime[:http]
463
463
  session = client.create_session
464
464
  puppet = session.route_to(:puppet)
465
465
 
@@ -29,11 +29,6 @@ class Puppet::Context::TrustedInformation
29
29
  # @return [String]
30
30
  attr_reader :hostname
31
31
 
32
- # Additional external facts loaded through `trusted_external_command`.
33
- #
34
- # @return [Hash]
35
- attr_reader :external
36
-
37
32
  def initialize(authenticated, certname, extensions, external = {})
38
33
  @authenticated = authenticated.freeze
39
34
  @certname = certname.freeze
@@ -46,11 +41,11 @@ class Puppet::Context::TrustedInformation
46
41
  end
47
42
  @hostname = hostname.freeze
48
43
  @domain = domain.freeze
49
- @external = external.freeze
44
+ @external = external.is_a?(Proc) ? external : external.freeze
50
45
  end
51
46
 
52
47
  def self.remote(authenticated, node_name, certificate)
53
- external = retrieve_trusted_external(node_name)
48
+ external = proc { retrieve_trusted_external(node_name) }
54
49
 
55
50
  if authenticated
56
51
  extensions = {}
@@ -70,8 +65,19 @@ class Puppet::Context::TrustedInformation
70
65
  def self.local(node)
71
66
  # Always trust local data by picking up the available parameters.
72
67
  client_cert = node ? node.parameters['clientcert'] : nil
68
+ external = proc { retrieve_trusted_external(client_cert) }
69
+
70
+ new('local', client_cert, {}, external)
71
+ end
73
72
 
74
- new('local', client_cert, {}, retrieve_trusted_external(client_cert))
73
+ # Additional external facts loaded through `trusted_external_command`.
74
+ #
75
+ # @return [Hash]
76
+ def external
77
+ if @external.is_a?(Proc)
78
+ @external = @external.call.freeze
79
+ end
80
+ @external
75
81
  end
76
82
 
77
83
  def self.retrieve_trusted_external(certname)
@@ -1,19 +1,15 @@
1
1
  require 'puppet/application'
2
2
  require 'puppet/scheduler'
3
3
 
4
- # Run periodic actions and a network server in a daemonized process.
4
+ # Run periodic actions in a daemonized process.
5
5
  #
6
- # A Daemon has 3 parts:
6
+ # A Daemon has 2 parts:
7
7
  # * config reparse
8
- # * (optional) an agent that responds to #run
9
- # * (optional) a server that response to #stop, #start, and #wait_for_shutdown
8
+ # * an agent that responds to #run
10
9
  #
11
- # The config reparse will occur periodically based on Settings. The server will
12
- # be started and is expected to manage its own run loop (and so not block the
13
- # start call). The server will, however, still be waited for by using the
14
- # #wait_for_shutdown method. The agent is run periodically and a time interval
15
- # based on Settings. The config reparse will update this time interval when
16
- # needed.
10
+ # The config reparse will occur periodically based on Settings. The agent
11
+ # is run periodically and a time interval based on Settings. The config
12
+ # reparse will update this time interval when needed.
17
13
  #
18
14
  # The Daemon is also responsible for signal handling, starting, stopping,
19
15
  # running the agent on demand, and reloading the entire process. It ensures
@@ -23,12 +19,14 @@ require 'puppet/scheduler'
23
19
  class Puppet::Daemon
24
20
  SIGNAL_CHECK_INTERVAL = 5
25
21
 
26
- attr_accessor :agent, :server, :argv
27
- attr_reader :signals
22
+ attr_accessor :argv
23
+ attr_reader :signals, :agent
28
24
 
29
- def initialize(pidfile, scheduler = Puppet::Scheduler::Scheduler.new())
25
+ def initialize(agent, pidfile, scheduler = Puppet::Scheduler::Scheduler.new())
26
+ raise Puppet::DevError, _("Daemons must have an agent") unless agent
30
27
  @scheduler = scheduler
31
28
  @pidfile = pidfile
29
+ @agent = agent
32
30
  @signals = []
33
31
  end
34
32
 
@@ -88,7 +86,6 @@ class Puppet::Daemon
88
86
  end
89
87
 
90
88
  def reload
91
- return unless agent
92
89
  agent.run({:splay => false})
93
90
  rescue Puppet::LockError
94
91
  Puppet.notice "Not triggering already-running agent"
@@ -96,7 +93,7 @@ class Puppet::Daemon
96
93
 
97
94
  def restart
98
95
  Puppet::Application.restart!
99
- reexec unless agent and agent.running?
96
+ reexec
100
97
  end
101
98
 
102
99
  def reopen_logs
@@ -129,8 +126,6 @@ class Puppet::Daemon
129
126
  def stop(args = {:exit => true})
130
127
  Puppet::Application.stop!
131
128
 
132
- server.stop if server
133
-
134
129
  remove_pidfile
135
130
 
136
131
  Puppet::Util::Log.close_all
@@ -140,16 +135,7 @@ class Puppet::Daemon
140
135
 
141
136
  def start
142
137
  create_pidfile
143
-
144
- raise Puppet::DevError, _("Daemons must have an agent, server, or both") unless agent or server
145
-
146
- # Start the listening server, if required.
147
- server.start if server
148
-
149
- # Finally, loop forever running events - or, at least, until we exit.
150
138
  run_event_loop
151
-
152
- server.wait_for_shutdown if server
153
139
  end
154
140
 
155
141
  private
@@ -165,6 +151,7 @@ class Puppet::Daemon
165
151
  @pidfile.unlock
166
152
  end
167
153
 
154
+ # Loop forever running events - or, at least, until we exit.
168
155
  def run_event_loop
169
156
  agent_run = Puppet::Scheduler.create_job(Puppet[:runinterval], Puppet[:splay], Puppet[:splaylimit]) do
170
157
  # Splay for the daemon is handled in the scheduler
@@ -189,7 +176,6 @@ class Puppet::Daemon
189
176
  end
190
177
 
191
178
  reparse_run.disable if Puppet[:filetimeout] == 0
192
- agent_run.disable unless agent
193
179
 
194
180
  @scheduler.run_loop([reparse_run, agent_run, signal_loop])
195
181
  end