vagrant-bolt 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +0 -8
- data/.travis.yml +2 -2
- data/CHANGELOG.md +66 -0
- data/Gemfile +5 -3
- data/Puppetfile +0 -2
- data/README.md +36 -24
- data/acceptance/components/bolt_spec.rb +11 -11
- data/acceptance/skeletons/advanced/Vagrantfile +1 -1
- data/acceptance/skeletons/base/Vagrantfile +1 -0
- data/lib/vagrant-bolt/command.rb +2 -5
- data/lib/vagrant-bolt/config/bolt.rb +29 -22
- data/lib/vagrant-bolt/config/global.rb +68 -38
- data/lib/vagrant-bolt/config_builder/config.rb +61 -31
- data/lib/vagrant-bolt/config_builder/monkey_patches.rb +1 -1
- data/lib/vagrant-bolt/config_builder/provisioner.rb +28 -4
- data/lib/vagrant-bolt/runner.rb +10 -10
- data/lib/vagrant-bolt/util/bolt.rb +8 -7
- data/lib/vagrant-bolt/util/config.rb +15 -2
- data/lib/vagrant-bolt/util/machine.rb +1 -1
- data/lib/vagrant-bolt/version.rb +1 -1
- data/spec/unit/config/bolt_spec.rb +4 -0
- data/spec/unit/config/global_spec.rb +7 -2
- data/spec/unit/runner/runner_spec.rb +32 -17
- data/spec/unit/util/bolt_spec.rb +10 -5
- data/tasks/changelog.rake +8 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5db77647479d994addb8c0d44266d5408001a0035f7d57d913107f88c1290a07
|
4
|
+
data.tar.gz: 5ede9d54e55e4401133fa1ede70d62bf7e9ab6aef4805a9533bc0b106cea7cee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90a889e58965672e19a4b4fdd5e667fe05ace1d96d401481e9c73cfba89cc26e284c557a530902b38b97a8bb1cb68f45e163ffd2ecc3094380c309fe4d38920b
|
7
|
+
data.tar.gz: d25d14d296e07fcf22d8a75612e37525495a4e33d2b2f031b804e9d1ac2e28ab0e82c2bd0352329d4a6cc421a7e22be505d842b0e90d3d804cd207f0659a3d8d
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -96,14 +96,6 @@ Metrics/CyclomaticComplexity:
|
|
96
96
|
Enabled: false
|
97
97
|
Metrics/PerceivedComplexity:
|
98
98
|
Enabled: false
|
99
|
-
Metrics/MethodLength:
|
100
|
-
Enabled: true
|
101
|
-
ExcludedMethods:
|
102
|
-
- initialize
|
103
|
-
- finalize!
|
104
|
-
- validate
|
105
|
-
- to_proc
|
106
|
-
Max: 25
|
107
99
|
Metrics/ClassLength:
|
108
100
|
Enabled: false
|
109
101
|
Metrics/ModuleLength:
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [v0.3.0](https://github.com/oscar-stack/vagrant-bolt/tree/v0.3.0) (2020-06-02)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/oscar-stack/vagrant-bolt/compare/v0.2.1...v0.3.0)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- Update inventory naming [\#16](https://github.com/oscar-stack/vagrant-bolt/pull/16) ([jarretlavallee](https://github.com/jarretlavallee))
|
10
|
+
|
11
|
+
## [v0.2.1](https://github.com/oscar-stack/vagrant-bolt/tree/v0.2.1) (2020-03-23)
|
12
|
+
|
13
|
+
[Full Changelog](https://github.com/oscar-stack/vagrant-bolt/compare/v0.2.0...v0.2.1)
|
14
|
+
|
15
|
+
**Closed issues:**
|
16
|
+
|
17
|
+
- Replace bolt argument nodes with targets [\#13](https://github.com/oscar-stack/vagrant-bolt/issues/13)
|
18
|
+
|
19
|
+
**Merged pull requests:**
|
20
|
+
|
21
|
+
- Fix config builder role filtering [\#15](https://github.com/oscar-stack/vagrant-bolt/pull/15) ([jarretlavallee](https://github.com/jarretlavallee))
|
22
|
+
|
23
|
+
## [v0.2.0](https://github.com/oscar-stack/vagrant-bolt/tree/v0.2.0) (2020-02-26)
|
24
|
+
|
25
|
+
[Full Changelog](https://github.com/oscar-stack/vagrant-bolt/compare/v0.1.2...v0.2.0)
|
26
|
+
|
27
|
+
**Merged pull requests:**
|
28
|
+
|
29
|
+
- Change nodes to targets in config [\#14](https://github.com/oscar-stack/vagrant-bolt/pull/14) ([jarretlavallee](https://github.com/jarretlavallee))
|
30
|
+
- Update to Bolt inventory v2 [\#12](https://github.com/oscar-stack/vagrant-bolt/pull/12) ([jarretlavallee](https://github.com/jarretlavallee))
|
31
|
+
|
32
|
+
## [v0.1.2](https://github.com/oscar-stack/vagrant-bolt/tree/v0.1.2) (2019-10-17)
|
33
|
+
|
34
|
+
[Full Changelog](https://github.com/oscar-stack/vagrant-bolt/compare/v0.1.1...v0.1.2)
|
35
|
+
|
36
|
+
**Merged pull requests:**
|
37
|
+
|
38
|
+
- Fix the bolt path issue and create a release [\#11](https://github.com/oscar-stack/vagrant-bolt/pull/11) ([jarretlavallee](https://github.com/jarretlavallee))
|
39
|
+
- Fix changelog version tag [\#10](https://github.com/oscar-stack/vagrant-bolt/pull/10) ([jarretlavallee](https://github.com/jarretlavallee))
|
40
|
+
|
41
|
+
## [v0.1.1](https://github.com/oscar-stack/vagrant-bolt/tree/v0.1.1) (2019-07-01)
|
42
|
+
|
43
|
+
[Full Changelog](https://github.com/oscar-stack/vagrant-bolt/compare/v0.1.0...v0.1.1)
|
44
|
+
|
45
|
+
**Merged pull requests:**
|
46
|
+
|
47
|
+
- Add changelog generation [\#9](https://github.com/oscar-stack/vagrant-bolt/pull/9) ([jarretlavallee](https://github.com/jarretlavallee))
|
48
|
+
- Clean up command line arguments and paths [\#8](https://github.com/oscar-stack/vagrant-bolt/pull/8) ([jarretlavallee](https://github.com/jarretlavallee))
|
49
|
+
- Add connect\_timeout option to inventory [\#7](https://github.com/oscar-stack/vagrant-bolt/pull/7) ([jarretlavallee](https://github.com/jarretlavallee))
|
50
|
+
|
51
|
+
## [v0.1.0](https://github.com/oscar-stack/vagrant-bolt/tree/v0.1.0) (2018-12-11)
|
52
|
+
|
53
|
+
[Full Changelog](https://github.com/oscar-stack/vagrant-bolt/compare/4574482459a0f320bb6b25557199a1612b19ea72...v0.1.0)
|
54
|
+
|
55
|
+
**Merged pull requests:**
|
56
|
+
|
57
|
+
- \(SUP-874\) Add a command line interface [\#6](https://github.com/oscar-stack/vagrant-bolt/pull/6) ([jarretlavallee](https://github.com/jarretlavallee))
|
58
|
+
- Add Support for config\_builder bolt triggers [\#5](https://github.com/oscar-stack/vagrant-bolt/pull/5) ([jarretlavallee](https://github.com/jarretlavallee))
|
59
|
+
- Add Config Options and cleanup some bad code [\#4](https://github.com/oscar-stack/vagrant-bolt/pull/4) ([jarretlavallee](https://github.com/jarretlavallee))
|
60
|
+
- Consolidate files and add some spec tests [\#3](https://github.com/oscar-stack/vagrant-bolt/pull/3) ([jarretlavallee](https://github.com/jarretlavallee))
|
61
|
+
- Add the ability to use triggers and provisioners [\#2](https://github.com/oscar-stack/vagrant-bolt/pull/2) ([jarretlavallee](https://github.com/jarretlavallee))
|
62
|
+
- Initial Implementation [\#1](https://github.com/oscar-stack/vagrant-bolt/pull/1) ([jarretlavallee](https://github.com/jarretlavallee))
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
require 'rubygems/version'
|
5
5
|
|
6
|
-
vagrant_branch = ENV['TEST_VAGRANT_VERSION'] || 'v2.2.
|
6
|
+
vagrant_branch = ENV['TEST_VAGRANT_VERSION'] || 'v2.2.9'
|
7
7
|
|
8
8
|
group :plugins do
|
9
9
|
gemspec
|
@@ -15,6 +15,7 @@ group :development do
|
|
15
15
|
gem 'rubocop'
|
16
16
|
gem 'rubocop-rspec'
|
17
17
|
gem 'yard', '~> 0.9.16'
|
18
|
+
gem 'github_changelog_generator'
|
18
19
|
end
|
19
20
|
|
20
21
|
group :test do
|
@@ -26,11 +27,12 @@ group :test do
|
|
26
27
|
tag: vagrant_branch
|
27
28
|
end
|
28
29
|
|
29
|
-
gem 'vagrant-spec', git: 'https://github.com/hashicorp/vagrant-spec.git'
|
30
|
+
gem 'vagrant-spec', git: 'https://github.com/hashicorp/vagrant-spec.git',
|
31
|
+
branch: 'master'
|
30
32
|
end
|
31
33
|
|
32
34
|
group :system_tests do
|
33
|
-
gem 'bolt', "
|
35
|
+
gem 'bolt', "~> 2.0.0"
|
34
36
|
end
|
35
37
|
|
36
38
|
|
data/Puppetfile
CHANGED
data/README.md
CHANGED
@@ -166,7 +166,7 @@ The methods for a bolt command in a trigger allow for a task, plan, or command.
|
|
166
166
|
* Required: `machine` The machine object
|
167
167
|
* Optional: `**args` A hash of [Plugin Settings](#plugin-settings) which override any previous config
|
168
168
|
|
169
|
-
|
169
|
+
An example of the arguments can be seen below.
|
170
170
|
|
171
171
|
Run the `facts` task using a specific user and password.
|
172
172
|
|
@@ -177,13 +177,13 @@ VagrantBolt.task('facts', env, machine, user: 'ubuntu', password: 'testpassword'
|
|
177
177
|
Run the `facts` plan on `server1` and `server2`.
|
178
178
|
|
179
179
|
~~~ruby
|
180
|
-
VagrantBolt.plan('facts', env, machine,
|
180
|
+
VagrantBolt.plan('facts', env, machine, targets: [:server1, :server2])
|
181
181
|
~~~
|
182
182
|
|
183
|
-
Run the `hostname` command on all
|
183
|
+
Run the `hostname` command on all targets.
|
184
184
|
|
185
185
|
~~~ruby
|
186
|
-
VagrantBolt.command('/bin/hostname', env, machine,
|
186
|
+
VagrantBolt.command('/bin/hostname', env, machine, targets: 'all')
|
187
187
|
~~~
|
188
188
|
|
189
189
|
Run the `service::linux` task as `root` to restart `cron` with a specific path to the bolt executable. This configuration specifies params for the `service::linux` task.
|
@@ -194,7 +194,7 @@ VagrantBolt.task(
|
|
194
194
|
env,
|
195
195
|
machine,
|
196
196
|
run_as: 'root',
|
197
|
-
bolt_exe: '/
|
197
|
+
bolt_exe: '/opt/puppetlabs/bin/bolt',
|
198
198
|
params: { name: "cron", action: "restart" },
|
199
199
|
)
|
200
200
|
~~~
|
@@ -216,24 +216,24 @@ The settings available in the triggers and the provisioner are the same.
|
|
216
216
|
|
217
217
|
* `bolt_exe`
|
218
218
|
* Description: A string containing the full path to the bolt executable
|
219
|
-
* Default: `bolt`
|
219
|
+
* Default: `/opt/puppetlabs/bin/bolt` if it exists, else the first `bolt` in the PATH
|
220
220
|
* `boltdir`
|
221
221
|
* Description: A string containing the bolt working directory
|
222
222
|
* Default: The vagrant root
|
223
|
-
* `
|
224
|
-
* Description: A string containing bolt
|
225
|
-
* This will override `
|
226
|
-
* Default: `%{protocol}://%{ssh_ip}:%{ssh_port}` if `
|
227
|
-
* `
|
223
|
+
* `target_list`
|
224
|
+
* Description: A string containing bolt target list in URI format
|
225
|
+
* This will override `targets` and `excludes`
|
226
|
+
* Default: `%{protocol}://%{ssh_ip}:%{ssh_port}` if `targets` is not specified
|
227
|
+
* `targets`
|
228
228
|
* Description: An array of machine names to run the task or plan on
|
229
|
-
* The `
|
229
|
+
* The `target_list` will override this setting.
|
230
230
|
* A special `ALL` string can be used instead of an array to use all active machines in the environment
|
231
231
|
* Valid Values: An array of machine symbols or the string "ALL"
|
232
232
|
* Default: `[]`
|
233
233
|
* `excludes`
|
234
234
|
* Description: An array of machine names to not run the task on
|
235
|
-
* The `
|
236
|
-
* This setting will take precidence over `
|
235
|
+
* The `target_list` will override this setting.
|
236
|
+
* This setting will take precidence over `targets`
|
237
237
|
* Valid Values: An array of machine symbols
|
238
238
|
* Default: `[]`
|
239
239
|
* `params`
|
@@ -248,6 +248,8 @@ The settings available in the triggers and the provisioner are the same.
|
|
248
248
|
* Default: The port that vagrant uses to connect to the machine
|
249
249
|
* `sudo_password`
|
250
250
|
* Description: A string containing the password bolt will use to escalate privileges on the machine
|
251
|
+
* `connect_timeout`
|
252
|
+
* Description: A string which controls if the connection timeout for ssh (linux)
|
251
253
|
* `host_key_check`
|
252
254
|
* Description: A boolean which controls if the connection should check the host key on the remote host (linux)
|
253
255
|
* Default: `false`
|
@@ -258,9 +260,12 @@ The settings available in the triggers and the provisioner are the same.
|
|
258
260
|
* Description: A boolean which controls if the connection should use SSL on with WinRM (Windows)
|
259
261
|
* `ssl_verify`
|
260
262
|
* Description: A boolean which controls if the connection should verify SSL on with WinRM (Windows)
|
263
|
+
* `machine_alias`
|
264
|
+
* Description: A string to use as the machine's alias in the bolt inventory file. Defaults to nil unless `machine_name` is configured in which case it defaults to the machine name.
|
265
|
+
* `machine_name`
|
266
|
+
* Description: A string to use as the machine's name in the bolt inventory file. Defaults to the machine name.
|
261
267
|
* `modulepath`
|
262
268
|
* Description: A string containing the path to bolt modules
|
263
|
-
* Default: `modules` in the vagrant root
|
264
269
|
* `tmpdir`
|
265
270
|
* Description: A string containing the directory to upload and execute temporary files on the target
|
266
271
|
* `verbose`
|
@@ -276,7 +281,14 @@ The settings available in the triggers and the provisioner are the same.
|
|
276
281
|
* `vars`
|
277
282
|
* Description: A hash containing arbitrary data that may be passed to run_* functions or used for logic in plans
|
278
283
|
* `facts`
|
279
|
-
* Description: A hash containing observed information about the
|
284
|
+
* Description: A hash containing observed information about the target including what can be collected by Facter
|
285
|
+
|
286
|
+
**Deprecated Parameters**
|
287
|
+
|
288
|
+
* `node_list`
|
289
|
+
* Replaced by `target_list`
|
290
|
+
* `nodes`
|
291
|
+
* Replaced by `targets`
|
280
292
|
|
281
293
|
Config Builder
|
282
294
|
--------------
|
@@ -311,10 +323,10 @@ vms:
|
|
311
323
|
|
312
324
|
### Trigger Configuration
|
313
325
|
|
314
|
-
Bolt triggers cab be configured at the root or within a VM object. To configure a bolt trigger a few additional params are required.
|
326
|
+
Bolt triggers cab be configured at the root or within a VM object. To configure a bolt trigger a few additional params are required.
|
315
327
|
|
316
328
|
* `trigger_type`
|
317
|
-
* Description: A symbol of the trigger type.
|
329
|
+
* Description: A symbol of the trigger type.
|
318
330
|
* Valid Values: `:before` or `:after`
|
319
331
|
* `trigger_commands`
|
320
332
|
* Description: An array of symbols for the commands to run the trigger on
|
@@ -366,13 +378,13 @@ Options:
|
|
366
378
|
-u, --[no-]updateinventory Update the inventory file (defaults to false)
|
367
379
|
~~~
|
368
380
|
|
369
|
-
The command can be used to deploy the Puppetfile, for example.
|
381
|
+
The command can be used to deploy the Puppetfile, for example.
|
370
382
|
|
371
383
|
~~~shell
|
372
384
|
vagrant bolt puppetfile install
|
373
385
|
~~~
|
374
386
|
|
375
|
-
It can be used to run ad-hoc tasks on a
|
387
|
+
It can be used to run ad-hoc tasks on a target by specifying the target by its machine name.
|
376
388
|
|
377
389
|
~~~shell
|
378
390
|
vagrant bolt -u task run facts -n server
|
@@ -380,7 +392,7 @@ vagrant bolt -u task run facts -n server
|
|
380
392
|
|
381
393
|
The `--updateinventory` flag will regenerate the inventory file from the active running machines, however it defaults to being off. In the example above, the inventory file will be updated prior to running the task.
|
382
394
|
|
383
|
-
All arguments except for the `-u` will be passed to bolt, so a bolt command like the
|
395
|
+
All arguments except for the `-u` will be passed to bolt, so a bolt command like the example below can be run.
|
384
396
|
|
385
397
|
~~~shell
|
386
398
|
vagrant bolt command run 'date' -n agent,master
|
@@ -389,7 +401,7 @@ vagrant bolt command run 'date' -n agent,master
|
|
389
401
|
Other Use Cases
|
390
402
|
---------------
|
391
403
|
|
392
|
-
There are some other use cases for Vagrant Bolt. One of which is to not use the triggers or provisioning to run bolt commands on the
|
404
|
+
There are some other use cases for Vagrant Bolt. One of which is to not use the triggers or provisioning to run bolt commands on the targets, but to manage the inventory file for manual testing. This can easily be accomplished by using a trigger to manage the `inventory.yaml` file and specifying the configuration for the targets in the config based on the options above. Below is an example trigger that will manage a `./inventory.yaml` file for use with external bolt commands.
|
393
405
|
|
394
406
|
~~~ruby
|
395
407
|
require 'vagrant-bolt'
|
@@ -422,10 +434,10 @@ Requirements
|
|
422
434
|
------------
|
423
435
|
|
424
436
|
* Vagrant 2.2.0+ is required for this plugin.
|
425
|
-
* Bolt 1.
|
437
|
+
* Bolt 1.10+ needs to be installed on the platform machine and accessible on the path. Use the `bolt_exe` config parameter if it is not on the path.
|
426
438
|
* Ruby 2.3+
|
427
439
|
|
428
440
|
Known Issues
|
429
441
|
------------
|
430
442
|
|
431
|
-
* Machine names with hyphens in them are not valid
|
443
|
+
* Machine names with hyphens in them are not valid until bolt 1.10.0. Please upgrade to Bolt 1.10.0+ to use hyphens in the machine names.
|
@@ -24,7 +24,7 @@ shared_examples 'provider/virtualbox' do |provider, options|
|
|
24
24
|
expect(@result.stdout).to match(%r{Bolt: Running bolt command locally: \/[^\ ]+bolt task run 'facts'})
|
25
25
|
expect(@result.stdout).to match(%r{Bolt: Running bolt command locally: \/[^\ ]+bolt plan run 'facts'})
|
26
26
|
expect(@result.stdout).to match(%r{Bolt: Running bolt command locally: \/[^\ ]+bolt command run})
|
27
|
-
expect(@result.stdout.scan(%r{Successful on 1
|
27
|
+
expect(@result.stdout.scan(%r{Successful on 1 target}).size).to eq(3)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -39,7 +39,7 @@ shared_examples 'provider/virtualbox' do |provider, options|
|
|
39
39
|
expect(@result.stdout).to match(%r{Bolt: Running bolt command locally: \/[^\ ]+bolt task run 'facts'})
|
40
40
|
expect(@result.stdout).to match(%r{Bolt: Running bolt command locally: \/[^\ ]+bolt plan run 'facts'})
|
41
41
|
expect(@result.stdout).to match(%r{Bolt: Running bolt command locally: \/[^\ ]+bolt command run})
|
42
|
-
expect(@result.stdout.scan(%r{Successful on 1
|
42
|
+
expect(@result.stdout.scan(%r{Successful on 1 target}).size).to eq(3)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -50,18 +50,18 @@ shared_examples 'provider/virtualbox' do |provider, options|
|
|
50
50
|
|
51
51
|
it 'runs a task, plan, and command' do
|
52
52
|
expect(@result.exit_code).to eq(0)
|
53
|
-
result = assert_execute('vagrant', 'bolt', 'task', 'run', 'facts', '-
|
53
|
+
result = assert_execute('vagrant', 'bolt', 'task', 'run', 'facts', '-t', 'server')
|
54
54
|
expect(result.exit_code).to eq(0)
|
55
55
|
expect(result.stdout).to match(%r{Bolt: Running bolt command locally: '\/[^\ ]+bolt' 'task' 'run' 'facts'})
|
56
|
-
expect(result.stdout.scan(%r{Successful on 1
|
57
|
-
result = assert_execute('vagrant', 'bolt', 'plan', 'run', 'facts', '-
|
56
|
+
expect(result.stdout.scan(%r{Successful on 1 target}).size).to eq(1)
|
57
|
+
result = assert_execute('vagrant', 'bolt', 'plan', 'run', 'facts', '-t', 'server')
|
58
58
|
expect(result.exit_code).to eq(0)
|
59
59
|
expect(result.stdout).to match(%r{Bolt: Running bolt command locally: '\/[^\ ]+bolt' 'plan' 'run' 'facts'})
|
60
|
-
expect(result.stdout.scan(%r{Successful on 1
|
61
|
-
result = assert_execute('vagrant', 'bolt', 'command', 'run', 'hostname', '-
|
60
|
+
expect(result.stdout.scan(%r{Successful on 1 target}).size).to eq(1)
|
61
|
+
result = assert_execute('vagrant', 'bolt', 'command', 'run', 'hostname', '-t', 'server')
|
62
62
|
expect(result.exit_code).to eq(0)
|
63
63
|
expect(result.stdout).to match(%r{Bolt: Running bolt command locally: '\/[^\ ]+bolt' 'command' 'run'})
|
64
|
-
expect(result.stdout.scan(%r{Successful on 1
|
64
|
+
expect(result.stdout.scan(%r{Successful on 1 target}).size).to eq(1)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -79,14 +79,14 @@ shared_examples 'provider/virtualbox' do |provider, options|
|
|
79
79
|
# Check for root level triggers
|
80
80
|
result = assert_execute('vagrant', 'provision')
|
81
81
|
expect(result.exit_code).to eq(0)
|
82
|
-
# Ensure that the trigger is run on both
|
82
|
+
# Ensure that the trigger is run on both targets
|
83
83
|
expect(result.stdout.scan(%r{server[12]:\s+allnodetest}).size).to eq(4)
|
84
|
-
# Ensure that '
|
84
|
+
# Ensure that 'targets = all' includes both targets
|
85
85
|
expect(result.stdout).to match(%r{Bolt: Running bolt command locally: \/[^\ ]+bolt command run[^\n]+allnodetest[^\n]+server[12],server[12]})
|
86
86
|
# Ensure that the root level `run_as` is used
|
87
87
|
expect(result.stdout).to match(%r{Bolt: Running bolt command locally: \/[^\ ]+bolt command run[^\n]+allnodetest[^\n]+--run-as 'root'})
|
88
88
|
## Configtest
|
89
|
-
# Ensure excludes overrides
|
89
|
+
# Ensure excludes overrides targets
|
90
90
|
expect(result.stdout).to match(%r{Bolt: Running bolt command locally: \/[^\ ]+bolt command run[^\n]+configtest[^\n]+server2})
|
91
91
|
# Ensure verbose and debug flags are correctly handled
|
92
92
|
expect(result.stdout).to match(%r{Bolt: Running bolt command locally: \/[^\ ]+bolt command run[^\n]+configtest[^\n]+--verbose})
|
@@ -6,7 +6,7 @@ Vagrant.configure('2') do |config|
|
|
6
6
|
# Run a trigger on all nodes after provision
|
7
7
|
config.trigger.after :provision do |trigger|
|
8
8
|
trigger.ruby do |env, machine|
|
9
|
-
VagrantBolt.command('/bin/echo "allnodetest"', env, machine,
|
9
|
+
VagrantBolt.command('/bin/echo "allnodetest"', env, machine, targets: 'all')
|
10
10
|
end
|
11
11
|
end
|
12
12
|
config.vm.define 'server1' do |node|
|
data/lib/vagrant-bolt/command.rb
CHANGED
@@ -42,20 +42,17 @@ class VagrantBolt::Command < Vagrant.plugin('2', :command)
|
|
42
42
|
execute_bolt_command(bolt_args)
|
43
43
|
end
|
44
44
|
|
45
|
-
# Run a bolt command with the inventory path,
|
45
|
+
# Run a bolt command with the inventory path, and boltdir
|
46
46
|
# @param args [Array<String>] An array containing the bolt arguments
|
47
47
|
def execute_bolt_command(args)
|
48
48
|
bolt_exe = @env.vagrantfile.config.bolt.bolt_exe
|
49
|
-
|
50
|
-
boltdir = VagrantBolt::Util::Config.full_path(@env.vagrantfile.config.bolt.boltdir, @env.root_path)
|
49
|
+
boltdir = VagrantBolt::Util::Config.relative_path(@env.vagrantfile.config.bolt.boltdir, @env.root_path)
|
51
50
|
inventoryfile = VagrantBolt::Util::Bolt.inventory_file(@env)
|
52
51
|
|
53
52
|
quoted_args = args.flatten.compact.map { |a| "'#{a}'" }
|
54
53
|
command = [
|
55
54
|
"\'#{bolt_exe}\'",
|
56
55
|
quoted_args,
|
57
|
-
'--modulepath',
|
58
|
-
"\'#{modulepath}\'",
|
59
56
|
'--boltdir',
|
60
57
|
"\'#{boltdir}\'",
|
61
58
|
]
|
@@ -10,6 +10,7 @@ class VagrantBolt::Config::Bolt < VagrantBolt::Config::Global
|
|
10
10
|
attr_accessor :name
|
11
11
|
|
12
12
|
# @!attribute [rw] nodes
|
13
|
+
# DEPRECATED. Use `targets` instead.
|
13
14
|
# Note: The `node_list` will override this setting.
|
14
15
|
# @return [Array<String, Symbol>, "ALL"] The nodes to run the task or plan on.
|
15
16
|
# Valid values are an array of machine names or the string "ALL".
|
@@ -17,14 +18,15 @@ class VagrantBolt::Config::Bolt < VagrantBolt::Config::Global
|
|
17
18
|
|
18
19
|
# @!attribute [rw] excludes
|
19
20
|
# Note: The `node_list` will override this setting.
|
20
|
-
# Note: This will be merged with `
|
21
|
-
# @return [Array<String, Symbol>] The
|
21
|
+
# Note: This will be merged with `targets`, with `excludes` taking precidence.
|
22
|
+
# @return [Array<String, Symbol>] The targets to exclude from running this task or plan on.
|
22
23
|
# Valid values are an array of machine names.
|
23
24
|
attr_accessor :excludes
|
24
25
|
|
25
26
|
# @!attribute [rw] node_list
|
27
|
+
# DEPRECATED. Use `target_list` instead.
|
26
28
|
# This setting overrides `nodes` and needs to be in the `protocol://ipaddress:port` URI format.
|
27
|
-
# @return [String] The bolt node list. This defaults to the currnet
|
29
|
+
# @return [String] The bolt node list. This defaults to the currnet machine.
|
28
30
|
attr_accessor :node_list
|
29
31
|
|
30
32
|
# @!attribute [rw] params
|
@@ -39,6 +41,17 @@ class VagrantBolt::Config::Bolt < VagrantBolt::Config::Global
|
|
39
41
|
# @return [Boolean] If the command should be run with noop. Only valid with tasks and apply.
|
40
42
|
attr_accessor :noop
|
41
43
|
|
44
|
+
# @!attribute [rw] targets
|
45
|
+
# Note: The `target_list` will override this setting.
|
46
|
+
# @return [Array<String, Symbol>, "ALL"] The targets to run the task or plan on.
|
47
|
+
# Valid values are an array of machine names or the string "ALL".
|
48
|
+
attr_accessor :targets
|
49
|
+
|
50
|
+
# @!attribute [rw] target_list
|
51
|
+
# This setting overrides `targets` and needs to be in the `protocol://ipaddress:port` URI format.
|
52
|
+
# @return [String] The bolt target list. This defaults to the currnet machine.
|
53
|
+
attr_accessor :target_list
|
54
|
+
|
42
55
|
def initialize
|
43
56
|
super
|
44
57
|
@args = UNSET_VALUE
|
@@ -48,40 +61,32 @@ class VagrantBolt::Config::Bolt < VagrantBolt::Config::Global
|
|
48
61
|
@node_list = UNSET_VALUE
|
49
62
|
@params = UNSET_VALUE
|
50
63
|
@command = UNSET_VALUE
|
64
|
+
@targets = []
|
65
|
+
@target_list = UNSET_VALUE
|
51
66
|
end
|
52
67
|
|
53
68
|
def finalize!
|
54
69
|
@bolt_exe = nil if @bolt_exe == UNSET_VALUE
|
55
70
|
@boltdir = nil if @boltdir == UNSET_VALUE
|
56
|
-
|
57
|
-
@modulepath = nil if @modulepath == UNSET_VALUE
|
58
|
-
@port = nil if @port == UNSET_VALUE
|
59
|
-
@password = nil if @password == UNSET_VALUE
|
60
|
-
@private_key = nil if @private_key == UNSET_VALUE
|
61
|
-
@run_as = nil if @run_as == UNSET_VALUE
|
62
|
-
@ssl = nil if @ssl == UNSET_VALUE
|
63
|
-
@ssl_verify = nil if @ssl_verify == UNSET_VALUE
|
64
|
-
@sudo_password = nil if @sudo_password == UNSET_VALUE
|
65
|
-
@tmpdir = nil if @tmpdir == UNSET_VALUE
|
66
|
-
@user = nil if @user == UNSET_VALUE
|
67
|
-
@verbose = nil if @verbose == UNSET_VALUE
|
68
|
-
@debug = nil if @debug == UNSET_VALUE
|
69
|
-
|
71
|
+
super
|
70
72
|
@args = nil if @args == UNSET_VALUE
|
71
73
|
@name = nil if @name == UNSET_VALUE
|
72
74
|
@node_list = nil if @node_list == UNSET_VALUE
|
73
75
|
@params = nil if @params == UNSET_VALUE
|
74
76
|
@command = nil if @command == UNSET_VALUE
|
75
77
|
@noop = nil if @noop == UNSET_VALUE
|
78
|
+
# Use nodes if targets is not specified.
|
79
|
+
@targets = @nodes if @targets.empty?
|
80
|
+
@target_list = @node_list if (@target_list == UNSET_VALUE) || @target_list.nil?
|
76
81
|
end
|
77
82
|
|
78
83
|
def merge(other)
|
79
84
|
super.tap do |result|
|
80
85
|
new_excludes = (excludes + other.excludes.dup).flatten.uniq
|
81
86
|
result.instance_variable_set(:@excludes, new_excludes.to_a)
|
82
|
-
unless
|
83
|
-
|
84
|
-
result.instance_variable_set(:@
|
87
|
+
unless targets.to_s.casecmp("all").zero?
|
88
|
+
new_targets = (targets + other.targets.dup).flatten.uniq
|
89
|
+
result.instance_variable_set(:@targets, new_targets.to_a)
|
85
90
|
end
|
86
91
|
end
|
87
92
|
end
|
@@ -90,9 +95,9 @@ class VagrantBolt::Config::Bolt < VagrantBolt::Config::Global
|
|
90
95
|
errors = _detected_errors
|
91
96
|
errors << I18n.t('vagrant-bolt.config.bolt.errors.invalid_command', command: @command.to_s) if !@command.nil? && !['task', 'plan', 'command'].include?(@command.to_s)
|
92
97
|
|
93
|
-
if @
|
98
|
+
if @targets.nil? || (!(@targets.is_a? Array) && !@targets.to_s.casecmp("all").zero?)
|
94
99
|
errors << I18n.t('vagrant-bolt.config.bolt.errors.invalid_data_command',
|
95
|
-
item: '
|
100
|
+
item: 'targets',
|
96
101
|
command: 'array')
|
97
102
|
end
|
98
103
|
|
@@ -121,8 +126,10 @@ class VagrantBolt::Config::Bolt < VagrantBolt::Config::Global
|
|
121
126
|
def blacklist
|
122
127
|
[
|
123
128
|
'nodes',
|
129
|
+
'targets',
|
124
130
|
'excludes',
|
125
131
|
'node_list',
|
132
|
+
'target_list',
|
126
133
|
'bolt_exe',
|
127
134
|
'args',
|
128
135
|
'command',
|