bolt 0.5.1 → 0.6.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 (94) hide show
  1. checksums.yaml +4 -4
  2. data/exe/bolt +1 -1
  3. data/lib/bolt.rb +0 -3
  4. data/lib/bolt/cli.rb +66 -32
  5. data/lib/bolt/config.rb +19 -0
  6. data/lib/bolt/executor.rb +21 -16
  7. data/lib/bolt/node.rb +13 -10
  8. data/lib/bolt/node/errors.rb +22 -0
  9. data/lib/bolt/node/ssh.rb +25 -2
  10. data/lib/bolt/node/winrm.rb +14 -2
  11. data/lib/bolt/node_uri.rb +15 -14
  12. data/lib/bolt/result.rb +22 -0
  13. data/lib/bolt/version.rb +1 -1
  14. data/vendored/puppet/lib/puppet/application/script.rb +7 -1
  15. data/vendored/puppet/lib/puppet/configurer.rb +1 -1
  16. data/vendored/puppet/lib/puppet/defaults.rb +18 -1
  17. data/vendored/puppet/lib/puppet/functions/run_command.rb +5 -2
  18. data/vendored/puppet/lib/puppet/functions/run_script.rb +5 -2
  19. data/vendored/puppet/lib/puppet/functions/run_task.rb +7 -2
  20. data/vendored/puppet/lib/puppet/gettext/config.rb +47 -26
  21. data/vendored/puppet/lib/puppet/graph/relationship_graph.rb +6 -0
  22. data/vendored/puppet/lib/puppet/indirector/node/ldap.rb +19 -3
  23. data/vendored/puppet/lib/puppet/module.rb +8 -7
  24. data/vendored/puppet/lib/puppet/network/http/webrick.rb +1 -0
  25. data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +9 -0
  26. data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +8 -0
  27. data/vendored/puppet/lib/puppet/pops/types/p_error_type.rb +12 -0
  28. data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +9 -3
  29. data/vendored/puppet/lib/puppet/pops/types/ruby_generator.rb +65 -24
  30. data/vendored/puppet/lib/puppet/provider/mount.rb +25 -8
  31. data/vendored/puppet/lib/puppet/provider/package/dnf.rb +1 -1
  32. data/vendored/puppet/lib/puppet/provider/package/gem.rb +1 -1
  33. data/vendored/puppet/lib/puppet/provider/package/pkg.rb +3 -0
  34. data/vendored/puppet/lib/puppet/provider/service/launchd.rb +1 -1
  35. data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +20 -1
  36. data/vendored/puppet/lib/puppet/type/mount.rb +6 -2
  37. data/vendored/puppet/lib/puppet/type/yumrepo.rb +9 -0
  38. data/vendored/puppet/lib/puppet/version.rb +1 -1
  39. data/vendored/puppet/lib/puppet_pal.rb +33 -7
  40. metadata +45 -83
  41. data/.gitignore +0 -33
  42. data/.gitmodules +0 -12
  43. data/.rspec +0 -2
  44. data/.rubocop.yml +0 -61
  45. data/.travis.yml +0 -18
  46. data/CODE_OF_CONDUCT.md +0 -46
  47. data/CONTRIBUTING.md +0 -27
  48. data/Gemfile +0 -9
  49. data/INSTALL.md +0 -70
  50. data/LICENSE +0 -201
  51. data/README.md +0 -353
  52. data/Rakefile +0 -27
  53. data/Vagrantfile +0 -13
  54. data/appveyor.yml +0 -29
  55. data/bolt.gemspec +0 -50
  56. data/docs/writing_tasks_and_plans.pdf +0 -0
  57. data/metadata.json +0 -13
  58. data/tasks/init.json +0 -3
  59. data/tasks/init.rb +0 -44
  60. data/ux/bolt-CLI-spec.md +0 -186
  61. data/vendored/puppet/lib/puppet/external/nagios/grammar.ry +0 -248
  62. data/vendored/puppet/lib/puppet/external/nagios/makefile +0 -9
  63. data/vendored/puppet/lib/puppet/face/help/action.erb +0 -86
  64. data/vendored/puppet/lib/puppet/face/help/face.erb +0 -114
  65. data/vendored/puppet/lib/puppet/face/help/global.erb +0 -16
  66. data/vendored/puppet/lib/puppet/face/help/man.erb +0 -152
  67. data/vendored/puppet/lib/puppet/generate/templates/type/pcore.erb +0 -42
  68. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.fixtures.yml.erb +0 -7
  69. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.gitignore +0 -18
  70. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.rubocop.yml +0 -42
  71. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.yardopts +0 -1
  72. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/Gemfile +0 -18
  73. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +0 -89
  74. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +0 -32
  75. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/examples/init.pp.erb +0 -12
  76. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +0 -48
  77. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/metadata.json.erb +0 -1
  78. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +0 -6
  79. data/vendored/puppet/lib/puppet/pops/model/ast.pp +0 -695
  80. data/vendored/puppet/lib/puppet/pops/parser/egrammar.ra +0 -937
  81. data/vendored/puppet/lib/puppet/pops/resource/resource_type_set.pcore +0 -22
  82. data/vendored/puppet/lib/puppet/util/libuser.conf +0 -15
  83. data/vendored/puppet/lib/puppet/vendor/deep_merge/CHANGELOG +0 -45
  84. data/vendored/puppet/lib/puppet/vendor/deep_merge/Gemfile +0 -3
  85. data/vendored/puppet/lib/puppet/vendor/deep_merge/LICENSE +0 -21
  86. data/vendored/puppet/lib/puppet/vendor/deep_merge/PUPPET_README.md +0 -6
  87. data/vendored/puppet/lib/puppet/vendor/deep_merge/README.md +0 -113
  88. data/vendored/puppet/lib/puppet/vendor/deep_merge/Rakefile +0 -19
  89. data/vendored/puppet/lib/puppet/vendor/deep_merge/deep_merge.gemspec +0 -35
  90. data/vendored/puppet/lib/puppet/vendor/pathspec/CHANGELOG.md +0 -2
  91. data/vendored/puppet/lib/puppet/vendor/pathspec/LICENSE +0 -201
  92. data/vendored/puppet/lib/puppet/vendor/pathspec/PUPPET_README.md +0 -6
  93. data/vendored/puppet/lib/puppet/vendor/pathspec/README.md +0 -53
  94. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/locales/config.yaml +0 -21
@@ -9,15 +9,27 @@ module Bolt
9
9
 
10
10
  @shell = shell
11
11
  @endpoint = "http://#{host}:#{port}/wsman"
12
+ end
13
+
14
+ def connect
12
15
  @connection = ::WinRM::Connection.new(endpoint: @endpoint,
13
16
  user: @user,
14
17
  password: @password)
15
18
  @connection.logger = @transport_logger
16
- end
17
19
 
18
- def connect
19
20
  @session = @connection.shell(@shell)
21
+ @session.run('$PSVersionTable.PSVersion')
20
22
  @logger.debug { "Opened session" }
23
+ rescue ::WinRM::WinRMAuthorizationError
24
+ raise Bolt::Node::ConnectError.new(
25
+ "Authentication failed for #{@endpoint}",
26
+ 'AUTH_ERROR'
27
+ )
28
+ rescue StandardError => e
29
+ raise Bolt::Node::ConnectError.new(
30
+ "Failed to connect to #{@endpoint}: #{e.message}",
31
+ 'CONNECT_ERROR'
32
+ )
21
33
  end
22
34
 
23
35
  def disconnect
@@ -1,3 +1,5 @@
1
+ require 'addressable'
2
+
1
3
  module Bolt
2
4
  class NodeURI
3
5
  def initialize(string)
@@ -5,18 +7,13 @@ module Bolt
5
7
  end
6
8
 
7
9
  def parse(string)
8
- case string
9
- when %r{^(ssh|winrm|pcp)://.*:\d+$}
10
- URI(string)
11
- when %r{^pcp://}
12
- URI(string)
13
- when %r{^(ssh|winrm)://}
14
- uri = URI(string)
15
- uri.port = 5985 if uri.scheme == 'winrm'
16
- uri
17
- else
18
- URI("ssh://#{string}")
19
- end
10
+ uri = if string =~ %r{^(ssh|winrm|pcp)://}
11
+ Addressable::URI.parse(string)
12
+ else
13
+ Addressable::URI.parse("ssh://#{string}")
14
+ end
15
+ uri.port ||= 5985 if uri.scheme == 'winrm'
16
+ uri
20
17
  end
21
18
 
22
19
  def hostname
@@ -28,11 +25,15 @@ module Bolt
28
25
  end
29
26
 
30
27
  def user
31
- @uri.user
28
+ Addressable::URI.unencode_component(
29
+ @uri.user
30
+ )
32
31
  end
33
32
 
34
33
  def password
35
- @uri.password
34
+ Addressable::URI.unencode_component(
35
+ @uri.password
36
+ )
36
37
  end
37
38
 
38
39
  def scheme
@@ -25,6 +25,28 @@ module Bolt
25
25
  end
26
26
  end
27
27
 
28
+ class ErrorResult < Result
29
+ def initialize(message, issue_code, kind)
30
+ super(message)
31
+ @issue_code = issue_code
32
+ @kind = kind
33
+ end
34
+
35
+ def to_h
36
+ {
37
+ 'error' => {
38
+ 'issue_code' => @issue_code,
39
+ 'kind' => @kind,
40
+ 'msg' => @message
41
+ }
42
+ }
43
+ end
44
+
45
+ def success?
46
+ false
47
+ end
48
+ end
49
+
28
50
  class CommandResult < Result
29
51
  attr_reader :stdout, :stderr, :exit_code
30
52
 
@@ -1,3 +1,3 @@
1
1
  module Bolt
2
- VERSION = '0.5.1'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
@@ -113,7 +113,13 @@ Copyright (c) 2017 Puppet Inc., LLC Licensed under the Apache 2.0 License
113
113
  end
114
114
 
115
115
  def run_command
116
- main
116
+ if Puppet.features.bolt?
117
+ Puppet.override(:bolt_executor => Bolt::Executor.new) do
118
+ main
119
+ end
120
+ else
121
+ raise _("Bolt must be installed to use the script application")
122
+ end
117
123
  end
118
124
 
119
125
  def main
@@ -375,7 +375,7 @@ class Puppet::Configurer
375
375
  :transaction_uuid => @transaction_uuid,
376
376
  :fail_on_404 => false)
377
377
  found = true
378
- rescue Exception => e
378
+ rescue
379
379
  # Nothing to see here
380
380
  end
381
381
  end
@@ -126,6 +126,19 @@ module Puppet
126
126
  munge(value)
127
127
  value.to_sym
128
128
  end
129
+ },
130
+ :disable_i18n => {
131
+ :default => false,
132
+ :type => :boolean,
133
+ :desc => "If true, turns off all translations of Puppet and module
134
+ log messages, which affects error, warning, and info log messages,
135
+ as well as any translations in the report and CLI.",
136
+ :hook => proc do |value|
137
+ if value
138
+ require 'puppet/gettext/stubs'
139
+ Puppet::GettextConfig.disable_gettext
140
+ end
141
+ end
129
142
  }
130
143
  )
131
144
 
@@ -156,7 +169,9 @@ module Puppet
156
169
  :static_catalogs => {
157
170
  :default => true,
158
171
  :type => :boolean,
159
- :desc => "Whether to compile a static catalog."
172
+ :desc => "Whether to compile a [static catalog](https://docs.puppet.com/puppet/latest/static_catalogs.html#enabling-or-disabling-static-catalogs),
173
+ which occurs only on a Puppet Server master when the `code-id-command` and
174
+ `code-content-command` settings are configured in its `puppetserver.conf` file.",
160
175
  },
161
176
  :strict_environment_mode => {
162
177
  :default => false,
@@ -1312,6 +1327,8 @@ EOT
1312
1327
  :default => "$vardir/devices",
1313
1328
  :type => :directory,
1314
1329
  :mode => "0750",
1330
+ :owner => "service",
1331
+ :group => "service",
1315
1332
  :desc => "The root directory of devices' $vardir.",
1316
1333
  },
1317
1334
  :deviceconfig => {
@@ -26,7 +26,8 @@ Puppet::Functions.create_function(:run_command) do
26
26
  {:operation => 'run_command'})
27
27
  end
28
28
 
29
- unless Puppet.features.bolt?
29
+ executor = Puppet.lookup(:bolt_executor) { nil }
30
+ unless executor && Puppet.features.bolt?
30
31
  raise Puppet::ParseErrorWithIssue.from_issue_and_stack(Puppet::Pops::Issues::TASK_MISSING_BOLT, :action => _('run a command'))
31
32
  end
32
33
 
@@ -35,7 +36,9 @@ Puppet::Functions.create_function(:run_command) do
35
36
  call_function('debug', "Simulating run_command('#{command}') - no hosts given - no action taken")
36
37
  Puppet::Pops::Types::ExecutionResult::EMPTY_RESULT
37
38
  else
38
- Puppet::Pops::Types::ExecutionResult.from_bolt(Bolt::Executor.from_uris(hosts).run_command(command))
39
+ Puppet::Pops::Types::ExecutionResult.from_bolt(
40
+ executor.run_command(executor.from_uris(hosts), command)
41
+ )
39
42
  end
40
43
  end
41
44
  end
@@ -27,7 +27,8 @@ Puppet::Functions.create_function(:run_script, Puppet::Functions::InternalFuncti
27
27
  {:operation => 'run_script'})
28
28
  end
29
29
 
30
- unless Puppet.features.bolt?
30
+ executor = Puppet.lookup(:bolt_executor) { nil }
31
+ unless executor && Puppet.features.bolt?
31
32
  raise Puppet::ParseErrorWithIssue.from_issue_and_stack(Puppet::Pops::Issues::TASK_MISSING_BOLT, :action => _('run a script'))
32
33
  end
33
34
 
@@ -44,7 +45,9 @@ Puppet::Functions.create_function(:run_script, Puppet::Functions::InternalFuncti
44
45
  call_function('debug', "Simulating run_script of '#{found}' - no hosts given - no action taken")
45
46
  Puppet::Pops::Types::ExecutionResult::EMPTY_RESULT
46
47
  else
47
- Puppet::Pops::Types::ExecutionResult.from_bolt(Bolt::Executor.from_uris(hosts).run_script(found))
48
+ Puppet::Pops::Types::ExecutionResult.from_bolt(
49
+ executor.run_script(executor.from_uris(hosts), found)
50
+ )
48
51
  end
49
52
  end
50
53
  end
@@ -55,7 +55,8 @@ Puppet::Functions.create_function(:run_task) do
55
55
  {:operation => 'run_task'})
56
56
  end
57
57
 
58
- unless Puppet.features.bolt?
58
+ executor = Puppet.lookup(:bolt_executor) { nil }
59
+ unless executor && Puppet.features.bolt?
59
60
  raise Puppet::ParseErrorWithIssue.from_issue_and_stack(Puppet::Pops::Issues::TASK_MISSING_BOLT, :action => _('run a task'))
60
61
  end
61
62
 
@@ -67,7 +68,11 @@ Puppet::Functions.create_function(:run_task) do
67
68
  input_method = task._pcore_type['input_method'].value
68
69
 
69
70
  arguments = task.task_args
70
- Puppet::Pops::Types::ExecutionResult.from_bolt(Bolt::Executor.from_uris(hosts).run_task(task.executable_path, input_method, arguments))
71
+ Puppet::Pops::Types::ExecutionResult.from_bolt(
72
+ executor.run_task(
73
+ executor.from_uris(hosts), task.executable_path, input_method, arguments
74
+ )
75
+ )
71
76
  end
72
77
  end
73
78
  end
@@ -1,18 +1,36 @@
1
1
  require 'puppet/util/platform'
2
+ require 'puppet/file_system'
2
3
 
3
4
  module Puppet::GettextConfig
4
5
  LOCAL_PATH = File.absolute_path('../../../locales', File.dirname(__FILE__))
5
6
  POSIX_PATH = File.absolute_path('../../../../../share/locale', File.dirname(__FILE__))
6
7
  WINDOWS_PATH = File.absolute_path('../../../../../../../puppet/share/locale', File.dirname(__FILE__))
7
8
 
9
+ # Load gettext helpers and track whether they're available.
10
+ # Used instead of features because we initialize gettext before features is available.
11
+ # Stubbing gettext if unavailable is handled in puppet.rb.
12
+ begin
13
+ require 'gettext-setup'
14
+ require 'locale'
15
+ @gettext_loaded = true
16
+ rescue LoadError
17
+ @gettext_loaded = false
18
+ end
19
+
20
+ # Whether we were able to require gettext-setup and locale
21
+ # @return [Boolean] true if gettext-setup was successfully loaded
22
+ def self.gettext_loaded?
23
+ @gettext_loaded
24
+ end
25
+
8
26
  # Search for puppet gettext config files
9
27
  # @return [String] path to the config, or nil if not found
10
28
  def self.puppet_locale_path
11
- if File.exist?(LOCAL_PATH)
29
+ if Puppet::FileSystem.exist?(LOCAL_PATH)
12
30
  return LOCAL_PATH
13
- elsif Puppet::Util::Platform.windows? && File.exist?(WINDOWS_PATH)
31
+ elsif Puppet::Util::Platform.windows? && Puppet::FileSystem.exist?(WINDOWS_PATH)
14
32
  return WINDOWS_PATH
15
- elsif !Puppet::Util::Platform.windows? && File.exist?(POSIX_PATH)
33
+ elsif !Puppet::Util::Platform.windows? && Puppet::FileSystem.exist?(POSIX_PATH)
16
34
  return POSIX_PATH
17
35
  else
18
36
  nil
@@ -30,40 +48,43 @@ module Puppet::GettextConfig
30
48
  end
31
49
  end
32
50
 
51
+ # Prevent future gettext initializations
52
+ def self.disable_gettext
53
+ @gettext_disabled = true
54
+ end
55
+
33
56
  # Attempt to initialize the gettext-setup gem
34
57
  # @param path [String] to gettext config file
35
58
  # @param file_format [Symbol] translation file format to use, either :po or :mo
36
59
  # @return true if initialization succeeded, false otherwise
37
- def self.initialize(conf_file_location, file_format)
60
+ def self.initialize(conf_file_dir, file_format)
61
+ return false if @gettext_disabled || !@gettext_loaded
62
+
38
63
  unless file_format == :po || file_format == :mo
39
64
  raise Puppet::Error, "Unsupported translation file format #{file_format}; please use :po or :mo"
40
65
  end
41
66
 
42
- begin
43
- require 'gettext-setup'
44
- require 'locale'
67
+ return false if conf_file_dir.nil?
45
68
 
46
- if conf_file_location && File.exists?(conf_file_location)
47
- if GettextSetup.method(:initialize).parameters.count == 1
48
- # For use with old gettext-setup gem versions, will load PO files only
49
- GettextSetup.initialize(conf_file_location)
50
- else
51
- GettextSetup.initialize(conf_file_location, :file_format => file_format)
52
- end
53
- # Only change this once.
54
- # Because negotiate_locales will only return a non-default locale if
55
- # the system locale matches a translation set actually available for the
56
- # given gettext project, we don't want this to get set back to default if
57
- # we load a module that doesn't have translations, but Puppet does have
58
- # translations for the user's locale.
59
- if FastGettext.locale == GettextSetup.default_locale
60
- FastGettext.locale = GettextSetup.negotiate_locale(Locale.current.language)
61
- end
62
- true
69
+ conf_file = File.join(conf_file_dir, "config.yaml")
70
+ if Puppet::FileSystem.exist?(conf_file)
71
+ if GettextSetup.method(:initialize).parameters.count == 1
72
+ # For use with old gettext-setup gem versions, will load PO files only
73
+ GettextSetup.initialize(conf_file_dir)
63
74
  else
64
- false
75
+ GettextSetup.initialize(conf_file_dir, :file_format => file_format)
65
76
  end
66
- rescue LoadError
77
+ # Only change this once.
78
+ # Because negotiate_locales will only return a non-default locale if
79
+ # the system locale matches a translation set actually available for the
80
+ # given gettext project, we don't want this to get set back to default if
81
+ # we load a module that doesn't have translations, but Puppet does have
82
+ # translations for the user's locale.
83
+ if FastGettext.locale == GettextSetup.default_locale
84
+ FastGettext.locale = GettextSetup.negotiate_locale(Locale.current.language)
85
+ end
86
+ true
87
+ else
67
88
  false
68
89
  end
69
90
  end
@@ -247,6 +247,12 @@ class Puppet::Graph::RelationshipGraph < Puppet::Graph::SimpleGraph
247
247
  containers.each { |x|
248
248
  admissible[x] = whit_class.new(:name => "admissible_#{x.ref}", :catalog => catalog)
249
249
  completed[x] = whit_class.new(:name => "completed_#{x.ref}", :catalog => catalog)
250
+
251
+ # This copies the original container's tags over to the two anchor whits.
252
+ # Without this, tags are not propagated to the container's resources.
253
+ admissible[x].set_tags(x)
254
+ completed[x].set_tags(x)
255
+
250
256
  priority = @prioritizer.priority_of(x)
251
257
  add_vertex(admissible[x], priority)
252
258
  add_vertex(completed[x], priority)
@@ -5,7 +5,8 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
5
5
  desc "Search in LDAP for node configuration information. See
6
6
  the [LDAP Nodes](https://docs.puppetlabs.com/guides/ldap_nodes.html) page for more information. This will first
7
7
  search for whatever the certificate name is, then (if that name
8
- contains a `.`) for the short name, then `default`."
8
+ contains a `.`) for the short name, then `default`.
9
+ Requires ruby-ldap with MRI ruby or jruby-ldap with puppetserver/jruby"
9
10
 
10
11
  # The attributes that Puppet class information is stored in.
11
12
  def class_attributes
@@ -93,7 +94,8 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
93
94
  result[:stacked] = get_stacked_values_from_entry(entry)
94
95
  result[:parameters] = get_parameters_from_entry(entry)
95
96
 
96
- result[:environment] = result[:parameters]["environment"] if result[:parameters]["environment"]
97
+ # delete from parameters to prevent "Already declered variable $environment" error
98
+ result[:environment] = result[:parameters].delete(:environment) if result[:parameters][:environment]
97
99
 
98
100
  result[:stacked_parameters] = {}
99
101
 
@@ -222,9 +224,23 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
222
224
  result.uniq
223
225
  end
224
226
 
227
+ # Workaround jruby-ldap 0.0.2 missing the #to_hash method
228
+ #
229
+ # @see https://github.com/jruby/jruby-ldap/pull/5
230
+ #
231
+ # @param entry [LDAP::Entry] The LDAP::Entry object to convert to a hash
232
+ # @return [Hash] The hash of the provided LDAP::Entry object with keys
233
+ # downcased (puppet variables need to start with lowercase char)
234
+ def ldap_entry_to_hash(entry)
235
+ h = {}
236
+ entry.get_attributes.each { |a| h[a.downcase.to_sym] = entry[a] }
237
+ h[:dn] = [entry.dn]
238
+ h
239
+ end
240
+
225
241
  def get_parameters_from_entry(entry)
226
242
  stacked_params = stacked_attributes
227
- entry.to_hash.inject({}) do |hash, ary|
243
+ ldap_entry_to_hash(entry).inject({}) do |hash, ary|
228
244
  unless stacked_params.include?(ary[0]) # don't add our stacked parameters to the main param list
229
245
  if ary[1].length == 1
230
246
  hash[ary[0]] = ary[1].shift
@@ -98,7 +98,7 @@ class Puppet::Module
98
98
  @absolute_path_to_manifests = Puppet::FileSystem::PathPattern.absolute(manifests)
99
99
 
100
100
  # i18n initialization for modules
101
- initialize_i18n
101
+ initialize_i18n unless Puppet[:disable_i18n]
102
102
  end
103
103
 
104
104
  # @deprecated The puppetversion module metadata field is no longer used.
@@ -428,22 +428,23 @@ class Puppet::Module
428
428
 
429
429
  locales_path = File.absolute_path('locales', path)
430
430
 
431
- begin
432
- Puppet::GettextConfig.initialize(locales_path, :po)
431
+ if Puppet::GettextConfig.initialize(locales_path, :po)
433
432
  Puppet.debug "#{module_name} initialized for i18n: #{GettextSetup.translation_repositories[module_name]}"
434
- rescue
433
+ elsif Puppet::GettextConfig.gettext_loaded?
435
434
  config_path = File.absolute_path('config.yaml', locales_path)
436
435
  Puppet.debug "Could not find locales configuration file for #{module_name} at #{config_path}. Skipping i18n initialization."
436
+ else
437
+ Puppet.debug "No gettext library found, skipping i18n initialization."
437
438
  end
438
439
  end
439
440
 
440
441
  private
441
442
 
442
443
  def i18n_initialized?(module_name)
443
- begin
444
+ if Puppet::GettextConfig.gettext_loaded?
444
445
  GettextSetup.translation_repositories.has_key? module_name
445
- rescue NameError
446
- # GettextSetup not yet initialized
446
+ else
447
+ # GettextSetup not yet initialized or not found
447
448
  false
448
449
  end
449
450
  end