puppet 7.9.0-universal-darwin → 7.10.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 (182) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +6 -6
  3. data/{ext → examples/enc}/regexp_nodes/classes/databases +0 -0
  4. data/{ext → examples/enc}/regexp_nodes/classes/webservers +0 -0
  5. data/{ext → examples/enc}/regexp_nodes/environment/development +0 -0
  6. data/{ext → examples/enc}/regexp_nodes/parameters/service/prod +0 -0
  7. data/{ext → examples/enc}/regexp_nodes/parameters/service/qa +0 -0
  8. data/{ext → examples/enc}/regexp_nodes/parameters/service/sandbox +0 -0
  9. data/{ext → examples/enc}/regexp_nodes/regexp_nodes.rb +0 -0
  10. data/{ext → examples}/nagios/check_puppet.rb +2 -2
  11. data/ext/README.md +13 -0
  12. data/lib/puppet/configurer.rb +155 -46
  13. data/lib/puppet/defaults.rb +51 -26
  14. data/lib/puppet/environments.rb +66 -26
  15. data/lib/puppet/file_serving/configuration.rb +2 -0
  16. data/lib/puppet/file_serving/configuration/parser.rb +2 -0
  17. data/lib/puppet/file_serving/mount/scripts.rb +24 -0
  18. data/lib/puppet/functions/find_template.rb +2 -2
  19. data/lib/puppet/http/service/compiler.rb +6 -1
  20. data/lib/puppet/indirector/catalog/compiler.rb +21 -3
  21. data/lib/puppet/indirector/catalog/rest.rb +1 -0
  22. data/lib/puppet/indirector/terminus.rb +4 -0
  23. data/lib/puppet/module/plan.rb +0 -1
  24. data/lib/puppet/module/task.rb +1 -1
  25. data/lib/puppet/module_tool/applications/installer.rb +8 -4
  26. data/lib/puppet/network/http/api/indirected_routes.rb +1 -1
  27. data/lib/puppet/node/environment.rb +10 -11
  28. data/lib/puppet/pops/serialization/to_data_converter.rb +18 -6
  29. data/lib/puppet/provider/package/pkg.rb +8 -1
  30. data/lib/puppet/provider/service/launchd.rb +1 -1
  31. data/lib/puppet/provider/service/systemd.rb +1 -1
  32. data/lib/puppet/provider/user/useradd.rb +42 -9
  33. data/lib/puppet/transaction/persistence.rb +11 -1
  34. data/lib/puppet/transaction/report.rb +15 -1
  35. data/lib/puppet/type.rb +1 -1
  36. data/lib/puppet/type/exec.rb +10 -1
  37. data/lib/puppet/type/file.rb +6 -6
  38. data/lib/puppet/type/filebucket.rb +2 -2
  39. data/lib/puppet/version.rb +1 -1
  40. data/locales/puppet.pot +134 -94
  41. data/man/man5/puppet.conf.5 +65 -25
  42. data/man/man8/puppet-agent.8 +1 -1
  43. data/man/man8/puppet-apply.8 +1 -1
  44. data/man/man8/puppet-catalog.8 +1 -1
  45. data/man/man8/puppet-config.8 +1 -1
  46. data/man/man8/puppet-describe.8 +1 -1
  47. data/man/man8/puppet-device.8 +1 -1
  48. data/man/man8/puppet-doc.8 +1 -1
  49. data/man/man8/puppet-epp.8 +1 -1
  50. data/man/man8/puppet-facts.8 +1 -1
  51. data/man/man8/puppet-filebucket.8 +1 -1
  52. data/man/man8/puppet-generate.8 +1 -1
  53. data/man/man8/puppet-help.8 +1 -1
  54. data/man/man8/puppet-lookup.8 +1 -1
  55. data/man/man8/puppet-module.8 +3 -3
  56. data/man/man8/puppet-node.8 +1 -1
  57. data/man/man8/puppet-parser.8 +1 -1
  58. data/man/man8/puppet-plugin.8 +1 -1
  59. data/man/man8/puppet-report.8 +1 -1
  60. data/man/man8/puppet-resource.8 +1 -1
  61. data/man/man8/puppet-script.8 +1 -1
  62. data/man/man8/puppet-ssl.8 +1 -1
  63. data/man/man8/puppet.8 +2 -2
  64. data/spec/fixtures/integration/application/agent/lib/facter/agent_spec_role.rb +3 -0
  65. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/Gemfile +4 -0
  66. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/Rakefile +3 -0
  67. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/lib/puppet/functions/l10n.rb +8 -0
  68. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/locales/config.yaml +25 -0
  69. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/locales/ja/puppet-l10n.po +19 -0
  70. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/locales/puppet-l10n.pot +20 -0
  71. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/metadata.json +8 -0
  72. data/spec/integration/application/agent_spec.rb +102 -52
  73. data/spec/integration/application/filebucket_spec.rb +5 -0
  74. data/spec/integration/configurer_spec.rb +17 -1
  75. data/spec/integration/l10n/compiler_spec.rb +37 -0
  76. data/spec/lib/puppet_spec/modules.rb +13 -2
  77. data/spec/lib/puppet_spec/puppetserver.rb +15 -0
  78. data/spec/shared_behaviours/documentation_on_faces.rb +0 -2
  79. data/spec/shared_contexts/l10n.rb +27 -0
  80. data/spec/spec_helper.rb +1 -10
  81. data/spec/unit/configurer_spec.rb +265 -54
  82. data/spec/unit/environments_spec.rb +150 -1
  83. data/spec/unit/file_serving/configuration/parser_spec.rb +23 -0
  84. data/spec/unit/file_serving/configuration_spec.rb +12 -4
  85. data/spec/unit/file_serving/mount/scripts_spec.rb +69 -0
  86. data/spec/unit/functions/logging_spec.rb +1 -0
  87. data/spec/unit/http/service/compiler_spec.rb +8 -0
  88. data/spec/unit/indirector/catalog/compiler_spec.rb +87 -0
  89. data/spec/unit/indirector/catalog/rest_spec.rb +8 -0
  90. data/spec/unit/interface/action_spec.rb +0 -9
  91. data/spec/unit/module_spec.rb +14 -0
  92. data/spec/unit/module_tool/applications/installer_spec.rb +39 -12
  93. data/spec/unit/pops/parser/parse_containers_spec.rb +0 -11
  94. data/spec/unit/pops/serialization/to_from_hr_spec.rb +58 -0
  95. data/spec/unit/provider/package/pkg_spec.rb +19 -5
  96. data/spec/unit/provider/service/launchd_spec.rb +11 -0
  97. data/spec/unit/provider/service/systemd_spec.rb +1 -1
  98. data/spec/unit/provider/user/useradd_spec.rb +3 -2
  99. metadata +34 -94
  100. data/ext/README.environment +0 -8
  101. data/ext/dbfix.sql +0 -132
  102. data/ext/debian/README.Debian +0 -8
  103. data/ext/debian/README.source +0 -2
  104. data/ext/debian/TODO.Debian +0 -1
  105. data/ext/debian/changelog.erb +0 -1122
  106. data/ext/debian/compat +0 -1
  107. data/ext/debian/control +0 -144
  108. data/ext/debian/copyright +0 -339
  109. data/ext/debian/docs +0 -1
  110. data/ext/debian/fileserver.conf +0 -41
  111. data/ext/debian/puppet-common.dirs +0 -13
  112. data/ext/debian/puppet-common.install +0 -3
  113. data/ext/debian/puppet-common.lintian-overrides +0 -5
  114. data/ext/debian/puppet-common.manpages +0 -28
  115. data/ext/debian/puppet-common.postinst +0 -35
  116. data/ext/debian/puppet-common.postrm +0 -33
  117. data/ext/debian/puppet-el.dirs +0 -1
  118. data/ext/debian/puppet-el.emacsen-install +0 -25
  119. data/ext/debian/puppet-el.emacsen-remove +0 -11
  120. data/ext/debian/puppet-el.emacsen-startup +0 -9
  121. data/ext/debian/puppet-el.install +0 -1
  122. data/ext/debian/puppet-testsuite.install +0 -2
  123. data/ext/debian/puppet-testsuite.lintian-overrides +0 -4
  124. data/ext/debian/puppet.lintian-overrides +0 -3
  125. data/ext/debian/puppet.logrotate +0 -20
  126. data/ext/debian/puppet.postinst +0 -20
  127. data/ext/debian/puppet.postrm +0 -20
  128. data/ext/debian/puppet.preinst +0 -20
  129. data/ext/debian/puppetmaster-common.install +0 -2
  130. data/ext/debian/puppetmaster-common.manpages +0 -2
  131. data/ext/debian/puppetmaster-common.postinst +0 -6
  132. data/ext/debian/puppetmaster-passenger.dirs +0 -4
  133. data/ext/debian/puppetmaster-passenger.postinst +0 -162
  134. data/ext/debian/puppetmaster-passenger.postrm +0 -61
  135. data/ext/debian/puppetmaster.README.debian +0 -17
  136. data/ext/debian/puppetmaster.default +0 -14
  137. data/ext/debian/puppetmaster.init +0 -137
  138. data/ext/debian/puppetmaster.lintian-overrides +0 -3
  139. data/ext/debian/puppetmaster.postinst +0 -20
  140. data/ext/debian/puppetmaster.postrm +0 -5
  141. data/ext/debian/puppetmaster.preinst +0 -22
  142. data/ext/debian/rules +0 -132
  143. data/ext/debian/source/format +0 -1
  144. data/ext/debian/source/options +0 -1
  145. data/ext/debian/vim-puppet.README.Debian +0 -13
  146. data/ext/debian/vim-puppet.dirs +0 -5
  147. data/ext/debian/vim-puppet.yaml +0 -7
  148. data/ext/debian/watch +0 -2
  149. data/ext/freebsd/puppetd +0 -26
  150. data/ext/freebsd/puppetmasterd +0 -26
  151. data/ext/gentoo/conf.d/puppet +0 -5
  152. data/ext/gentoo/conf.d/puppetmaster +0 -12
  153. data/ext/gentoo/init.d/puppet +0 -38
  154. data/ext/gentoo/init.d/puppetmaster +0 -51
  155. data/ext/gentoo/puppet/fileserver.conf +0 -41
  156. data/ext/ips/puppet-agent +0 -44
  157. data/ext/ips/puppet-master +0 -44
  158. data/ext/ips/puppet.p5m.erb +0 -12
  159. data/ext/ips/puppetagent.xml +0 -42
  160. data/ext/ips/puppetmaster.xml +0 -42
  161. data/ext/ips/rules +0 -19
  162. data/ext/ips/transforms +0 -34
  163. data/ext/ldap/puppet.schema +0 -24
  164. data/ext/logcheck/puppet +0 -23
  165. data/ext/osx/file_mapping.yaml +0 -28
  166. data/ext/osx/postflight.erb +0 -109
  167. data/ext/osx/preflight.erb +0 -52
  168. data/ext/osx/prototype.plist.erb +0 -38
  169. data/ext/redhat/fileserver.conf +0 -41
  170. data/ext/redhat/logrotate +0 -21
  171. data/ext/redhat/puppet.spec.erb +0 -841
  172. data/ext/redhat/server.init +0 -128
  173. data/ext/redhat/server.sysconfig +0 -13
  174. data/ext/solaris/pkginfo +0 -6
  175. data/ext/solaris/smf/puppetd.xml +0 -77
  176. data/ext/solaris/smf/puppetmasterd.xml +0 -77
  177. data/ext/solaris/smf/svc-puppetd +0 -71
  178. data/ext/solaris/smf/svc-puppetmasterd +0 -67
  179. data/ext/suse/puppet.spec +0 -310
  180. data/ext/suse/server.init +0 -173
  181. data/ext/yaml_nodes.rb +0 -105
  182. data/spec/unit/indirector/store_configs_spec.rb +0 -7
@@ -48,6 +48,13 @@ module Puppet::Environments
48
48
  root.instance_variable_set(:@rich_data, nil)
49
49
  end
50
50
  end
51
+
52
+ # The base implementation is a noop, because `get` returns a new environment
53
+ # each time.
54
+ #
55
+ # @see Puppet::Environments::Cached#guard
56
+ def guard(name); end
57
+ def unguard(name); end
51
58
  end
52
59
 
53
60
  # @!macro [new] loader_search_paths
@@ -188,7 +195,7 @@ module Puppet::Environments
188
195
 
189
196
  def self.real_path(dir)
190
197
  if Puppet::FileSystem.symlink?(dir) && Puppet[:versioned_environment_dirs]
191
- dir = Puppet::FileSystem.expand_path(Puppet::FileSystem.readlink(dir))
198
+ dir = Pathname.new Puppet::FileSystem.expand_path(Puppet::FileSystem.readlink(dir))
192
199
  end
193
200
  return dir
194
201
  end
@@ -241,7 +248,7 @@ module Puppet::Environments
241
248
 
242
249
  def validated_directory(envdir)
243
250
  env_name = Puppet::FileSystem.basename_string(envdir)
244
- envdir = Puppet::Environments::Directories.real_path(envdir)
251
+ envdir = Puppet::Environments::Directories.real_path(envdir).to_s
245
252
  if Puppet::FileSystem.directory?(envdir) && Puppet::Node::Environment.valid_name?(env_name)
246
253
  envdir
247
254
  else
@@ -330,21 +337,13 @@ module Puppet::Environments
330
337
  end
331
338
 
332
339
  def self.cache_expiration_service=(service)
333
- @cache_expiration_service = service
340
+ @cache_expiration_service_singleton = service
334
341
  end
335
342
 
336
343
  def self.cache_expiration_service
337
- @cache_expiration_service || DefaultCacheExpirationService.new
344
+ @cache_expiration_service_singleton || DefaultCacheExpirationService.new
338
345
  end
339
346
 
340
- # Returns the end of time (the next Mesoamerican Long Count cycle-end after 2012 (5125+2012) = 7137
341
- def self.end_of_time
342
- Time.gm(7137)
343
- end
344
-
345
- END_OF_TIME = end_of_time
346
- START_OF_TIME = Time.gm(1)
347
-
348
347
  def initialize(loader)
349
348
  @loader = loader
350
349
  @cache_expiration_service = Puppet::Environments::Cached.cache_expiration_service
@@ -356,7 +355,7 @@ module Puppet::Environments
356
355
  # Evict all that have expired, in the same way as `get`
357
356
  clear_all_expired
358
357
 
359
- # Evict all that was removed from diks
358
+ # Evict all that was removed from disk
360
359
  cached_envs = @cache.keys.map!(&:to_sym)
361
360
  loader_envs = @loader.list.map!(&:name)
362
361
  removed_envs = cached_envs - loader_envs
@@ -385,27 +384,35 @@ module Puppet::Environments
385
384
 
386
385
  # @!macro loader_get
387
386
  def get(name)
387
+ entry = get_entry(name)
388
+ entry ? entry.value : nil
389
+ end
390
+
391
+ # Get a cache entry for an envionment. It returns nil if the
392
+ # environment doesn't exist.
393
+ def get_entry(name, check_expired = true)
388
394
  # Aggressively evict all that has expired
389
395
  # This strategy favors smaller memory footprint over environment
390
396
  # retrieval time.
391
- clear_all_expired
392
- result = @cache[name]
393
- if result
394
- Puppet.debug {"Found in cache '#{name}' #{result.label}"}
397
+ clear_all_expired if check_expired
398
+ name = name.to_sym
399
+ entry = @cache[name]
400
+ if entry
401
+ Puppet.debug {"Found in cache #{name.inspect} #{entry.label}"}
395
402
  # found in cache
396
- result.touch
397
- return result.value
398
- elsif (result = @loader.get(name))
403
+ entry.touch
404
+ elsif (env = @loader.get(name))
399
405
  # environment loaded, cache it
400
- cache_entry = entry(result)
401
- add_entry(name, cache_entry)
402
- result
406
+ entry = entry(env)
407
+ add_entry(name, entry)
403
408
  end
409
+ entry
404
410
  end
411
+ private :get_entry
405
412
 
406
413
  # Adds a cache entry to the cache
407
414
  def add_entry(name, cache_entry)
408
- Puppet.debug {"Caching environment '#{name}' #{cache_entry.label}"}
415
+ Puppet.debug {"Caching environment #{name.inspect} #{cache_entry.label}"}
409
416
  @cache[name] = cache_entry
410
417
  @cache_expiration_service.created(cache_entry.value)
411
418
  end
@@ -413,7 +420,7 @@ module Puppet::Environments
413
420
 
414
421
  def clear_entry(name, entry)
415
422
  @cache.delete(name)
416
- Puppet.debug {"Evicting cache entry for environment '#{name}'"}
423
+ Puppet.debug {"Evicting cache entry for environment #{name.inspect}"}
417
424
  @cache_expiration_service.evicted(name.to_sym)
418
425
  Puppet::GettextConfig.delete_text_domain(name)
419
426
  Puppet.settings.clear_environment_settings(name)
@@ -423,6 +430,7 @@ module Puppet::Environments
423
430
  # Clears the cache of the environment with the given name.
424
431
  # (The intention is that this could be used from a MANUAL cache eviction command (TBD)
425
432
  def clear(name)
433
+ name = name.to_sym
426
434
  entry = @cache[name]
427
435
  clear_entry(name, entry) if entry
428
436
  end
@@ -443,19 +451,21 @@ module Puppet::Environments
443
451
  # Clears all environments that have expired, either by exceeding their time to live, or
444
452
  # through an explicit eviction determined by the cache expiration service.
445
453
  #
446
- def clear_all_expired()
454
+ def clear_all_expired
447
455
  t = Time.now
448
456
 
449
457
  @cache.each_pair do |name, entry|
450
458
  clear_if_expired(name, entry, t)
451
459
  end
452
460
  end
461
+ private :clear_all_expired
453
462
 
454
463
  # Clear an environment if it is expired, either by exceeding its time to live, or
455
464
  # through an explicit eviction determined by the cache expiration service.
456
465
  #
457
466
  def clear_if_expired(name, entry, t = Time.now)
458
467
  return unless entry
468
+ return if entry.guarded?
459
469
 
460
470
  if entry.expired?(t) || @cache_expiration_service.expired?(name.to_sym)
461
471
  clear_entry(name, entry)
@@ -472,10 +482,25 @@ module Puppet::Environments
472
482
  #
473
483
  # @!macro loader_get_conf
474
484
  def get_conf(name)
485
+ name = name.to_sym
475
486
  clear_if_expired(name, @cache[name])
476
487
  @loader.get_conf(name)
477
488
  end
478
489
 
490
+ # Guard an environment so it can't be evicted while it's in use. The method
491
+ # may be called multiple times, provided it is unguarded the same number of
492
+ # times. If you call this method, you must call `unguard` in an ensure block.
493
+ def guard(name)
494
+ entry = get_entry(name, false)
495
+ entry.guard if entry
496
+ end
497
+
498
+ # Unguard an environment.
499
+ def unguard(name)
500
+ entry = get_entry(name, false)
501
+ entry.unguard if entry
502
+ end
503
+
479
504
  # Creates a suitable cache entry given the time to live for one environment
480
505
  #
481
506
  def entry(env)
@@ -501,6 +526,7 @@ module Puppet::Environments
501
526
 
502
527
  def initialize(value)
503
528
  @value = value
529
+ @guards = 0
504
530
  end
505
531
 
506
532
  def touch
@@ -513,6 +539,20 @@ module Puppet::Environments
513
539
  def label
514
540
  ""
515
541
  end
542
+
543
+ # These are not protected with a lock, because all of the Cached
544
+ # methods are protected.
545
+ def guarded?
546
+ @guards > 0
547
+ end
548
+
549
+ def guard
550
+ @guards += 1
551
+ end
552
+
553
+ def unguard
554
+ @guards -= 1
555
+ end
516
556
  end
517
557
 
518
558
  # Always evicting entry
@@ -6,6 +6,7 @@ require_relative '../../puppet/file_serving/mount/modules'
6
6
  require_relative '../../puppet/file_serving/mount/plugins'
7
7
  require_relative '../../puppet/file_serving/mount/locales'
8
8
  require_relative '../../puppet/file_serving/mount/pluginfacts'
9
+ require_relative '../../puppet/file_serving/mount/scripts'
9
10
  require_relative '../../puppet/file_serving/mount/tasks'
10
11
 
11
12
  class Puppet::FileServing::Configuration
@@ -83,6 +84,7 @@ class Puppet::FileServing::Configuration
83
84
  @mounts["plugins"] ||= Mount::Plugins.new("plugins")
84
85
  @mounts["locales"] ||= Mount::Locales.new("locales")
85
86
  @mounts["pluginfacts"] ||= Mount::PluginFacts.new("pluginfacts")
87
+ @mounts["scripts"] ||= Mount::Scripts.new("scripts")
86
88
  @mounts["tasks"] ||= Mount::Tasks.new("tasks")
87
89
  end
88
90
 
@@ -78,6 +78,8 @@ class Puppet::FileServing::Configuration::Parser
78
78
  mount = Mount::Modules.new(name)
79
79
  when "plugins"
80
80
  mount = Mount::Plugins.new(name)
81
+ when "scripts"
82
+ mount = Mount::Scripts.new(name)
81
83
  when "tasks"
82
84
  mount = Mount::Tasks.new(name)
83
85
  when "locales"
@@ -0,0 +1,24 @@
1
+ require 'puppet/file_serving/mount'
2
+
3
+ class Puppet::FileServing::Mount::Scripts < Puppet::FileServing::Mount
4
+ # Return an instance of the appropriate class.
5
+ def find(path, request)
6
+ raise _("No module specified") if path.to_s.empty?
7
+ module_name, relative_path = path.split("/", 2)
8
+ mod = request.environment.module(module_name)
9
+ return nil unless mod
10
+
11
+ mod.script(relative_path)
12
+ end
13
+
14
+ def search(path, request)
15
+ result = find(path, request)
16
+ if result
17
+ [result]
18
+ end
19
+ end
20
+
21
+ def valid?
22
+ true
23
+ end
24
+ end
@@ -2,11 +2,11 @@
2
2
  #
3
3
  # This function accepts an argument that is a String as a `<MODULE NAME>/<TEMPLATE>`
4
4
  # reference, which searches for `<TEMPLATE>` relative to a module's `templates`
5
- # directory on the master. (For example, the reference `mymod/secret.conf.epp`
5
+ # directory on the primary server. (For example, the reference `mymod/secret.conf.epp`
6
6
  # will search for the file `<MODULES DIRECTORY>/mymod/templates/secret.conf.epp`.)
7
7
  #
8
8
  # The primary use case is for agent-side template rendering with late-bound variables
9
- # resolved, such as from secret stores inaccessible to the master, such as
9
+ # resolved, such as from secret stores inaccessible to the primary server, such as
10
10
  #
11
11
  # ```
12
12
  # $variables = {
@@ -60,6 +60,10 @@ class Puppet::HTTP::Service::Compiler < Puppet::HTTP::Service
60
60
  # @param [String] environment The name of the environment we are operating in
61
61
  # @param [String] configured_environment Optional, the name of the configured
62
62
  # environment. If unset, `environment` is used.
63
+ # @param [Boolean] check_environment If true, request that the server check if
64
+ # our `environment` matches the server-specified environment. If they do not
65
+ # match, then the server may return an empty catalog in the server-specified
66
+ # environment.
63
67
  # @param [String] transaction_uuid An agent generated transaction uuid, used
64
68
  # for connecting catalogs and reports.
65
69
  # @param [String] job_uuid A unique job identifier defined when the orchestrator
@@ -75,7 +79,7 @@ class Puppet::HTTP::Service::Compiler < Puppet::HTTP::Service
75
79
  # the server
76
80
  #
77
81
  # @api public
78
- def post_catalog(name, facts:, environment:, configured_environment: nil, transaction_uuid: nil, job_uuid: nil, static_catalog: true, checksum_type: Puppet[:supported_checksum_types])
82
+ def post_catalog(name, facts:, environment:, configured_environment: nil, check_environment: false, transaction_uuid: nil, job_uuid: nil, static_catalog: true, checksum_type: Puppet[:supported_checksum_types])
79
83
  if Puppet[:preferred_serialization_format] == "pson"
80
84
  formatter = Puppet::Network::FormatHandler.format_for(:pson)
81
85
  # must use 'pson' instead of 'text/pson'
@@ -93,6 +97,7 @@ class Puppet::HTTP::Service::Compiler < Puppet::HTTP::Service
93
97
  facts: Puppet::Util.uri_query_encode(facts_as_string),
94
98
  environment: environment,
95
99
  configured_environment: configured_environment || environment,
100
+ check_environment: !!check_environment,
96
101
  transaction_uuid: transaction_uuid,
97
102
  job_uuid: job_uuid,
98
103
  static_catalog: static_catalog,
@@ -53,8 +53,22 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
53
53
  node.trusted_data = Puppet.lookup(:trusted_information) { Puppet::Context::TrustedInformation.local(node) }.to_h
54
54
 
55
55
  if node.environment
56
+ # If the requested environment doesn't match the server specified environment,
57
+ # as determined by the node terminus, and the request wants us to check for an
58
+ # environment mismatch, then return an empty catalog with the server-specified
59
+ # enviroment.
60
+ if request.remote? && request.options[:check_environment] && node.environment != request.environment
61
+ return Puppet::Resource::Catalog.new(node.name, node.environment)
62
+ end
63
+
56
64
  node.environment.with_text_domain do
57
- compile(node, request.options)
65
+ envs = Puppet.lookup(:environments)
66
+ envs.guard(node.environment.name)
67
+ begin
68
+ compile(node, request.options)
69
+ ensure
70
+ envs.unguard(node.environment.name)
71
+ end
58
72
  end
59
73
  else
60
74
  compile(node, request.options)
@@ -78,6 +92,10 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
78
92
  Puppet.run_mode.server?
79
93
  end
80
94
 
95
+ def require_environment?
96
+ false
97
+ end
98
+
81
99
  private
82
100
 
83
101
  # @param facts [String] facts in a wire format for decoding
@@ -154,7 +172,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
154
172
  location = Puppet::Module::FILETYPES['files']
155
173
 
156
174
  !!(source_as_uri.path =~ /^\/modules\// &&
157
- metadata.full_path =~ /#{environment_path}[^\/]+\/[^\/]+\/#{location}\/.+/)
175
+ metadata.full_path =~ /#{environment_path}\/[^\/]+\/[^\/]+\/#{location}\/.+/)
158
176
  end
159
177
 
160
178
  # Helper method to log file resources that could not be inlined because they
@@ -173,7 +191,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
173
191
  # Inline file metadata for static catalogs
174
192
  # Initially restricted to files sourced from codedir via puppet:/// uri.
175
193
  def inline_metadata(catalog, checksum_type)
176
- environment_path = Pathname.new File.join(Puppet[:environmentpath], catalog.environment, "")
194
+ environment_path = Pathname.new File.join(Puppet[:environmentpath], catalog.environment)
177
195
  environment_path = Puppet::Environments::Directories.real_path(environment_path)
178
196
  list_of_resources = catalog.resources.find_all { |res| res.type == "File" }
179
197
 
@@ -18,6 +18,7 @@ class Puppet::Resource::Catalog::Rest < Puppet::Indirector::REST
18
18
  facts: request.options[:facts_for_catalog],
19
19
  environment: request.environment.to_s,
20
20
  configured_environment: request.options[:configured_environment],
21
+ check_environment: request.options[:check_environment],
21
22
  transaction_uuid: request.options[:transaction_uuid],
22
23
  job_uuid: request.options[:job_id],
23
24
  static_catalog: request.options[:static_catalog],
@@ -143,6 +143,10 @@ class Puppet::Indirector::Terminus
143
143
  self.class.name
144
144
  end
145
145
 
146
+ def require_environment?
147
+ true
148
+ end
149
+
146
150
  def allow_remote_requests?
147
151
  true
148
152
  end
@@ -50,7 +50,6 @@ class Puppet::Module
50
50
  RESERVED_DATA_TYPES = %w{any array boolean catalogentry class collection
51
51
  callable data default enum float hash integer numeric optional pattern
52
52
  resource runtime scalar string struct tuple type undef variant}
53
- MOUNTS = %w[lib files plans]
54
53
 
55
54
  def self.is_plan_name?(name)
56
55
  return true if name =~ /^[a-z][a-z0-9_]*$/
@@ -45,7 +45,7 @@ class Puppet::Module
45
45
  end
46
46
 
47
47
  FORBIDDEN_EXTENSIONS = %w{.conf .md}
48
- MOUNTS = %w[lib files tasks]
48
+ MOUNTS = %w[files lib scripts tasks]
49
49
 
50
50
  def self.is_task_name?(name)
51
51
  return true if name =~ /^[a-z][a-z0-9_]*$/
@@ -138,7 +138,7 @@ module Puppet::ModuleTool
138
138
  rescue SemanticPuppet::Dependency::UnsatisfiableGraph => e
139
139
  unsatisfied = nil
140
140
 
141
- if e.respond_to?(:unsatisfied)
141
+ if e.respond_to?(:unsatisfied) && e.unsatisfied
142
142
  constraints = {}
143
143
  # If the module we're installing satisfies all its
144
144
  # dependencies, but would break an already installed
@@ -164,8 +164,12 @@ module Puppet::ModuleTool
164
164
  # If the module fails to satisfy one of its
165
165
  # dependencies, show the unsatisfiable module
166
166
  else
167
- unsatisfied_range = graph.dependencies[name].max.constraints[e.unsatisfied].first[1]
168
- constraints[e.unsatisfied] = unsatisfied_range
167
+ dep_constraints = graph.dependencies[name].max.constraints
168
+
169
+ if dep_constraints.key?(e.unsatisfied)
170
+ unsatisfied_range = dep_constraints[e.unsatisfied].first[1]
171
+ constraints[e.unsatisfied] = unsatisfied_range
172
+ end
169
173
  end
170
174
 
171
175
  installed_module = @environment.module_by_forge_name(e.unsatisfied.tr('-', '/'))
@@ -175,7 +179,7 @@ module Puppet::ModuleTool
175
179
  :name => e.unsatisfied,
176
180
  :constraints => constraints,
177
181
  :current_version => current_version
178
- }
182
+ } if constraints.any?
179
183
  end
180
184
 
181
185
  raise NoVersionsSatisfyError, results.merge(
@@ -98,7 +98,7 @@ class Puppet::Network::HTTP::API::IndirectedRoutes
98
98
  params[:environment] = configured_environment
99
99
  end
100
100
 
101
- if configured_environment.nil?
101
+ if configured_environment.nil? && indirection.terminus.require_environment?
102
102
  raise Puppet::Network::HTTP::Error::HTTPNotFoundError.new(
103
103
  _("Could not find environment '%{environment}'") % { environment: environment })
104
104
  end
@@ -312,7 +312,9 @@ class Puppet::Node::Environment
312
312
  {}
313
313
  end
314
314
  modulepath.each do |path|
315
- Dir.entries(path).each do |name|
315
+ Puppet::FileSystem.children(path).map do |p|
316
+ Puppet::FileSystem.basename_string(p)
317
+ end.each do |name|
316
318
  next unless Puppet::Module.is_module_directory?(name, path)
317
319
  warn_about_mistaken_path(path, name)
318
320
  if not seen_modules[name]
@@ -357,9 +359,6 @@ class Puppet::Node::Environment
357
359
 
358
360
  # Modules broken out by directory in the modulepath
359
361
  #
360
- # @note This method _changes_ the current working directory while enumerating
361
- # the modules. This seems rather dangerous.
362
- #
363
362
  # @api public
364
363
  #
365
364
  # @return [Hash<String, Array<Puppet::Module>>] A hash whose keys are file
@@ -368,13 +367,13 @@ class Puppet::Node::Environment
368
367
  modules_by_path = {}
369
368
  modulepath.each do |path|
370
369
  if Puppet::FileSystem.exist?(path)
371
- Dir.chdir(path) do
372
- module_names = Dir.entries(path).select do |name|
373
- Puppet::Module.is_module_directory?(name, path)
374
- end
375
- modules_by_path[path] = module_names.sort.map do |name|
376
- Puppet::Module.new(name, File.join(path, name), self)
377
- end
370
+ module_names = Puppet::FileSystem.children(path).map do |p|
371
+ Puppet::FileSystem.basename_string(p)
372
+ end.select do |name|
373
+ Puppet::Module.is_module_directory?(name, path)
374
+ end
375
+ modules_by_path[path] = module_names.sort.map do |name|
376
+ Puppet::Module.new(name, File.join(path, name), self)
378
377
  end
379
378
  else
380
379
  modules_by_path[path] = []