bolt 0.7.0 → 0.8.0

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

Potentially problematic release.


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

Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bolt/cli.rb +65 -28
  3. data/lib/bolt/config.rb +18 -8
  4. data/lib/bolt/executor.rb +21 -6
  5. data/lib/bolt/node.rb +3 -0
  6. data/lib/bolt/node/result.rb +5 -0
  7. data/lib/bolt/node/ssh.rb +81 -25
  8. data/lib/bolt/node/winrm.rb +70 -31
  9. data/lib/bolt/notifier.rb +20 -0
  10. data/lib/bolt/outputter.rb +21 -0
  11. data/lib/bolt/outputter/human.rb +30 -0
  12. data/lib/bolt/outputter/json.rb +51 -0
  13. data/lib/bolt/result.rb +32 -5
  14. data/lib/bolt/version.rb +1 -1
  15. data/vendored/puppet/lib/puppet.rb +4 -5
  16. data/vendored/puppet/lib/puppet/agent.rb +22 -2
  17. data/vendored/puppet/lib/puppet/application/agent.rb +1 -1
  18. data/vendored/puppet/lib/puppet/application/apply.rb +1 -1
  19. data/vendored/puppet/lib/puppet/configurer/downloader_factory.rb +10 -0
  20. data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +4 -4
  21. data/vendored/puppet/lib/puppet/defaults.rb +21 -2
  22. data/vendored/puppet/lib/puppet/external/nagios/parser.rb +1 -1
  23. data/vendored/puppet/lib/puppet/file_serving/configuration.rb +3 -0
  24. data/vendored/puppet/lib/puppet/file_serving/configuration/parser.rb +2 -0
  25. data/vendored/puppet/lib/puppet/file_serving/mount/locales.rb +35 -0
  26. data/vendored/puppet/lib/puppet/forge.rb +9 -3
  27. data/vendored/puppet/lib/puppet/forge/repository.rb +1 -1
  28. data/vendored/puppet/lib/puppet/functions/file_upload.rb +20 -15
  29. data/vendored/puppet/lib/puppet/functions/new.rb +1 -4
  30. data/vendored/puppet/lib/puppet/functions/run_command.rb +15 -13
  31. data/vendored/puppet/lib/puppet/functions/run_script.rb +27 -14
  32. data/vendored/puppet/lib/puppet/functions/run_task.rb +21 -19
  33. data/vendored/puppet/lib/puppet/gettext/config.rb +86 -28
  34. data/vendored/puppet/lib/puppet/indirector/catalog/compiler.rb +25 -5
  35. data/vendored/puppet/lib/puppet/indirector/file_bucket_file/file.rb +1 -1
  36. data/vendored/puppet/lib/puppet/module.rb +13 -17
  37. data/vendored/puppet/lib/puppet/pops/evaluator/access_operator.rb +20 -21
  38. data/vendored/puppet/lib/puppet/pops/evaluator/compare_operator.rb +3 -3
  39. data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +9 -0
  40. data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +20 -1
  41. data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +2 -1
  42. data/vendored/puppet/lib/puppet/pops/loaders.rb +6 -41
  43. data/vendored/puppet/lib/puppet/pops/pcore.rb +9 -0
  44. data/vendored/puppet/lib/puppet/pops/serialization/from_data_converter.rb +64 -10
  45. data/vendored/puppet/lib/puppet/pops/serialization/json_path.rb +2 -1
  46. data/vendored/puppet/lib/puppet/pops/types/execution_result.rb +7 -4
  47. data/vendored/puppet/lib/puppet/pops/types/p_binary_type.rb +9 -2
  48. data/vendored/puppet/lib/puppet/pops/types/p_init_type.rb +1 -1
  49. data/vendored/puppet/lib/puppet/pops/types/p_meta_type.rb +4 -0
  50. data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +81 -4
  51. data/vendored/puppet/lib/puppet/pops/types/p_object_type_extension.rb +213 -0
  52. data/vendored/puppet/lib/puppet/pops/types/p_sem_ver_type.rb +10 -2
  53. data/vendored/puppet/lib/puppet/pops/types/puppet_object.rb +11 -1
  54. data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +2 -2
  55. data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +16 -6
  56. data/vendored/puppet/lib/puppet/pops/types/type_formatter.rb +22 -14
  57. data/vendored/puppet/lib/puppet/pops/types/type_parser.rb +17 -15
  58. data/vendored/puppet/lib/puppet/pops/types/types.rb +181 -72
  59. data/vendored/puppet/lib/puppet/provider.rb +18 -8
  60. data/vendored/puppet/lib/puppet/provider/package/yum.rb +22 -7
  61. data/vendored/puppet/lib/puppet/provider/service/base.rb +21 -8
  62. data/vendored/puppet/lib/puppet/provider/service/launchd.rb +2 -3
  63. data/vendored/puppet/lib/puppet/provider/user/aix.rb +1 -0
  64. data/vendored/puppet/lib/puppet/provider/user/user_role_add.rb +7 -1
  65. data/vendored/puppet/lib/puppet/provider/user/useradd.rb +3 -2
  66. data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +5 -1
  67. data/vendored/puppet/lib/puppet/type/exec.rb +5 -4
  68. data/vendored/puppet/lib/puppet/type/macauthorization.rb +1 -1
  69. data/vendored/puppet/lib/puppet/type/user.rb +19 -0
  70. data/vendored/puppet/lib/puppet/util/log/destinations.rb +10 -0
  71. data/vendored/puppet/lib/puppet/util/windows/file.rb +35 -4
  72. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +1 -1
  73. data/vendored/puppet/lib/puppet/version.rb +1 -1
  74. data/vendored/puppet/lib/puppet_pal.rb +15 -5
  75. metadata +8 -3
  76. data/vendored/puppet/lib/puppet/pops/types/p_error_type.rb +0 -158
@@ -290,16 +290,26 @@ class Puppet::Provider
290
290
  end
291
291
  end
292
292
 
293
+ # Compare a fact value against one or more supplied value
294
+ # @param [Symbol] fact a fact to query to match against one of the given values
295
+ # @param [Array, Regexp, String] values one or more values to compare to the
296
+ # value of the given fact
297
+ # @return [Boolean] whether or not the fact value matches one of the supplied
298
+ # values. Given one or more Regexp instances, fact is compared via the basic
299
+ # pattern-matching operator.
293
300
  def self.fact_match(fact, values)
294
- values = [values] unless values.is_a? Array
295
- values.map! { |v| v.to_s.downcase.intern }
296
-
297
- if fval = Facter.value(fact).to_s and fval != ""
298
- fval = fval.to_s.downcase.intern
299
-
300
- values.include?(fval)
301
+ fact_val = Facter.value(fact).to_s.downcase
302
+ if fact_val.empty?
303
+ return false
301
304
  else
302
- false
305
+ values = [values] unless values.is_a?(Array)
306
+ values.any? do |value|
307
+ if value.is_a?(Regexp)
308
+ fact_val =~ value
309
+ else
310
+ fact_val.intern == value.to_s.downcase.intern
311
+ end
312
+ end
303
313
  end
304
314
  end
305
315
 
@@ -175,17 +175,32 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
175
175
  operation = :install
176
176
  end
177
177
  should = nil
178
- when true, false, Symbol
178
+ when true, :present, :installed
179
+ # if we have been given a source and we were not asked for a specific
180
+ # version feed it to yum directly
181
+ if @resource[:source]
182
+ wanted = @resource[:source]
183
+ self.debug "Installing directly from #{wanted}"
184
+ end
185
+ should = nil
186
+ when false,:absent
179
187
  # pass
180
188
  should = nil
181
189
  else
182
- # Add the package version
183
- wanted += "-#{should}"
184
- if wanted.scan(ARCH_REGEX)
185
- self.debug "Detected Arch argument in package! - Moving arch to end of version string"
186
- wanted.gsub!(/(.+)(#{ARCH_REGEX})(.+)/,'\1\3\2')
190
+ if @resource[:source]
191
+ # An explicit source was supplied, which means we're ensuring a specific
192
+ # version, and also supplying the path to a package that supplies that
193
+ # version.
194
+ wanted = @resource[:source]
195
+ self.debug "Installing directly from #{wanted}"
196
+ else
197
+ # No explicit source was specified, so add the package version
198
+ wanted += "-#{should}"
199
+ if wanted.scan(ARCH_REGEX)
200
+ self.debug "Detected Arch argument in package! - Moving arch to end of version string"
201
+ wanted.gsub!(/(.+)(#{ARCH_REGEX})(.+)/,'\1\3\2')
202
+ end
187
203
  end
188
-
189
204
  current_package = self.query
190
205
  if current_package
191
206
  if rpm_compareEVR(rpm_parse_evr(should), rpm_parse_evr(current_package[:ensure])) < 0
@@ -32,15 +32,28 @@ Puppet::Type.type(:service).provide :base, :parent => :service do
32
32
  @resource.fail "Either stop/status commands or a pattern must be specified" unless @resource[:pattern]
33
33
  regex = Regexp.new(@resource[:pattern])
34
34
  ps = getps
35
+
35
36
  self.debug "Executing '#{ps}'"
36
- IO.popen(ps) { |table|
37
- table.each_line { |line|
38
- if regex.match(line)
39
- self.debug "Process matched: #{line}"
40
- ary = line.sub(/^\s+/, '').split(/\s+/)
41
- return ary[1]
42
- end
43
- }
37
+ table = Puppet::Util::Execution.execute(ps)
38
+
39
+ # The output of the PS command can be a mashup of several different
40
+ # encodings depending on which processes are running and what
41
+ # arbitrary data has been used to set their name in the process table.
42
+ #
43
+ # First, try a polite conversion to in order to match the UTF-8 encoding
44
+ # of our regular expression.
45
+ table = Puppet::Util::CharacterEncoding.convert_to_utf_8(table)
46
+ # If that fails, force to UTF-8 and then scrub as most uses are scanning
47
+ # for ACII-compatible program names.
48
+ table.force_encoding(Encoding::UTF_8) unless table.encoding == Encoding::UTF_8
49
+ table = Puppet::Util::CharacterEncoding.scrub(table) unless table.valid_encoding?
50
+
51
+ table.each_line { |line|
52
+ if regex.match(line)
53
+ self.debug "Process matched: #{line}"
54
+ ary = line.sub(/^[[:space:]]+/u, '').split(/[[:space:]]+/u)
55
+ return ary[1]
56
+ end
44
57
  }
45
58
 
46
59
  nil
@@ -4,10 +4,9 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
4
4
  This provider manages jobs with `launchd`, which is the default service
5
5
  framework for Mac OS X (and may be available for use on other platforms).
6
6
 
7
- For `launchd` documentation, see:
7
+ For more information, see the `launchd` man page:
8
8
 
9
- * <https://developer.apple.com/macosx/launchd.html>
10
- * <http://launchd.macosforge.org/>
9
+ * <https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man8/launchd.8.html>
11
10
 
12
11
  This provider reads plists out of the following directories:
13
12
 
@@ -72,6 +72,7 @@ Puppet::Type.type(:user).provide :aix, :parent => Puppet::Provider::AixObject do
72
72
  :from => :expiry_from_attr },
73
73
  {:aix_attr => :maxage, :puppet_prop => :password_max_age},
74
74
  {:aix_attr => :minage, :puppet_prop => :password_min_age},
75
+ {:aix_attr => :pwdwarntime, :puppet_prop => :password_warn_days},
75
76
  {:aix_attr => :attributes, :puppet_prop => :attributes},
76
77
  { :aix_attr => :gecos, :puppet_prop => :comment },
77
78
  ]
@@ -18,6 +18,7 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source =>
18
18
  options :profiles, :flag => "-P"
19
19
  options :password_min_age, :flag => "-n"
20
20
  options :password_max_age, :flag => "-x"
21
+ options :password_warn_days, :flag => "-w"
21
22
 
22
23
  verify :gid, "GID must be an integer" do |value|
23
24
  value.is_a? Integer
@@ -48,7 +49,7 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source =>
48
49
  cmd = []
49
50
  Puppet::Type.type(:user).validproperties.each do |property|
50
51
  #skip the password because we can't create it with the solaris useradd
51
- next if [:ensure, :password, :password_min_age, :password_max_age].include?(property)
52
+ next if [:ensure, :password, :password_min_age, :password_max_age, :password_warn_days].include?(property)
52
53
  # 1680 Now you can set the hashed passwords on solaris:lib/puppet/provider/user/user_role_add.rb
53
54
  # the value needs to be quoted, mostly because -c might
54
55
  # have spaces in it
@@ -196,6 +197,11 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source =>
196
197
  shadow_entry[4].empty? ? -1 : shadow_entry[4]
197
198
  end
198
199
 
200
+ def password_warn_days
201
+ return :absent unless shadow_entry
202
+ shadow_entry[5].empty? ? -1 : shadow_entry[5]
203
+ end
204
+
199
205
  # Read in /etc/shadow, find the line for our used and rewrite it with the
200
206
  # new pw. Smooth like 80 grit sandpaper.
201
207
  #
@@ -16,6 +16,7 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
16
16
  options :groups, :flag => "-G"
17
17
  options :password_min_age, :flag => "-m", :method => :sp_min
18
18
  options :password_max_age, :flag => "-M", :method => :sp_max
19
+ options :password_warn_days, :flag => "-W", :method => :sp_warn
19
20
  options :password, :method => :sp_pwdp
20
21
  options :expiry, :method => :sp_expire,
21
22
  :munge => proc { |value|
@@ -192,7 +193,7 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
192
193
  end
193
194
 
194
195
  def passcmd
195
- age_limits = [:password_min_age, :password_max_age].select { |property| @resource.should(property) }
196
+ age_limits = [:password_min_age, :password_max_age, :password_warn_days].select { |property| @resource.should(property) }
196
197
  if age_limits.empty?
197
198
  nil
198
199
  else
@@ -200,7 +201,7 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
200
201
  end
201
202
  end
202
203
 
203
- [:expiry, :password_min_age, :password_max_age, :password].each do |shadow_property|
204
+ [:expiry, :password_min_age, :password_max_age, :password_warn_days, :password].each do |shadow_property|
204
205
  define_method(shadow_property) do
205
206
  if Puppet.features.libshadow?
206
207
  if ent = Shadow::Passwd.getspnam(@canonical_name)
@@ -15,7 +15,11 @@ Puppet::Type.type(:zfs).provide(:zfs) do
15
15
  Puppet::Type.type(:zfs).validproperties.each do |property|
16
16
  next if property == :ensure
17
17
  if value = @resource[property] and value != ""
18
- properties << "-o" << "#{property}=#{value}"
18
+ if property == :volsize
19
+ properties << "-V" << "#{value}"
20
+ else
21
+ properties << "-o" << "#{property}=#{value}"
22
+ end
19
23
  end
20
24
  end
21
25
  properties
@@ -256,10 +256,11 @@ module Puppet
256
256
  end
257
257
 
258
258
  newparam(:environment) do
259
- desc "Any additional environment variables you want to set for a
260
- command. Note that if you use this to set PATH, it will override
261
- the `path` attribute. Multiple environment variables should be
262
- specified as an array."
259
+ desc "An array of any additional environment variables you want to set for a
260
+ command. e.g.: `[ 'HOME=/root', 'MAIL=root@example.com']`
261
+ Note that if you use this to set PATH, it will override the `path`
262
+ attribute. Multiple environment variables should be specified as an
263
+ array."
263
264
 
264
265
  validate do |values|
265
266
  values = [values] unless values.is_a? Array
@@ -1,7 +1,7 @@
1
1
  Puppet::Type.newtype(:macauthorization) do
2
2
 
3
3
  @doc = "Manage the Mac OS X authorization database. See the
4
- [Apple developer site](https://developer.apple.com/documentation/Security/Conceptual/Security_Overview/Security_Services/chapter_4_section_5.html)
4
+ [Apple developer site](https://developer.apple.com/library/content/documentation/Security/Conceptual/Security_Overview/AuthenticationAndAuthorization/AuthenticationAndAuthorization.html)
5
5
  for more information.
6
6
 
7
7
  Note that authorization store directives with hyphens in their names have
@@ -279,6 +279,25 @@ module Puppet
279
279
  end
280
280
  end
281
281
 
282
+ newproperty(:password_warn_days, :required_features => :manages_password_age) do
283
+ desc "The number of days before a password is going to expire (see the maximum password age) during which the user should be warned."
284
+
285
+ munge do |value|
286
+ case value
287
+ when String
288
+ Integer(value)
289
+ else
290
+ value
291
+ end
292
+ end
293
+
294
+ validate do |value|
295
+ if value.to_s !~ /^-?\d+$/
296
+ raise ArgumentError, "Password warning days must be provided as a number."
297
+ end
298
+ end
299
+ end
300
+
282
301
  newproperty(:groups, :parent => Puppet::Property::List) do
283
302
  desc "The groups to which the user belongs. The primary group should
284
303
  not be listed, and groups should be identified by name rather than by
@@ -217,6 +217,7 @@ Puppet::Util::Log.newdesttype :eventlog do
217
217
  Puppet::Util::Log::DestEventlog::EVENTLOG_ERROR_TYPE = 0x0001
218
218
  Puppet::Util::Log::DestEventlog::EVENTLOG_WARNING_TYPE = 0x0002
219
219
  Puppet::Util::Log::DestEventlog::EVENTLOG_INFORMATION_TYPE = 0x0004
220
+ Puppet::Util::Log::DestEventlog::EVENTLOG_CHARACTER_LIMIT = 31838
220
221
 
221
222
  def self.suitable?(obj)
222
223
  Puppet.features.microsoft_windows?
@@ -233,6 +234,15 @@ Puppet::Util::Log.newdesttype :eventlog do
233
234
  def handle(msg)
234
235
  native_type, native_id = to_native(msg.level)
235
236
 
237
+ stringified_msg = msg.message.to_s
238
+ if stringified_msg.length > self.class::EVENTLOG_CHARACTER_LIMIT
239
+ warning = "...Message exceeds character length limit, truncating."
240
+ truncated_message_length = self.class::EVENTLOG_CHARACTER_LIMIT - warning.length
241
+ stringified_truncated_msg = stringified_msg[0..truncated_message_length]
242
+ stringified_truncated_msg << warning
243
+ msg.message = stringified_truncated_msg
244
+ end
245
+
236
246
  @eventlog.report_event(
237
247
  :event_type => native_type,
238
248
  :event_id => native_id,
@@ -179,9 +179,23 @@ module Puppet::Util::Windows::File
179
179
 
180
180
  def self.get_reparse_point_data(handle, &block)
181
181
  # must be multiple of 1024, min 10240
182
- FFI::MemoryPointer.new(REPARSE_DATA_BUFFER.size) do |reparse_data_buffer_ptr|
182
+ FFI::MemoryPointer.new(MAXIMUM_REPARSE_DATA_BUFFER_SIZE) do |reparse_data_buffer_ptr|
183
183
  device_io_control(handle, FSCTL_GET_REPARSE_POINT, nil, reparse_data_buffer_ptr)
184
- yield REPARSE_DATA_BUFFER.new(reparse_data_buffer_ptr)
184
+
185
+ reparse_tag = reparse_data_buffer_ptr.read_win32_ulong
186
+ buffer_type = case reparse_tag
187
+ when 0xA000000C
188
+ SYMLINK_REPARSE_DATA_BUFFER
189
+ when 0xA0000003
190
+ MOUNT_POINT_REPARSE_DATA_BUFFER
191
+ when 0x80000014
192
+ raise Puppet::Util::Windows::Error.new("Retrieving NFS reparse point data is unsupported")
193
+ else
194
+ raise Puppet::Util::Windows::Error.new("DeviceIoControl(#{handle}, " +
195
+ "FSCTL_GET_REPARSE_POINT) returned unknown tag 0x#{reparse_tag.to_s(16).upcase}")
196
+ end
197
+
198
+ yield buffer_type.new(reparse_data_buffer_ptr)
185
199
  end
186
200
 
187
201
  # underlying struct MemoryPointer has been cleaned up by this point, nothing to return
@@ -448,11 +462,11 @@ module Puppet::Util::Windows::File
448
462
 
449
463
  MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16384
450
464
 
451
- # REPARSE_DATA_BUFFER
465
+ # SYMLINK_REPARSE_DATA_BUFFER
452
466
  # https://msdn.microsoft.com/en-us/library/cc232006.aspx
453
467
  # https://msdn.microsoft.com/en-us/library/windows/hardware/ff552012(v=vs.85).aspx
454
468
  # struct is always MAXIMUM_REPARSE_DATA_BUFFER_SIZE bytes
455
- class REPARSE_DATA_BUFFER < FFI::Struct
469
+ class SYMLINK_REPARSE_DATA_BUFFER < FFI::Struct
456
470
  layout :ReparseTag, :win32_ulong,
457
471
  :ReparseDataLength, :ushort,
458
472
  :Reserved, :ushort,
@@ -466,6 +480,23 @@ module Puppet::Util::Windows::File
466
480
  :PathBuffer, [:byte, MAXIMUM_REPARSE_DATA_BUFFER_SIZE - 20]
467
481
  end
468
482
 
483
+ # MOUNT_POINT_REPARSE_DATA_BUFFER
484
+ # https://msdn.microsoft.com/en-us/library/cc232007.aspx
485
+ # https://msdn.microsoft.com/en-us/library/windows/hardware/ff552012(v=vs.85).aspx
486
+ # struct is always MAXIMUM_REPARSE_DATA_BUFFER_SIZE bytes
487
+ class MOUNT_POINT_REPARSE_DATA_BUFFER < FFI::Struct
488
+ layout :ReparseTag, :win32_ulong,
489
+ :ReparseDataLength, :ushort,
490
+ :Reserved, :ushort,
491
+ :SubstituteNameOffset, :ushort,
492
+ :SubstituteNameLength, :ushort,
493
+ :PrintNameOffset, :ushort,
494
+ :PrintNameLength, :ushort,
495
+ # max less above fields dword / uint 4 bytes, ushort 2 bytes
496
+ # technically a WCHAR buffer, but we care about size in bytes here
497
+ :PathBuffer, [:byte, MAXIMUM_REPARSE_DATA_BUFFER_SIZE - 16]
498
+ end
499
+
469
500
  # https://msdn.microsoft.com/en-us/library/windows/desktop/aa364980(v=vs.85).aspx
470
501
  # DWORD WINAPI GetLongPathName(
471
502
  # _In_ LPCTSTR lpszShortPath,
@@ -1,5 +1,5 @@
1
1
  module SemanticPuppet
2
- Puppet::GettextConfig.initialize(File.absolute_path('../locales', File.dirname(__FILE__)), :po)
2
+ Puppet::GettextConfig.load_translations('semantic_puppet', File.absolute_path('../locales', File.dirname(__FILE__)), :po)
3
3
 
4
4
  autoload :Version, 'semantic_puppet/version'
5
5
  autoload :VersionRange, 'semantic_puppet/version_range'
@@ -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 = '5.3.2'
9
+ PUPPETVERSION = '5.3.3'
10
10
 
11
11
  ##
12
12
  # version is a public API method intended to always provide a fast and
@@ -114,6 +114,8 @@ module Puppet::Pal
114
114
  # @param env_name [String] the name of an existing environment
115
115
  # @param modulepath [Array<String>] an array of directory paths containing Puppet modules, overrides the modulepath of an existing env.
116
116
  # Defaults to `{env_dir}/modules` if `env_dir` is given,
117
+ # @param pre_modulepath [Array<String>] like modulepath, but is prepended to the modulepath
118
+ # @param post_modulepath [Array<String>] like modulepath, but is appended to the modulepath
117
119
  # @param settings_hash [Hash] a hash of settings - currently not used for anything, defaults to empty hash
118
120
  # @param env_dir [String] a reference to a directory being the named environment (mutually exclusive with `envpath`)
119
121
  # @param envpath [String] a path of directories in which there are environments to search for `env_name` (mutually exclusive with `env_dir`).
@@ -124,6 +126,8 @@ module Puppet::Pal
124
126
  #
125
127
  def self.in_environment(env_name,
126
128
  modulepath: nil,
129
+ pre_modulepath: [],
130
+ post_modulepath: [],
127
131
  settings_hash: {},
128
132
  env_dir: nil,
129
133
  envpath: nil,
@@ -134,6 +138,8 @@ module Puppet::Pal
134
138
  # TRANSLATORS terms in the assertions below are names of terms in code
135
139
  assert_non_empty_string(env_name, 'env_name')
136
140
  assert_optionally_empty_array(modulepath, 'modulepath', true)
141
+ assert_optionally_empty_array(pre_modulepath, 'pre_modulepath', false)
142
+ assert_optionally_empty_array(post_modulepath, 'post_modulepath', false)
137
143
  assert_mutually_exclusive(env_dir, envpath, 'env_dir', 'envpath')
138
144
 
139
145
  unless block_given?
@@ -146,10 +152,9 @@ module Puppet::Pal
146
152
  end
147
153
 
148
154
  # a nil modulepath for env_dir means it should use its ./modules directory
149
- if modulepath.nil?
150
- modulepath = [Puppet::FileSystem.expand_path(File.join(env_dir, 'modules'))]
151
- end
152
- env = Puppet::Node::Environment.create(env_name, modulepath)
155
+ mid_modulepath = modulepath.nil? ? [Puppet::FileSystem.expand_path(File.join(env_dir, 'modules'))] : modulepath
156
+
157
+ env = Puppet::Node::Environment.create(env_name, pre_modulepath + mid_modulepath + post_modulepath)
153
158
  environments = Puppet::Environments::StaticDirectory.new(env_name, env_dir, env) # The env being used is the only one...
154
159
  else
155
160
  assert_non_empty_string(envpath, 'envpath')
@@ -169,7 +174,12 @@ module Puppet::Pal
169
174
  raise ArgumentError, _("No directory found for the environment '%{env_name}' on the path '%{envpath}'") % { env_name: env_name, envpath: envpath }
170
175
  end
171
176
  # A given modulepath should override the default
172
- env = env.override_with(:modulepath => modulepath) if !modulepath.nil?
177
+ mid_modulepath = modulepath.nil? ? env.modulepath : modulepath
178
+ env_path = env.configuration.path_to_env
179
+ env = env.override_with(:modulepath => pre_modulepath + mid_modulepath + post_modulepath)
180
+ # must configure this in case logic looks up the env by name again (otherwise the looked up env does
181
+ # not have the same effective modulepath).
182
+ environments = Puppet::Environments::StaticDirectory.new(env_name, env_path, env) # The env being used is the only one...
173
183
  end
174
184
  with_loaded_environment(environments, env, facts, variables, &block)
175
185
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-02 00:00:00.000000000 Z
11
+ date: 2017-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -289,6 +289,10 @@ files:
289
289
  - lib/bolt/node/ssh.rb
290
290
  - lib/bolt/node/winrm.rb
291
291
  - lib/bolt/node_uri.rb
292
+ - lib/bolt/notifier.rb
293
+ - lib/bolt/outputter.rb
294
+ - lib/bolt/outputter/human.rb
295
+ - lib/bolt/outputter/json.rb
292
296
  - lib/bolt/result.rb
293
297
  - lib/bolt/version.rb
294
298
  - vendored/facter/lib/facter.rb
@@ -580,6 +584,7 @@ files:
580
584
  - vendored/puppet/lib/puppet/file_serving/metadata.rb
581
585
  - vendored/puppet/lib/puppet/file_serving/mount.rb
582
586
  - vendored/puppet/lib/puppet/file_serving/mount/file.rb
587
+ - vendored/puppet/lib/puppet/file_serving/mount/locales.rb
583
588
  - vendored/puppet/lib/puppet/file_serving/mount/modules.rb
584
589
  - vendored/puppet/lib/puppet/file_serving/mount/pluginfacts.rb
585
590
  - vendored/puppet/lib/puppet/file_serving/mount/plugins.rb
@@ -1064,10 +1069,10 @@ files:
1064
1069
  - vendored/puppet/lib/puppet/pops/types/implementation_registry.rb
1065
1070
  - vendored/puppet/lib/puppet/pops/types/iterable.rb
1066
1071
  - vendored/puppet/lib/puppet/pops/types/p_binary_type.rb
1067
- - vendored/puppet/lib/puppet/pops/types/p_error_type.rb
1068
1072
  - vendored/puppet/lib/puppet/pops/types/p_init_type.rb
1069
1073
  - vendored/puppet/lib/puppet/pops/types/p_meta_type.rb
1070
1074
  - vendored/puppet/lib/puppet/pops/types/p_object_type.rb
1075
+ - vendored/puppet/lib/puppet/pops/types/p_object_type_extension.rb
1071
1076
  - vendored/puppet/lib/puppet/pops/types/p_runtime_type.rb
1072
1077
  - vendored/puppet/lib/puppet/pops/types/p_sem_ver_range_type.rb
1073
1078
  - vendored/puppet/lib/puppet/pops/types/p_sem_ver_type.rb