bolt 1.14.0 → 1.15.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.

@@ -76,15 +76,7 @@ module Bolt
76
76
  @transport_logger = transport_logger
77
77
  end
78
78
 
79
- if Bolt::Util.windows?
80
- require 'ffi'
81
- module Win
82
- extend FFI::Library
83
- ffi_lib 'user32'
84
- ffi_convention :stdcall
85
- attach_function :FindWindow, :FindWindowW, %i[buffer_in buffer_in], :int
86
- end
87
- end
79
+ PAGEANT_NAME = "Pageant\0".encode(Encoding::UTF_16LE)
88
80
 
89
81
  def connect
90
82
  options = {
@@ -119,6 +111,11 @@ module Bolt
119
111
 
120
112
  options[:proxy] = Net::SSH::Proxy::Jump.new(target.options['proxyjump']) if target.options['proxyjump']
121
113
 
114
+ # This option was to address discrepency betwen net-ssh host-key-check and ssh(1)
115
+ # For the net-ssh 5.x series it defaults to true, in 6.x it will default to false, and will be removed in 7.x
116
+ # https://github.com/net-ssh/net-ssh/pull/663#issuecomment-469979931
117
+ options[:check_host_ip] = false if Net::SSH::VALID_OPTIONS.include?(:check_host_ip)
118
+
122
119
  if @load_config
123
120
  # Mirroring:
124
121
  # https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/authentication/agent.rb#L80
@@ -129,8 +126,10 @@ module Bolt
129
126
  options[:use_agent] = false
130
127
  end
131
128
  elsif Bolt::Util.windows?
132
- pageant_wide = 'Pageant'.encode('UTF-16LE')
133
- if Win.FindWindow(pageant_wide, pageant_wide).to_i == 0
129
+ require 'Win32API' # case matters in this require!
130
+ # https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-findwindoww
131
+ @find_window ||= Win32API.new('user32', 'FindWindowW', %w[P P], 'L')
132
+ if @find_window.call(nil, PAGEANT_NAME).to_i == 0
134
133
  @logger.debug { "Disabling use_agent in net-ssh: pageant process not running" }
135
134
  options[:use_agent] = false
136
135
  end
@@ -85,7 +85,11 @@ module Bolt
85
85
  def run_command(target, command, _options = {})
86
86
  with_connection(target) do |conn|
87
87
  output = conn.execute(command)
88
- Bolt::Result.for_command(target, output.stdout.string, output.stderr.string, output.exit_code)
88
+ Bolt::Result.for_command(target,
89
+ output.stdout.string,
90
+ output.stderr.string,
91
+ output.exit_code,
92
+ 'command', command)
89
93
  end
90
94
  end
91
95
 
@@ -102,7 +106,11 @@ module Bolt
102
106
  args += Powershell.escape_arguments(arguments)
103
107
  output = conn.execute_process(path, args)
104
108
  end
105
- Bolt::Result.for_command(target, output.stdout.string, output.stderr.string, output.exit_code)
109
+ Bolt::Result.for_command(target,
110
+ output.stdout.string,
111
+ output.stderr.string,
112
+ output.exit_code,
113
+ 'script', script)
106
114
  end
107
115
  end
108
116
  end
@@ -163,7 +171,8 @@ module Bolt
163
171
 
164
172
  Bolt::Result.for_task(target, output.stdout.string,
165
173
  output.stderr.string,
166
- output.exit_code)
174
+ output.exit_code,
175
+ task.name)
167
176
  end
168
177
  end
169
178
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'bolt/node/errors'
4
4
  require 'bolt/node/output'
5
- require 'ruby_smb'
6
5
 
7
6
  module Bolt
8
7
  module Transport
@@ -158,6 +157,9 @@ module Bolt
158
157
  end
159
158
 
160
159
  def write_remote_file_smb(source, destination)
160
+ # lazy-load expensive gem code
161
+ require 'ruby_smb'
162
+
161
163
  win_dest = destination.tr('/', '\\')
162
164
  if (md = win_dest.match(/^([a-z]):\\(.*)/i))
163
165
  # if drive, use admin share for that drive, so path is '\\host\C$'
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.14.0'
4
+ VERSION = '1.15.0'
5
5
  end
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'concurrent'
3
+ require 'concurrent/atomic/read_write_lock'
4
+ require 'concurrent/executor/single_thread_executor'
5
+ require 'concurrent/promise'
6
+ require 'concurrent/timer_task'
4
7
  require 'digest'
5
8
  require 'fileutils'
6
9
  require 'net/http'
@@ -4,8 +4,8 @@ require 'sinatra'
4
4
  require 'bolt'
5
5
  require 'bolt/error'
6
6
  require 'bolt/target'
7
- require 'bolt/task/puppet_server'
8
7
  require 'bolt_server/file_cache'
8
+ require 'bolt/task/puppet_server'
9
9
  require 'json'
10
10
  require 'json-schema'
11
11
 
@@ -29,7 +29,7 @@ module BoltSpec
29
29
  end
30
30
 
31
31
  def result_for(target, stdout: '', stderr: '')
32
- Bolt::Result.for_command(target, stdout, stderr, 0)
32
+ Bolt::Result.for_command(target, stdout, stderr, 0, 'command', '')
33
33
  end
34
34
 
35
35
  # Public methods
@@ -35,7 +35,7 @@ module BoltSpec
35
35
  end
36
36
 
37
37
  def result_for(target, stdout: '', stderr: '')
38
- Bolt::Result.for_command(target, stdout, stderr, 0)
38
+ Bolt::Result.for_command(target, stdout, stderr, 0, 'script', '')
39
39
  end
40
40
 
41
41
  # Public methods
data/lib/bolt_spec/run.rb CHANGED
@@ -12,6 +12,14 @@ require 'bolt/util'
12
12
  module BoltSpec
13
13
  module Run
14
14
  def run_task(task_name, targets, params, config: nil, inventory: nil)
15
+ if config.nil? && defined?(bolt_config)
16
+ config = bolt_config
17
+ end
18
+
19
+ if inventory.nil? && defined?(bolt_inventory)
20
+ inventory = bolt_inventory
21
+ end
22
+
15
23
  result = BoltRunner.with_runner(config, inventory) do |runner|
16
24
  runner.run_task(task_name, targets, params)
17
25
  end
@@ -20,6 +28,14 @@ module BoltSpec
20
28
  end
21
29
 
22
30
  def run_plan(plan_name, params, config: nil, inventory: nil)
31
+ if config.nil? && defined?(bolt_config)
32
+ config = bolt_config
33
+ end
34
+
35
+ if inventory.nil? && defined?(bolt_inventory)
36
+ inventory = bolt_inventory
37
+ end
38
+
23
39
  # Users copying code from run_task may forget that targets is not a parameter for run plan
24
40
  raise ArgumentError, "params must be a hash" unless params.is_a?(Hash)
25
41
 
@@ -32,6 +48,14 @@ module BoltSpec
32
48
  end
33
49
 
34
50
  def run_command(command, targets, options: {}, config: nil, inventory: nil)
51
+ if config.nil? && defined?(bolt_config)
52
+ config = bolt_config
53
+ end
54
+
55
+ if inventory.nil? && defined?(bolt_inventory)
56
+ inventory = bolt_inventory
57
+ end
58
+
35
59
  result = BoltRunner.with_runner(config, inventory) do |runner|
36
60
  runner.run_command(command, targets, options)
37
61
  end
@@ -40,6 +64,14 @@ module BoltSpec
40
64
  end
41
65
 
42
66
  def run_script(script, targets, arguments, options: {}, config: nil, inventory: nil)
67
+ if config.nil? && defined?(bolt_config)
68
+ config = bolt_config
69
+ end
70
+
71
+ if inventory.nil? && defined?(bolt_inventory)
72
+ inventory = bolt_inventory
73
+ end
74
+
43
75
  result = BoltRunner.with_runner(config, inventory) do |runner|
44
76
  runner.run_script(script, targets, arguments, options)
45
77
  end
@@ -47,7 +79,31 @@ module BoltSpec
47
79
  Bolt::Util.walk_keys(result, &:to_s)
48
80
  end
49
81
 
82
+ def upload_file(source, dest, targets, options: {}, config: nil, inventory: nil)
83
+ if config.nil? && defined?(bolt_config)
84
+ config = bolt_config
85
+ end
86
+
87
+ if inventory.nil? && defined?(bolt_inventory)
88
+ inventory = bolt_inventory
89
+ end
90
+
91
+ result = BoltRunner.with_runner(config, inventory) do |runner|
92
+ runner.upload_file(source, dest, targets, options)
93
+ end
94
+ result = result.to_a
95
+ Bolt::Util.walk_keys(result, &:to_s)
96
+ end
97
+
50
98
  def apply_manifest(manifest, targets, execute: false, noop: false, config: nil, inventory: nil)
99
+ if config.nil? && defined?(bolt_config)
100
+ config = bolt_config
101
+ end
102
+
103
+ if inventory.nil? && defined?(bolt_inventory)
104
+ inventory = bolt_inventory
105
+ end
106
+
51
107
  # The execute parameter is equivalent to the --execute option
52
108
  if execute
53
109
  code = manifest
@@ -127,6 +183,12 @@ module BoltSpec
127
183
  executor.run_script(targets, script, arguments, options)
128
184
  end
129
185
 
186
+ def upload_file(source, dest, targets, options = {})
187
+ executor = Bolt::Executor.new(config.concurrency, @analytics)
188
+ targets = inventory.get_targets(targets)
189
+ executor.upload_file(targets, source, dest, options)
190
+ end
191
+
130
192
  def apply_manifest(code, targets, filename = nil, noop = false)
131
193
  ast = pal.parse_manifest(code, filename)
132
194
  executor = Bolt::Executor.new(config.concurrency, @analytics, noop)
@@ -9,7 +9,6 @@ require 'bolt/puppetdb'
9
9
  require 'bolt/version'
10
10
  require 'plan_executor/applicator'
11
11
  require 'plan_executor/executor'
12
- require 'concurrent'
13
12
  require 'json'
14
13
  require 'json-schema'
15
14
 
@@ -28,6 +27,9 @@ module PlanExecutor
28
27
  end
29
28
 
30
29
  def initialize(config)
30
+ # lazy-load expensive gem code
31
+ require 'concurrent'
32
+
31
33
  @http_client = create_http(config)
32
34
 
33
35
  # Use an empty inventory until we figure out where this data comes from.
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.14.0
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-15 00:00:00.000000000 Z
11
+ date: 2019-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -142,7 +142,7 @@ dependencies:
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: 6.0.1
145
+ version: 6.4.0
146
146
  - - "<"
147
147
  - !ruby/object:Gem::Version
148
148
  version: '7'
@@ -152,7 +152,7 @@ dependencies:
152
152
  requirements:
153
153
  - - ">="
154
154
  - !ruby/object:Gem::Version
155
- version: 6.0.1
155
+ version: 6.4.0
156
156
  - - "<"
157
157
  - !ruby/object:Gem::Version
158
158
  version: '7'
@@ -361,6 +361,9 @@ files:
361
361
  - lib/bolt/pal.rb
362
362
  - lib/bolt/pal/issues.rb
363
363
  - lib/bolt/pal/logging.rb
364
+ - lib/bolt/pal/yaml_plan.rb
365
+ - lib/bolt/pal/yaml_plan/evaluator.rb
366
+ - lib/bolt/pal/yaml_plan/loader.rb
364
367
  - lib/bolt/plan_result.rb
365
368
  - lib/bolt/puppetdb.rb
366
369
  - lib/bolt/puppetdb/client.rb
@@ -371,7 +374,6 @@ files:
371
374
  - lib/bolt/target.rb
372
375
  - lib/bolt/task.rb
373
376
  - lib/bolt/task/puppet_server.rb
374
- - lib/bolt/task/remote.rb
375
377
  - lib/bolt/transport/base.rb
376
378
  - lib/bolt/transport/docker.rb
377
379
  - lib/bolt/transport/docker/connection.rb
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bolt/task'
4
-
5
- module Bolt
6
- class Task
7
- class Remote < Task
8
- def self.from_task(task)
9
- new(task.name, task.file, task.files, task.metadata)
10
- end
11
-
12
- def implementations
13
- metadata['implementations']&.select { |i| i['remote'] || metadata['remote'] }
14
- end
15
-
16
- def select_implementation(target, *args)
17
- unless implementations || metadata['remote']
18
- raise NoImplementationError.new(target, self)
19
- end
20
-
21
- super(target, *args)
22
- end
23
- end
24
- end
25
- end