bolt 1.48.0 → 1.49.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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 006dcb3a880fefec3005eebb9f31126c3dc164c45d90010f5e7d5b6d984556e2
4
- data.tar.gz: eaf4f944a88fba6aa4f1a0bb6fabe227246fa1ca90a63516a60d8db656f05176
3
+ metadata.gz: cf6891d9f3f208d516d962db7af3e26df0b8de95312c465f3cc8add22948730a
4
+ data.tar.gz: d58605a7bff94d170ab8c95f3b9a024eb60173f60d5bda83cd29c5084baa7450
5
5
  SHA512:
6
- metadata.gz: 3fc3a8337bed7f52c5b091a94b388de07514d3dcc0840d1523b1417769e244dfa1840b8a77616170589343ceb451e726121752eb4927db271cda526ad7eb0b0e
7
- data.tar.gz: 617985134dd23308316303222af69da7ca08bf1840b5fb7301a0dc9b609ba0cc1430877b3bf02c7aaa1f2173c1ca20a76dc36594332f0b8f979aa65b5620f449
6
+ metadata.gz: 742d7bd9cf8f7943412e8fbcb363541b787cccfb019e52c913690a00cfe567787fbe16aa20fd5c4a7b0095724f5b5a124c5d4026879c7b3e0f58d342c5c24124
7
+ data.tar.gz: 436bb36efdefc26efc08de99769af0d9912c1a34caaf0e9255950e4738a92b65ebcf05df20a4add6b47a54add18c1757d11643fb426c214ce840d83dbd80fd86
@@ -130,5 +130,9 @@ module Bolt
130
130
  def report
131
131
  @value['report']
132
132
  end
133
+
134
+ def generic_value
135
+ {}
136
+ end
133
137
  end
134
138
  end
data/lib/bolt/cli.rb CHANGED
@@ -277,15 +277,13 @@ module Bolt
277
277
  Bolt::Inventory::ENVIRONMENT_VAR
278
278
  elsif @config.inventoryfile && Bolt::Util.file_stat(@config.inventoryfile)
279
279
  @config.inventoryfile
280
- elsif (inventory_file = @config.default_inventoryfile.find do |file|
281
- begin
282
- Bolt::Util.file_stat(file)
283
- rescue Errno::ENOENT
284
- false
285
- end
286
- end
287
- )
288
- inventory_file
280
+ else
281
+ begin
282
+ Bolt::Util.file_stat(@config.default_inventoryfile)
283
+ @config.default_inventoryfile
284
+ rescue Errno::ENOENT
285
+ nil
286
+ end
289
287
  end
290
288
 
291
289
  inventory_cli_opts = %i[authentication escalation transports].each_with_object([]) do |key, acc|
data/lib/bolt/config.rb CHANGED
@@ -116,7 +116,7 @@ module Bolt
116
116
  def self.from_boltdir(boltdir, overrides = {})
117
117
  data = {
118
118
  filepath: boltdir.config_file,
119
- data: Bolt::Util.read_config_file(nil, [boltdir.config_file], 'config')
119
+ data: Bolt::Util.read_optional_yaml_hash(boltdir.config_file, 'config')
120
120
  }
121
121
 
122
122
  data = load_defaults.push(data).select { |config| config[:data]&.any? }
@@ -129,9 +129,8 @@ module Bolt
129
129
 
130
130
  data = {
131
131
  filepath: boltdir.config_file,
132
- data: Bolt::Util.read_config_file(configfile, [], 'config')
132
+ data: Bolt::Util.read_yaml_hash(configfile, 'config')
133
133
  }
134
-
135
134
  data = load_defaults.push(data).select { |config| config[:data]&.any? }
136
135
 
137
136
  new(boltdir, data, overrides)
@@ -148,8 +147,8 @@ module Bolt
148
147
  end
149
148
  user_path = Pathname.new(File.expand_path(File.join('~', '.puppetlabs', 'etc', 'bolt', 'bolt.yaml')))
150
149
 
151
- [{ filepath: system_path, data: Bolt::Util.read_config_file(nil, [system_path], 'config') },
152
- { filepath: user_path, data: Bolt::Util.read_config_file(nil, [user_path], 'config') }]
150
+ [{ filepath: system_path, data: Bolt::Util.read_optional_yaml_hash(system_path, 'config') },
151
+ { filepath: user_path, data: Bolt::Util.read_optional_yaml_hash(user_path, 'config') }]
153
152
  end
154
153
 
155
154
  def initialize(boltdir, config_data, overrides = {})
@@ -182,7 +181,6 @@ module Bolt
182
181
  end
183
182
 
184
183
  @config_files = config_data.map { |config| config[:filepath] }
185
-
186
184
  config_data = merge_config_data(config_data)
187
185
  update_from_file(config_data)
188
186
 
@@ -376,7 +374,7 @@ module Bolt
376
374
  end
377
375
 
378
376
  def default_inventoryfile
379
- [@boltdir.inventory_file]
377
+ @boltdir.inventory_file
380
378
  end
381
379
 
382
380
  def rerunfile
@@ -52,7 +52,11 @@ module Bolt
52
52
  raise Bolt::ParseError, "Could not parse inventory from $#{ENVIRONMENT_VAR}"
53
53
  end
54
54
  else
55
- data = Bolt::Util.read_config_file(config.inventoryfile, config.default_inventoryfile, 'inventory')
55
+ data = if config.inventoryfile
56
+ Bolt::Util.read_yaml_hash(config.inventoryfile, 'inventory')
57
+ else
58
+ Bolt::Util.read_optional_yaml_hash(config.default_inventoryfile, 'inventory')
59
+ end
56
60
  end
57
61
 
58
62
  inventory = create_version(data, config, plugins)
@@ -143,12 +143,26 @@ module Bolt
143
143
  @uri_obj.port || transport_config['port']
144
144
  end
145
145
 
146
+ # For remote targets, protocol is the value of the URI scheme. For
147
+ # non-remote targets, there is no protocol.
146
148
  def protocol
147
- transport
149
+ if remote?
150
+ @uri_obj.scheme
151
+ end
148
152
  end
149
153
 
154
+ # For remote targets, the transport is always 'remote'. Otherwise, it
155
+ # will be either the URI scheme or set explicitly.
150
156
  def transport
151
- @uri_obj.scheme || transport_config_cache['transport']
157
+ if remote?
158
+ 'remote'
159
+ else
160
+ @uri_obj.scheme || transport_config_cache['transport']
161
+ end
162
+ end
163
+
164
+ def remote?
165
+ @uri_obj.scheme == 'remote' || transport_config_cache['transport'] == 'remote'
152
166
  end
153
167
 
154
168
  def user
data/lib/bolt/target.rb CHANGED
@@ -118,11 +118,11 @@ module Bolt
118
118
  end
119
119
 
120
120
  def transport
121
- inventory_target.protocol
121
+ inventory_target.transport
122
122
  end
123
123
 
124
124
  def protocol
125
- inventory_target.protocol
125
+ inventory_target.protocol || inventory_target.transport
126
126
  end
127
127
 
128
128
  def user
@@ -48,7 +48,7 @@ module Bolt
48
48
  # Cannot batch because arugments differ
49
49
  def run_task(target, task, arguments, options = {})
50
50
  proxy_target = get_proxy(target)
51
- transport = @executor.transport(proxy_target.protocol)
51
+ transport = @executor.transport(proxy_target.transport)
52
52
  arguments = arguments.merge('_target' => target.to_h.reject { |_, v| v.nil? })
53
53
 
54
54
  remote_task = task.remote_instance
@@ -101,11 +101,6 @@ module Bolt
101
101
 
102
102
  require 'net/ssh'
103
103
  require 'net/scp'
104
- begin
105
- require 'net/ssh/krb'
106
- rescue LoadError
107
- logger.debug("Authentication method 'gssapi-with-mic' (Kerberos) is not available.")
108
- end
109
104
 
110
105
  @transport_logger = Logging.logger[Net::SSH]
111
106
  @transport_logger.level = :warn
data/lib/bolt/util.rb CHANGED
@@ -3,32 +3,20 @@
3
3
  module Bolt
4
4
  module Util
5
5
  class << self
6
- def read_config_file(path, default_paths = nil, file_name = 'file')
6
+ def read_yaml_hash(path, file_name)
7
7
  require 'yaml'
8
8
 
9
9
  logger = Logging.logger[self]
10
- path_passed = path
11
- if path.nil? && default_paths
12
- found_default = default_paths.select { |p| File.exist?(p) }
13
- if found_default.size > 1
14
- logger.warn "Found #{file_name}s at #{found_default.join(', ')}, using the first"
15
- end
16
- # Use first found, fall back to first default and try to load even if it didn't exist
17
- path = found_default.first || default_paths.first
18
- end
19
-
20
10
  path = File.expand_path(path)
21
- content = File.open(path, "r:UTF-8") { |f| YAML.safe_load(f.read) }
11
+ content = File.open(path, "r:UTF-8") { |f| YAML.safe_load(f.read) } || {}
12
+ unless content.is_a?(Hash)
13
+ msg = "Invalid content for #{file_name} file: #{path} should be a Hash or empty, not #{content.class}"
14
+ raise Bolt::FileError.new(msg, path)
15
+ end
22
16
  logger.debug("Loaded #{file_name} from #{path}")
23
17
  content
24
18
  rescue Errno::ENOENT
25
- msg = "Could not read #{file_name} file: #{path}"
26
- if path_passed
27
- raise Bolt::FileError.new(msg, path)
28
- else
29
- logger.debug(msg)
30
- nil
31
- end
19
+ raise Bolt::FileError.new("Could not read #{file_name} file: #{path}", path)
32
20
  rescue Psych::Exception => e
33
21
  raise Bolt::FileError.new("Could not parse #{file_name} file: #{path}\n"\
34
22
  "Error at line #{e.line} column #{e.column}", path)
@@ -37,6 +25,10 @@ module Bolt
37
25
  "error: #{e}", path)
38
26
  end
39
27
 
28
+ def read_optional_yaml_hash(path, file_name)
29
+ File.exist?(path) ? read_yaml_hash(path, file_name) : {}
30
+ end
31
+
40
32
  # Accepts a path with either 'plans' or 'tasks' in it and determines
41
33
  # the name of the module
42
34
  def module_name(path)
data/lib/bolt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bolt
4
- VERSION = '1.48.0'
4
+ VERSION = '1.49.0'
5
5
  end
@@ -51,7 +51,10 @@ module BoltServer
51
51
  basemodulepath = plan_executor_config['basemodulepath'] || "#{codedir}/modules:/opt/puppetlabs/puppet/modules"
52
52
 
53
53
  with_pe_pal_init_settings(codedir, environmentpath, basemodulepath) do
54
+ modulepath_dirs = []
55
+ modulepath_setting_from_bolt = nil
54
56
  environment = Puppet.lookup(:environments).get!(environment_name)
57
+ path_to_env = environment.configuration.path_to_env
55
58
 
56
59
  # In the instance where the environment is "production" but no production dir
57
60
  # exists, the lookup will succeed, but the configuration will be mostly empty.
@@ -64,17 +67,28 @@ module BoltServer
64
67
  # environment: _technically_ that environment always exists, but if the dir
65
68
  # isn't there it won't find the module and fail with "plan not found" rather
66
69
  # than "environment doesn't exist"
67
- if environment.configuration.path_to_env
68
- bolt_config = File.join(environment.configuration.path_to_env, 'bolt.yaml')
70
+ if path_to_env
71
+ bolt_yaml = File.join(environment.configuration.path_to_env, 'bolt.yaml')
72
+ modulepath_setting_from_bolt = Bolt::Util.read_optional_yaml_hash(bolt_yaml, 'config')['modulepath']
73
+ end
74
+
75
+ # If we loaded a bolt.yaml in the environment root and it contained a modulepath setting:
76
+ # we will use that modulepath rather than the one loaded through puppet. modulepath will
77
+ # be the _only_ setting that will work from bolt.yaml in plans in PE.
78
+ if modulepath_setting_from_bolt
79
+ modulepath_setting_from_bolt.split(File::PATH_SEPARATOR).each do |path|
80
+ if Pathname.new(path).absolute? && File.exist?(path)
81
+ modulepath_dirs << path
82
+ elsif File.exist?(File.join(path_to_env, path))
83
+ modulepath_dirs << File.join(path_to_env, path)
84
+ end
85
+ end
86
+
87
+ # Append the basemodulepath to include "built-in" modules.
88
+ modulepath_dirs.concat(basemodulepath.split(File::PATH_SEPARATOR))
89
+ else
90
+ modulepath_dirs = environment.modulepath
69
91
  end
70
- # If we find a bolt.yaml config in the environment root, we load that instead of
71
- # environment.conf to find the modulepath. modulepath will be the _only_ setting
72
- # that will work from bolt.yaml in plans in PE.
73
- modulepath_dirs = if bolt_config && File.exist?(bolt_config)
74
- Bolt::Util.read_config_file(bolt_config)['modulepath'].split(File::PATH_SEPARATOR)
75
- else
76
- environment.modulepath
77
- end
78
92
 
79
93
  # A new modulepath is created from scratch (rather than using super's @modulepath)
80
94
  # so that we can have full control over all the entries in modulepath. In the future
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: 1.48.0
4
+ version: 1.49.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-03 00:00:00.000000000 Z
11
+ date: 2020-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '4.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: net-ssh-krb
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.5'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.5'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: orchestrator_client
141
155
  requirement: !ruby/object:Gem::Requirement