puppet 7.5.0 → 7.6.1

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +7 -7
  3. data/lib/puppet/defaults.rb +1 -5
  4. data/lib/puppet/functions.rb +1 -1
  5. data/lib/puppet/functions/partition.rb +8 -0
  6. data/lib/puppet/loaders.rb +0 -4
  7. data/lib/puppet/module.rb +1 -0
  8. data/lib/puppet/node/environment.rb +12 -5
  9. data/lib/puppet/pops/loader/base_loader.rb +42 -32
  10. data/lib/puppet/pops/loader/dependency_loader.rb +2 -2
  11. data/lib/puppet/pops/loader/loader.rb +15 -5
  12. data/lib/puppet/pops/loader/module_loaders.rb +8 -8
  13. data/lib/puppet/pops/loader/predefined_loader.rb +4 -0
  14. data/lib/puppet/pops/loader/runtime3_type_loader.rb +1 -1
  15. data/lib/puppet/pops/loader/static_loader.rb +4 -0
  16. data/lib/puppet/pops/loaders.rb +4 -4
  17. data/lib/puppet/pops/types/p_type_set_type.rb +1 -1
  18. data/lib/puppet/provider/package/dnfmodule.rb +1 -1
  19. data/lib/puppet/provider/package/puppet_gem.rb +12 -1
  20. data/lib/puppet/provider/service/systemd.rb +1 -1
  21. data/lib/puppet/provider/user/useradd.rb +1 -1
  22. data/lib/puppet/settings.rb +3 -2
  23. data/lib/puppet/version.rb +1 -1
  24. data/man/man5/puppet.conf.5 +2 -2
  25. data/man/man8/puppet-agent.8 +1 -1
  26. data/man/man8/puppet-apply.8 +1 -1
  27. data/man/man8/puppet-catalog.8 +1 -1
  28. data/man/man8/puppet-config.8 +1 -1
  29. data/man/man8/puppet-describe.8 +1 -1
  30. data/man/man8/puppet-device.8 +1 -1
  31. data/man/man8/puppet-doc.8 +1 -1
  32. data/man/man8/puppet-epp.8 +1 -1
  33. data/man/man8/puppet-facts.8 +1 -1
  34. data/man/man8/puppet-filebucket.8 +1 -1
  35. data/man/man8/puppet-generate.8 +1 -1
  36. data/man/man8/puppet-help.8 +1 -1
  37. data/man/man8/puppet-lookup.8 +1 -1
  38. data/man/man8/puppet-module.8 +1 -1
  39. data/man/man8/puppet-node.8 +1 -1
  40. data/man/man8/puppet-parser.8 +1 -1
  41. data/man/man8/puppet-plugin.8 +1 -1
  42. data/man/man8/puppet-report.8 +1 -1
  43. data/man/man8/puppet-resource.8 +1 -1
  44. data/man/man8/puppet-script.8 +1 -1
  45. data/man/man8/puppet-ssl.8 +1 -1
  46. data/man/man8/puppet.8 +2 -2
  47. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services_vendor_preset +9 -0
  48. data/spec/integration/http/client_spec.rb +1 -1
  49. data/spec/spec_helper.rb +11 -1
  50. data/spec/unit/module_spec.rb +1 -1
  51. data/spec/unit/pops/loaders/dependency_loader_spec.rb +1 -1
  52. data/spec/unit/pops/types/type_parser_spec.rb +2 -1
  53. data/spec/unit/provider/package/dnfmodule_spec.rb +10 -1
  54. data/spec/unit/provider/package/puppet_gem_spec.rb +28 -0
  55. data/spec/unit/provider/service/systemd_spec.rb +11 -0
  56. data/spec/unit/provider/user/useradd_spec.rb +18 -3
  57. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0c46be8ea84f210c98907f78f8fa7e67ddfe3500e77a8a1ab503f28f1887285
4
- data.tar.gz: e237a260fc5fb15474bd6713dad901fc7af6199d3da584aadb3c15cbff45886b
3
+ metadata.gz: bfacc8975faf19f44aa68a49b50e63896e7fc27106e946415c13b0cf600df328
4
+ data.tar.gz: 360336c8c5139037ca2afe94c986fcc1b37e902561cecf93e59b08add064d062
5
5
  SHA512:
6
- metadata.gz: 8cea314360893199a90e60d9da0a393f7caae00ec554bfa643d4b66a254d1a71a520eb5f0fd4b28adec1869c1ac693362613aea38c747c3c7b9f75f8af720bea
7
- data.tar.gz: 9df0489d6c2160814c17c28af8b151aa81175fb8919e4d80552733ad7657e22147da2743ac6780f786481d923f7f2e6044b88fc80ec9c570105b63f5ac1c1d85
6
+ metadata.gz: 7273c42d5d758f8eb4acf807f563771ae4a05cf44d4b8c14debe8e83a1be425cbd3cba4c8bf4daa9c22a5677f3e388b3b75badaef8a21819356c4deaef0933c5
7
+ data.tar.gz: 6eb1a41e1910ab15f297a6fee50b3de7c572394aab25baa8820adc78cc150fb25615d473caa5f11bd1c78cdbee237fc5358c1e20e4f5049ebf1d24c87fbe28f1
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- puppet (7.5.0)
15
+ puppet (7.6.1)
16
16
  CFPropertyList (~> 2.2)
17
17
  concurrent-ruby (~> 1.0)
18
18
  deep_merge (~> 1.0)
@@ -40,7 +40,7 @@ GEM
40
40
  deep_merge (1.2.1)
41
41
  diff-lcs (1.4.4)
42
42
  docopt (0.6.1)
43
- facter (4.0.51)
43
+ facter (4.1.1)
44
44
  hocon (~> 1.3)
45
45
  thor (>= 1.0.1, < 2.0)
46
46
  fast_gettext (1.1.2)
@@ -53,7 +53,7 @@ GEM
53
53
  gettext (>= 3.0.2, < 3.3.0)
54
54
  locale
55
55
  hashdiff (1.0.1)
56
- hiera (3.6.0)
56
+ hiera (3.7.0)
57
57
  hiera-eyaml (3.2.1)
58
58
  highline
59
59
  optimist
@@ -74,13 +74,13 @@ GEM
74
74
  parser (2.7.2.0)
75
75
  ast (~> 2.4.1)
76
76
  powerpack (0.1.3)
77
- pry (0.14.0)
77
+ pry (0.14.1)
78
78
  coderay (~> 1.1)
79
79
  method_source (~> 1.0)
80
80
  public_suffix (4.0.6)
81
81
  puppet-resource_api (1.8.13)
82
82
  hocon (>= 1.0)
83
- puppetserver-ca (2.0.1)
83
+ puppetserver-ca (2.1.0)
84
84
  facter (>= 2.0.1, < 5)
85
85
  racc (1.4.9)
86
86
  rainbow (2.2.2)
@@ -91,7 +91,7 @@ GEM
91
91
  release-metrics (1.1.0)
92
92
  csv
93
93
  docopt
94
- rexml (3.2.4)
94
+ rexml (3.2.5)
95
95
  ronn (0.7.3)
96
96
  hpricot (>= 0.8.2)
97
97
  mustache (>= 0.7.0)
@@ -129,7 +129,7 @@ GEM
129
129
  thor (1.1.0)
130
130
  unicode-display_width (1.7.0)
131
131
  vcr (5.1.0)
132
- webmock (3.12.1)
132
+ webmock (3.12.2)
133
133
  addressable (>= 2.3.6)
134
134
  crack (>= 0.3.2)
135
135
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -1672,7 +1672,7 @@ EOT
1672
1672
  },
1673
1673
  :agent_disabled_lockfile => {
1674
1674
  :default => "$statedir/agent_disabled.lock",
1675
- :type => :file,
1675
+ :type => :string,
1676
1676
  :desc => "A lock file to indicate that puppet agent runs have been administratively
1677
1677
  disabled. File contains a JSON object with state information.",
1678
1678
  },
@@ -2157,10 +2157,6 @@ EOT
2157
2157
  :rich_data => {
2158
2158
  :default => true,
2159
2159
  :type => :boolean,
2160
- :hook => proc do |value|
2161
- envs = Puppet.lookup(:environments) { nil }
2162
- envs.clear_all unless envs.nil?
2163
- end,
2164
2160
  :desc => <<-'EOT'
2165
2161
  Enables having extended data in the catalog by storing them as a hash with the special key
2166
2162
  `__ptype`. When enabled, resource containing values of the data types `Binary`, `Regexp`,
@@ -606,7 +606,7 @@ module Puppet::Functions
606
606
  attr_reader :local_types, :parser, :loader
607
607
 
608
608
  def initialize(loader, name)
609
- @loader = Puppet::Pops::Loader::PredefinedLoader.new(loader, :"local_function_#{name}")
609
+ @loader = Puppet::Pops::Loader::PredefinedLoader.new(loader, :"local_function_#{name}", loader.environment)
610
610
  @local_types = []
611
611
  # get the shared parser used by puppet's compiler
612
612
  @parser = Puppet::Pops::Parser::EvaluatingParser.singleton()
@@ -5,13 +5,21 @@
5
5
  Puppet::Functions.create_function(:partition) do
6
6
  # @param collection A collection of things to partition.
7
7
  # @example Partition array of empty strings, results in e.g. [[''], [b, c]]
8
+ # ```puppet
8
9
  # ['', b, c].partition |$s| { $s.empty }
10
+ # ```
9
11
  # @example Partition array of strings using index, results in e.g. [['', 'ab'], ['b']]
12
+ # ```puppet
10
13
  # ['', b, ab].partition |$i, $s| { $i == 2 or $s.empty }
14
+ # ```
11
15
  # @example Partition hash of strings by key-value pair, results in e.g. [[['b', []]], [['a', [1, 2]]]]
16
+ # ```puppet
12
17
  # { a => [1, 2], b => [] }.partition |$kv| { $kv[1].empty }
18
+ # ```
13
19
  # @example Partition hash of strings by key and value, results in e.g. [[['b', []]], [['a', [1, 2]]]]
20
+ # ```puppet
14
21
  # { a => [1, 2], b => [] }.partition |$k, $v| { $v.empty }
22
+ # ```
15
23
  dispatch :partition_1 do
16
24
  required_param 'Collection', :collection
17
25
  block_param 'Callable[1,1]', :block
@@ -24,10 +24,6 @@ module Puppet
24
24
  require 'puppet/pops/loader/predefined_loader'
25
25
  require 'puppet/pops/loader/generic_plan_instantiator'
26
26
  require 'puppet/pops/loader/puppet_plan_instantiator'
27
-
28
- # The implementation of synchronized applies it to all subclasses so we
29
- # want to add it to be base class after any subclasses are created
30
- Loader.include Puppet::Concurrent::Synchronized
31
27
  end
32
28
  end
33
29
 
data/lib/puppet/module.rb CHANGED
@@ -25,6 +25,7 @@ class Puppet::Module
25
25
  "plugins" => "lib",
26
26
  "pluginfacts" => "facts.d",
27
27
  "locales" => "locales",
28
+ "scripts" => "scripts",
28
29
  }
29
30
 
30
31
  # Find and return the +module+ that +path+ belongs to. If +path+ is
@@ -214,15 +214,22 @@ class Puppet::Node::Environment
214
214
  errors
215
215
  end
216
216
 
217
+ def rich_data_from_env_conf
218
+ unless @checked_conf_for_rich_data
219
+ environment_conf = Puppet.lookup(:environments).get_conf(name)
220
+ @rich_data_from_conf = environment_conf&.rich_data
221
+ @checked_conf_for_rich_data = true
222
+ end
223
+ @rich_data_from_conf
224
+ end
225
+
217
226
  # Checks if this environment permits use of rich data types in the catalog
227
+ # Checks the environment conf for an override on first query, then going forward
228
+ # either uses that, or if unset, uses the current value of the `rich_data` setting.
218
229
  # @return [Boolean] `true` if rich data is permitted.
219
230
  # @api private
220
231
  def rich_data?
221
- if @rich_data.nil?
222
- environment_conf = Puppet.lookup(:environments).get_conf(name)
223
- @rich_data = (environment_conf.nil? ? Puppet[:rich_data] : environment_conf.rich_data)
224
- end
225
- @rich_data
232
+ @rich_data = rich_data_from_env_conf.nil? ? Puppet[:rich_data] : rich_data_from_env_conf
226
233
  end
227
234
 
228
235
  # Return an environment-specific Puppet setting.
@@ -13,8 +13,8 @@ class BaseLoader < Loader
13
13
  # The parent loader
14
14
  attr_reader :parent
15
15
 
16
- def initialize(parent_loader, loader_name)
17
- super(loader_name)
16
+ def initialize(parent_loader, loader_name, environment)
17
+ super(loader_name, environment)
18
18
  @parent = parent_loader # the higher priority loader to consult
19
19
  @named_values = {} # hash name => NamedEntry
20
20
  @last_result = nil # the value of the last name (optimization)
@@ -38,22 +38,26 @@ class BaseLoader < Loader
38
38
  # These modules are typically parented by the same
39
39
  # loader as the one initiating the search. It is inefficient to again try to search the same loader for
40
40
  # the same name.
41
- if @last_result.nil? || typed_name != @last_result.typed_name
42
- @last_result = internal_load(typed_name)
43
- else
44
- @last_result
41
+ synchronize do
42
+ if @last_result.nil? || typed_name != @last_result.typed_name
43
+ @last_result = internal_load(typed_name)
44
+ else
45
+ @last_result
46
+ end
45
47
  end
46
48
  end
47
49
 
48
50
  # @api public
49
51
  #
50
52
  def loaded_entry(typed_name, check_dependencies = false)
51
- if @named_values.has_key?(typed_name)
52
- @named_values[typed_name]
53
- elsif parent
54
- parent.loaded_entry(typed_name, check_dependencies)
55
- else
56
- nil
53
+ synchronize do
54
+ if @named_values.has_key?(typed_name)
55
+ @named_values[typed_name]
56
+ elsif parent
57
+ parent.loaded_entry(typed_name, check_dependencies)
58
+ else
59
+ nil
60
+ end
57
61
  end
58
62
  end
59
63
 
@@ -68,23 +72,25 @@ class BaseLoader < Loader
68
72
  # @api private
69
73
  #
70
74
  def set_entry(typed_name, value, origin = nil)
71
- # It is never ok to redefine in the very same loader unless redefining a 'not found'
72
- entry = @named_values[typed_name]
73
- if entry
74
- fail_redefine(entry) unless entry.value.nil?
75
- end
76
-
77
- # Check if new entry shadows existing entry and fail
78
- # (unless special loader allows shadowing)
79
- if typed_name.type == :type && !allow_shadowing?
80
- entry = loaded_entry(typed_name)
75
+ synchronize do
76
+ # It is never ok to redefine in the very same loader unless redefining a 'not found'
77
+ entry = @named_values[typed_name]
81
78
  if entry
82
- fail_redefine(entry) unless entry.value.nil? #|| entry.value == value
79
+ fail_redefine(entry) unless entry.value.nil?
80
+ end
81
+
82
+ # Check if new entry shadows existing entry and fail
83
+ # (unless special loader allows shadowing)
84
+ if typed_name.type == :type && !allow_shadowing?
85
+ entry = loaded_entry(typed_name)
86
+ if entry
87
+ fail_redefine(entry) unless entry.value.nil? #|| entry.value == value
88
+ end
83
89
  end
84
- end
85
90
 
86
- @last_result = Loader::NamedEntry.new(typed_name, value, origin)
87
- @named_values[typed_name] = @last_result
91
+ @last_result = Loader::NamedEntry.new(typed_name, value, origin)
92
+ @named_values[typed_name] = @last_result
93
+ end
88
94
  end
89
95
 
90
96
  # @api private
@@ -96,8 +102,10 @@ class BaseLoader < Loader
96
102
  # @api private
97
103
  #
98
104
  def remove_entry(typed_name)
99
- unless @named_values.delete(typed_name).nil?
100
- @last_result = nil unless @last_result.nil? || typed_name != @last_result.typed_name
105
+ synchronize do
106
+ unless @named_values.delete(typed_name).nil?
107
+ @last_result = nil unless @last_result.nil? || typed_name != @last_result.typed_name
108
+ end
101
109
  end
102
110
  end
103
111
 
@@ -106,10 +114,12 @@ class BaseLoader < Loader
106
114
  # @api private
107
115
  #
108
116
  def promote_entry(named_entry)
109
- typed_name = named_entry.typed_name
110
- entry = @named_values[typed_name]
111
- if entry then fail_redefine(entry); end
112
- @named_values[typed_name] = named_entry
117
+ synchronize do
118
+ typed_name = named_entry.typed_name
119
+ entry = @named_values[typed_name]
120
+ if entry then fail_redefine(entry); end
121
+ @named_values[typed_name] = named_entry
122
+ end
113
123
  end
114
124
 
115
125
  protected
@@ -18,8 +18,8 @@ class Puppet::Pops::Loader::DependencyLoader < Puppet::Pops::Loader::BaseLoader
18
18
  # @param name [String] the name of the dependency-loader (used for debugging and tracing only)
19
19
  # @param dependency_loaders [Array<Puppet::Pops::Loader>] array of loaders for modules this module depends on
20
20
  #
21
- def initialize(parent_loader, name, dependency_loaders)
22
- super parent_loader, name
21
+ def initialize(parent_loader, name, dependency_loaders, environment)
22
+ super(parent_loader, name, environment)
23
23
  @dependency_loaders = dependency_loaders
24
24
  end
25
25
 
@@ -26,14 +26,15 @@ ENVIRONMENT = 'environment'.freeze
26
26
  ENVIRONMENT_PRIVATE = 'environment private'.freeze
27
27
 
28
28
  class Loader
29
- attr_reader :loader_name
29
+ attr_reader :environment, :loader_name
30
30
 
31
31
  # Describes the kinds of things that loaders can load
32
32
  LOADABLE_KINDS = [:func_4x, :func_4xpp, :func_3x, :datatype, :type_pp, :resource_type_pp, :plan, :task].freeze
33
33
 
34
34
  # @param [String] name the name of the loader. Must be unique among all loaders maintained by a {Loader} instance
35
- def initialize(loader_name)
35
+ def initialize(loader_name, environment)
36
36
  @loader_name = loader_name.freeze
37
+ @environment = environment
37
38
  end
38
39
 
39
40
  # Search all places where this loader would find values of a given type and return a list the
@@ -69,9 +70,11 @@ class Loader
69
70
  # @api public
70
71
  #
71
72
  def load(type, name)
72
- result = load_typed(TypedName.new(type, name.to_s))
73
- if result
74
- result.value
73
+ synchronize do
74
+ result = load_typed(TypedName.new(type, name.to_s))
75
+ if result
76
+ result.value
77
+ end
75
78
  end
76
79
  end
77
80
 
@@ -143,6 +146,13 @@ class Loader
143
146
  self
144
147
  end
145
148
 
149
+ # Lock around a block
150
+ # This exists so some subclasses that are set up statically and don't actually
151
+ # load can override it
152
+ def synchronize(&block)
153
+ @environment.lock.synchronize(&block)
154
+ end
155
+
146
156
  # Binds a value to a name. The name should not start with '::', but may contain multiple segments.
147
157
  #
148
158
  # @param type [:Symbol] the type of the entity being set
@@ -45,17 +45,17 @@ module ModuleLoaders
45
45
  #
46
46
  puppet_lib = File.realpath(File.join(File.dirname(__FILE__), '../../..'))
47
47
  LibRootedFileBased.new(parent_loader,
48
- loaders,
49
- nil,
50
- puppet_lib, # may or may not have a 'lib' above 'puppet'
51
- 'puppet_system',
52
- [:func_4x, :func_3x, :datatype] # only load ruby functions and types from "puppet"
53
- )
48
+ loaders,
49
+ nil,
50
+ puppet_lib, # may or may not have a 'lib' above 'puppet'
51
+ 'puppet_system',
52
+ [:func_4x, :func_3x, :datatype] # only load ruby functions and types from "puppet"
53
+ )
54
54
  end
55
55
 
56
56
  def self.environment_loader_from(parent_loader, loaders, env_path)
57
57
  if env_path.nil? || env_path.empty?
58
- EmptyLoader.new(parent_loader, ENVIRONMENT)
58
+ EmptyLoader.new(parent_loader, ENVIRONMENT, loaders.environment)
59
59
  else
60
60
  FileBased.new(parent_loader,
61
61
  loaders,
@@ -125,7 +125,7 @@ module ModuleLoaders
125
125
  # @param loader_name [String] a name that is used for human identification (useful when module_name is nil)
126
126
  #
127
127
  def initialize(parent_loader, loaders, module_name, path, loader_name, loadables)
128
- super parent_loader, loader_name
128
+ super(parent_loader, loader_name, loaders.environment)
129
129
 
130
130
  raise ArgumentError, 'path based loader cannot be instantiated without a path' if path.nil? || path.empty?
131
131
 
@@ -19,6 +19,10 @@ class PredefinedLoader < BaseLoader
19
19
  def allow_shadowing?
20
20
  true
21
21
  end
22
+
23
+ def synchronize(&block)
24
+ yield
25
+ end
22
26
  end
23
27
 
24
28
  end
@@ -10,7 +10,7 @@ class Runtime3TypeLoader < BaseLoader
10
10
  attr_reader :resource_3x_loader
11
11
 
12
12
  def initialize(parent_loader, loaders, environment, resource_3x_loader)
13
- super(parent_loader, environment.name)
13
+ super(parent_loader, environment.name, environment)
14
14
  @environment = environment
15
15
  @resource_3x_loader = resource_3x_loader
16
16
  end
@@ -122,6 +122,10 @@ class StaticLoader < Loader
122
122
  def create_resource_type_reference(name)
123
123
  add_type(name, Types::TypeFactory.resource(name))
124
124
  end
125
+
126
+ def synchronize(&block)
127
+ yield
128
+ end
125
129
  end
126
130
  end
127
131
  end
@@ -398,7 +398,7 @@ class Loaders
398
398
 
399
399
  if env_path.nil?
400
400
  # Not a real directory environment, cannot work as a module TODO: Drop when legacy env are dropped?
401
- loader = add_loader_by_name(Loader::SimpleEnvironmentLoader.new(@runtime3_type_loader, Loader::ENVIRONMENT))
401
+ loader = add_loader_by_name(Loader::SimpleEnvironmentLoader.new(@runtime3_type_loader, Loader::ENVIRONMENT, environment))
402
402
  else
403
403
  # View the environment as a module to allow loading from it - this module is always called 'environment'
404
404
  loader = Loader::ModuleLoaders.environment_loader_from(@runtime3_type_loader, self, env_path)
@@ -413,7 +413,7 @@ class Loaders
413
413
  # Code in the environment gets to see all modules (since there is no metadata for the environment)
414
414
  # but since this is not given to the module loaders, they can not load global code (since they can not
415
415
  # have prior knowledge about this
416
- loader = add_loader_by_name(Loader::DependencyLoader.new(loader, Loader::ENVIRONMENT_PRIVATE, @module_resolver.all_module_loaders()))
416
+ loader = add_loader_by_name(Loader::DependencyLoader.new(loader, Loader::ENVIRONMENT_PRIVATE, @module_resolver.all_module_loaders(), environment))
417
417
 
418
418
  # The module loader gets the private loader via a lazy operation to look up the module's private loader.
419
419
  # This does not work for an environment since it is not resolved the same way.
@@ -529,13 +529,13 @@ class Loaders
529
529
  private
530
530
 
531
531
  def create_loader_with_all_modules_visible(from_module_data)
532
- @loaders.add_loader_by_name(Loader::DependencyLoader.new(from_module_data.public_loader, "#{from_module_data.name} private", all_module_loaders()))
532
+ @loaders.add_loader_by_name(Loader::DependencyLoader.new(from_module_data.public_loader, "#{from_module_data.name} private", all_module_loaders(), @loaders.environment))
533
533
  end
534
534
 
535
535
  def create_loader_with_dependencies_first(from_module_data)
536
536
  dependency_loaders = from_module_data.dependency_names.collect { |name| @index[name].public_loader }
537
537
  visible_loaders = dependency_loaders + (all_module_loaders() - dependency_loaders)
538
- @loaders.add_loader_by_name(Loader::DependencyLoader.new(from_module_data.public_loader, "#{from_module_data.name} private", visible_loaders))
538
+ @loaders.add_loader_by_name(Loader::DependencyLoader.new(from_module_data.public_loader, "#{from_module_data.name} private", visible_loaders, @loaders.environment))
539
539
  end
540
540
  end
541
541
  end
@@ -15,7 +15,7 @@ class PTypeSetType < PMetaType
15
15
  # @api private
16
16
  class TypeSetLoader < Loader::BaseLoader
17
17
  def initialize(type_set, parent)
18
- super(parent, "(TypeSetFirstLoader '#{type_set.name}')")
18
+ super(parent, "(TypeSetFirstLoader '#{type_set.name}')", parent.environment)
19
19
  @type_set = type_set
20
20
  end
21
21
 
@@ -93,7 +93,7 @@ Puppet::Type.type(:package).provide :dnfmodule, :parent => :dnf do
93
93
  # module has no default profile and no profile was requested, so just enable the stream
94
94
  # DNF versions prior to 4.2.8 do not need this workaround
95
95
  # see https://bugzilla.redhat.com/show_bug.cgi?id=1669527
96
- if @resource[:flavor] == nil && e.message =~ /^missing groups or modules: #{Regexp.quote(@resource[:name])}$/
96
+ if @resource[:flavor] == nil && e.message =~ /^(?:missing|broken) groups or modules: #{Regexp.quote(@resource[:name])}$/
97
97
  enable(args)
98
98
  else
99
99
  raise
@@ -4,8 +4,19 @@ Puppet::Type.type(:package).provide :puppet_gem, :parent => :gem do
4
4
 
5
5
  has_feature :versionable, :install_options, :uninstall_options
6
6
 
7
+ confine :true => Facter.value(:aio_agent_version)
8
+
9
+ def self.windows_gemcmd
10
+ puppet_dir = Puppet::Util.get_env('PUPPET_DIR')
11
+ if puppet_dir
12
+ File.join(Puppet::Util.get_env('PUPPET_DIR').to_s, 'bin', 'gem.bat')
13
+ else
14
+ File.join(Gem.default_bindir, 'gem.bat')
15
+ end
16
+ end
17
+
7
18
  if Puppet::Util::Platform.windows?
8
- commands :gemcmd => File.join(Puppet::Util.get_env('PUPPET_DIR').to_s, 'bin', 'gem.bat')
19
+ commands :gemcmd => windows_gemcmd
9
20
  else
10
21
  commands :gemcmd => "/opt/puppetlabs/puppet/bin/gem"
11
22
  end
@@ -30,7 +30,7 @@ Puppet::Type.type(:service).provide :systemd, :parent => :base do
30
30
  def self.instances
31
31
  i = []
32
32
  output = systemctl('list-unit-files', '--type', 'service', '--full', '--all', '--no-pager')
33
- output.scan(/^(\S+)\s+(disabled|enabled|masked|indirect|bad|static)\s*$/i).each do |m|
33
+ output.scan(/^(\S+)\s+(disabled|enabled|masked|indirect|bad|static)\s*([^-]\S+)?\s*$/i).each do |m|
34
34
  Puppet.debug("#{m[0]} marked as bad by `systemctl`. It is recommended to be further checked.") if m[1] == "bad"
35
35
  i << new(:name => m[0])
36
36
  end
@@ -135,7 +135,7 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
135
135
 
136
136
  Puppet::FileSystem.each_line(group_file) do |line|
137
137
  data = line.chomp.split(':')
138
- if data.last.split(',').include?(user)
138
+ if !data.empty? && data.last.split(',').include?(user)
139
139
  @groups_of[user] << data.first
140
140
  end
141
141
  end
@@ -4,6 +4,7 @@ require 'puppet/util/watched_file'
4
4
  require 'puppet/util/command_line/puppet_option_parser'
5
5
  require 'forwardable'
6
6
  require 'fileutils'
7
+ require 'concurrent'
7
8
 
8
9
  # The class for handling configuration files.
9
10
  class Puppet::Settings
@@ -146,8 +147,8 @@ class Puppet::Settings
146
147
  @configuration_file = nil
147
148
 
148
149
  # And keep a per-environment cache
149
- @cache = Hash.new { |hash, key| hash[key] = {} }
150
- @values = Hash.new { |hash, key| hash[key] = {} }
150
+ @cache = Concurrent::Hash.new { |hash, key| hash[key] = Concurrent::Hash.new }
151
+ @values = Concurrent::Hash.new { |hash, key| hash[key] = Concurrent::Hash.new }
151
152
 
152
153
  # The list of sections we've used.
153
154
  @used = []
@@ -6,7 +6,7 @@
6
6
  # Raketasks and such to set the version based on the output of `git describe`
7
7
 
8
8
  module Puppet
9
- PUPPETVERSION = '7.5.0'
9
+ PUPPETVERSION = '7.6.1'
10
10
 
11
11
  ##
12
12
  # version is a public API method intended to always provide a fast and
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPETCONF" "5" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPETCONF" "5" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  \fBThis page is autogenerated; any changes will get overwritten\fR
6
6
  .
7
7
  .SH "Configuration settings"
@@ -907,7 +907,7 @@ The time to wait for data to be read from an HTTP connection\. If nothing is rea
907
907
  The HTTP User\-Agent string to send when making network requests\.
908
908
  .
909
909
  .IP "\(bu" 4
910
- \fIDefault\fR: Puppet/7\.5\.0 Ruby/2\.5\.1\-p57 (x86_64\-linux)
910
+ \fIDefault\fR: Puppet/7\.6\.0 Ruby/2\.5\.1\-p57 (x86_64\-linux)
911
911
  .
912
912
  .IP "" 0
913
913
  .
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-AGENT" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-AGENT" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-agent\fR \- The puppet agent daemon
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-APPLY" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-APPLY" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-apply\fR \- Apply Puppet manifests locally
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-CATALOG" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-CATALOG" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-catalog\fR \- Compile, save, view, and convert catalogs\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-CONFIG" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-CONFIG" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-config\fR \- Interact with Puppet\'s settings\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-DESCRIBE" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-DESCRIBE" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-describe\fR \- Display help about resource types
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-DEVICE" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-DEVICE" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-device\fR \- Manage remote network devices
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-DOC" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-DOC" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-doc\fR \- Generate Puppet references
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-EPP" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-EPP" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-epp\fR \- Interact directly with the EPP template parser/renderer\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-FACTS" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-FACTS" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-facts\fR \- Retrieve and store facts\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-FILEBUCKET" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-FILEBUCKET" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-filebucket\fR \- Store and retrieve files in a filebucket
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-GENERATE" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-GENERATE" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-generate\fR \- Generates Puppet code from Ruby definitions\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-HELP" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-HELP" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-help\fR \- Display Puppet help\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-LOOKUP" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-LOOKUP" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-lookup\fR \- Interactive Hiera lookup
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-MODULE" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-MODULE" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-module\fR \- Creates, installs and searches for modules on the Puppet Forge\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-NODE" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-NODE" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-node\fR \- View and manage node definitions\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-PARSER" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-PARSER" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-parser\fR \- Interact directly with the parser\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-PLUGIN" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-PLUGIN" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-plugin\fR \- Interact with the Puppet plugin system\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-REPORT" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-REPORT" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-report\fR \- Create, display, and submit reports\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-RESOURCE" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-RESOURCE" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-resource\fR \- The resource abstraction layer shell
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-SCRIPT" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-SCRIPT" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-script\fR \- Run a puppet manifests as a script without compiling a catalog
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-SSL" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-SSL" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-ssl\fR \- Manage SSL keys and certificates for puppet SSL clients
data/man/man8/puppet.8 CHANGED
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET" "8" "March 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET" "8" "April 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\fR
@@ -25,4 +25,4 @@ Specialized:
25
25
  catalog Compile, save, view, and convert catalogs\. describe Display help about resource types device Manage remote network devices doc Generate Puppet references epp Interact directly with the EPP template parser/renderer\. facts Retrieve and store facts\. filebucket Store and retrieve files in a filebucket generate Generates Puppet code from Ruby definitions\. node View and manage node definitions\. parser Interact directly with the parser\. plugin Interact with the Puppet plugin system\. script Run a puppet manifests as a script without compiling a catalog ssl Manage SSL keys and certificates for puppet SSL clients
26
26
  .
27
27
  .P
28
- See \'puppet help \fIsubcommand\fR \fIaction\fR\' for help on a specific subcommand action\. See \'puppet help \fIsubcommand\fR\' for help on a specific subcommand\. Puppet v7\.5\.0
28
+ See \'puppet help \fIsubcommand\fR \fIaction\fR\' for help on a specific subcommand action\. See \'puppet help \fIsubcommand\fR\' for help on a specific subcommand\. Puppet v7\.6\.0
@@ -0,0 +1,9 @@
1
+ UNIT FILE STATE VENDOR PRESET
2
+ arp-ethers.service disabled disabled
3
+ auditd.service enabled enabled
4
+ dbus.service enabled disabled
5
+ udev.service enabled-runtime disabled
6
+ umountfs.service linked-runtime disabled
7
+ umountnfs.service masked disabled
8
+ umountroot.service masked-runtime disabled
9
+ urandom.service indirect enabled
@@ -153,7 +153,7 @@ describe Puppet::HTTP::Client, unless: Puppet::Util::Platform.jruby? do
153
153
  end
154
154
 
155
155
  context 'ciphersuites' do
156
- it "does not connect when using an SSLv3 ciphersuite" do
156
+ it "does not connect when using an SSLv3 ciphersuite", :if => Puppet::Util::Package.versioncmp(OpenSSL::OPENSSL_LIBRARY_VERSION.split[1], '1.1.1e') > 0 do
157
157
  Puppet[:ciphers] = "DES-CBC3-SHA"
158
158
 
159
159
  https_server.start_server do |port|
data/spec/spec_helper.rb CHANGED
@@ -162,10 +162,20 @@ RSpec.configure do |config|
162
162
  PUPPET_FACTER_2_GCE_URL = %r{^http://metadata/computeMetadata/v1(beta1)?}.freeze
163
163
  PUPPET_FACTER_3_GCE_URL = "http://metadata.google.internal/computeMetadata/v1/?recursive=true&alt=json".freeze
164
164
 
165
+ # Facter azure metadata endpoint
166
+ PUPPET_FACTER_AZ_URL = "http://169.254.169.254/metadata/instance?api-version=2020-09-01"
167
+
168
+ # Facter EC2 endpoint
169
+ PUPPET_FACTER_EC2_METADATA = 'http://169.254.169.254/latest/meta-data/'
170
+ PUPPET_FACTER_EC2_USERDATA = 'http://169.254.169.254/latest/user-data/'
171
+
165
172
  config.around :each do |example|
166
- # Ignore requests from Facter GCE fact in Travis
173
+ # Ignore requests from Facter to external services
167
174
  stub_request(:get, PUPPET_FACTER_2_GCE_URL)
168
175
  stub_request(:get, PUPPET_FACTER_3_GCE_URL)
176
+ stub_request(:get, PUPPET_FACTER_AZ_URL)
177
+ stub_request(:get, PUPPET_FACTER_EC2_METADATA)
178
+ stub_request(:get, PUPPET_FACTER_EC2_USERDATA)
169
179
 
170
180
  # Enable VCR if the example is tagged with `:vcr` metadata.
171
181
  if example.metadata[:vcr]
@@ -478,7 +478,7 @@ describe Puppet::Module do
478
478
  end
479
479
  end
480
480
 
481
- [:plugins, :pluginfacts, :templates, :files, :manifests].each do |filetype|
481
+ [:plugins, :pluginfacts, :templates, :files, :manifests, :scripts].each do |filetype|
482
482
  case filetype
483
483
  when :plugins
484
484
  dirname = "lib"
@@ -122,7 +122,7 @@ Puppet::Functions.create_function('testmodule::foo') {
122
122
 
123
123
  def loader_for(name, dir)
124
124
  module_loader = Puppet::Pops::Loader::ModuleLoaders.module_loader_from(static_loader, loaders, name, dir)
125
- Puppet::Pops::Loader::DependencyLoader.new(static_loader, 'test-dep', [module_loader])
125
+ Puppet::Pops::Loader::DependencyLoader.new(static_loader, 'test-dep', [module_loader], loaders.environment)
126
126
  end
127
127
 
128
128
  def typed_name(type, name)
@@ -210,7 +210,8 @@ describe TypeParser do
210
210
  end
211
211
 
212
212
  context 'with loader context' do
213
- let(:loader) { Puppet::Pops::Loader::BaseLoader.new(nil, "type_parser_unit_test_loader") }
213
+ let(:environment) { Puppet::Node::Environment.create(:testing, []) }
214
+ let(:loader) { Puppet::Pops::Loader::BaseLoader.new(nil, "type_parser_unit_test_loader", environment) }
214
215
 
215
216
  it 'interprets anything that is not found by the loader to be a type reference' do
216
217
  expect(loader).to receive(:load).with(:type, 'nonesuch').and_return(nil)
@@ -123,7 +123,7 @@ describe Puppet::Type.type(:package).provider(:dnfmodule) do
123
123
  provider.install
124
124
  end
125
125
 
126
- it "should just enable the module if it has no default profile" do
126
+ it "should just enable the module if it has no default profile(missing groups or modules)" do
127
127
  dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nmissing groups or modules: #{resource[:name]}")
128
128
  allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception)
129
129
  resource[:ensure] = :present
@@ -132,6 +132,15 @@ describe Puppet::Type.type(:package).provider(:dnfmodule) do
132
132
  provider.install
133
133
  end
134
134
 
135
+ it "should just enable the module if it has no default profile(broken groups or modules)" do
136
+ dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nbroken groups or modules: #{resource[:name]}")
137
+ allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception)
138
+ resource[:ensure] = :present
139
+ expect(provider).to receive(:execute).with(array_including('install')).ordered
140
+ expect(provider).to receive(:execute).with(array_including('enable')).ordered
141
+ provider.install
142
+ end
143
+
135
144
  it "should just enable the module if enable_only = true" do
136
145
  resource[:ensure] = :present
137
146
  resource[:enable_only] = true
@@ -31,6 +31,34 @@ describe Puppet::Type.type(:package).provider(:puppet_gem) do
31
31
  allow(Puppet::Util::Platform).to receive(:windows?).and_return(false)
32
32
  end
33
33
 
34
+
35
+ describe '.windows_gemcmd' do
36
+ context 'when PUPPET_DIR is not set' do
37
+ before do
38
+ allow(Puppet::Util).to receive(:get_env).and_call_original
39
+ allow(Puppet::Util).to receive(:get_env).with('PUPPET_DIR').and_return(nil)
40
+ allow(Gem).to receive(:default_bindir).and_return('default_gem_bin')
41
+ end
42
+
43
+ it 'uses Gem.default_bindir' do
44
+ expected_path = File.join('default_gem_bin', 'gem.bat')
45
+ expect(described_class.windows_gemcmd).to eql(expected_path)
46
+ end
47
+ end
48
+
49
+ context 'when PUPPET_DIR is set' do
50
+ before do
51
+ allow(Puppet::Util).to receive(:get_env).and_call_original
52
+ allow(Puppet::Util).to receive(:get_env).with('PUPPET_DIR').and_return('puppet_dir')
53
+ end
54
+
55
+ it 'uses Gem.default_bindir' do
56
+ expected_path = File.join('puppet_dir', 'bin', 'gem.bat')
57
+ expect(described_class.windows_gemcmd).to eql(expected_path)
58
+ end
59
+ end
60
+ end
61
+
34
62
  context "when installing" do
35
63
  before :each do
36
64
  allow(provider).to receive(:rubygem_version).and_return('1.9.9')
@@ -200,6 +200,17 @@ describe 'Puppet::Type::Service::Provider::Systemd',
200
200
  })
201
201
  end
202
202
 
203
+ it "correctly parses services when list-unit-files has an additional column" do
204
+ expect(provider_class).to receive(:systemctl).with('list-unit-files', '--type', 'service', '--full', '--all', '--no-pager').and_return(File.read(my_fixture('list_unit_files_services_vendor_preset')))
205
+ expect(provider_class.instances.map(&:name)).to match_array(%w{
206
+ arp-ethers.service
207
+ auditd.service
208
+ dbus.service
209
+ umountnfs.service
210
+ urandom.service
211
+ })
212
+ end
213
+
203
214
  it "should print a debug message when a service with the state `bad` is found" do
204
215
  expect(provider_class).to receive(:systemctl).with('list-unit-files', '--type', 'service', '--full', '--all', '--no-pager').and_return(File.read(my_fixture('list_unit_files_services')))
205
216
  expect(Puppet).to receive(:debug).with("apparmor.service marked as bad by `systemctl`. It is recommended to be further checked.")
@@ -375,21 +375,36 @@ describe Puppet::Type.type(:user).provider(:useradd) do
375
375
  before { described_class.has_feature :manages_local_users_and_groups }
376
376
 
377
377
  let(:content) do
378
- <<~EOF
378
+ StringIO.new(<<~EOF)
379
379
  group1:x:0:myuser
380
380
  group2:x:999:
381
381
  group3:x:998:myuser
382
382
  EOF
383
383
  end
384
384
 
385
+ let(:content_with_empty_line) do
386
+ StringIO.new(<<~EOF)
387
+ group1:x:0:myuser
388
+ group2:x:999:
389
+ group3:x:998:myuser
390
+
391
+ EOF
392
+ end
393
+
385
394
  it "should return the local groups string when forcelocal is true" do
386
395
  resource[:forcelocal] = true
387
- group1, group2, group3 = content.split
388
396
  allow(Puppet::FileSystem).to receive(:exist?).with('/etc/group').and_return(true)
389
- allow(Puppet::FileSystem).to receive(:each_line).with('/etc/group').and_yield(group1).and_yield(group2).and_yield(group3)
397
+ allow(File).to receive(:open).with(Pathname.new('/etc/group')).and_yield(content)
390
398
  expect(provider.groups).to eq(['group1', 'group3'])
391
399
  end
392
400
 
401
+ it "does not raise when parsing empty lines in /etc/group" do
402
+ resource[:forcelocal] = true
403
+ allow(Puppet::FileSystem).to receive(:exist?).with('/etc/group').and_return(true)
404
+ allow(File).to receive(:open).with(Pathname.new('/etc/group')).and_yield(content_with_empty_line)
405
+ expect { provider.groups }.not_to raise_error
406
+ end
407
+
393
408
  it "should fall back to nameservice groups when forcelocal is false" do
394
409
  resource[:forcelocal] = false
395
410
  allow(Puppet::Util::POSIX).to receive(:groups_of).with('myuser').and_return(['remote groups'])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.5.0
4
+ version: 7.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-15 00:00:00.000000000 Z
11
+ date: 2021-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: facter
@@ -1735,6 +1735,7 @@ files:
1735
1735
  - spec/fixtures/unit/provider/service/smf/svcs_instances.out
1736
1736
  - spec/fixtures/unit/provider/service/smf/svcs_multiple_fmris.out
1737
1737
  - spec/fixtures/unit/provider/service/systemd/list_unit_files_services
1738
+ - spec/fixtures/unit/provider/service/systemd/list_unit_files_services_vendor_preset
1738
1739
  - spec/fixtures/unit/provider/user/aix/aix_passwd_file.out
1739
1740
  - spec/fixtures/unit/reports/tagmail/tagmail_email.conf
1740
1741
  - spec/fixtures/unit/reports/tagmail/tagmail_failers.conf
@@ -2971,6 +2972,7 @@ test_files:
2971
2972
  - spec/fixtures/unit/provider/service/smf/svcs_instances.out
2972
2973
  - spec/fixtures/unit/provider/service/smf/svcs_multiple_fmris.out
2973
2974
  - spec/fixtures/unit/provider/service/systemd/list_unit_files_services
2975
+ - spec/fixtures/unit/provider/service/systemd/list_unit_files_services_vendor_preset
2974
2976
  - spec/fixtures/unit/provider/user/aix/aix_passwd_file.out
2975
2977
  - spec/fixtures/unit/reports/tagmail/tagmail_email.conf
2976
2978
  - spec/fixtures/unit/reports/tagmail/tagmail_failers.conf