vagrant-bolt 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +124 -0
  5. data/.travis.yml +28 -0
  6. data/.yardopts +1 -0
  7. data/Gemfile +37 -0
  8. data/LICENSE +12 -0
  9. data/Puppetfile +7 -0
  10. data/README.md +431 -0
  11. data/Rakefile +19 -0
  12. data/Vagrantfile +47 -0
  13. data/acceptance/artifacts/.keep +0 -0
  14. data/acceptance/components/bolt_spec.rb +98 -0
  15. data/acceptance/skeletons/advanced/Vagrantfile +26 -0
  16. data/acceptance/skeletons/base/Vagrantfile +11 -0
  17. data/acceptance/skeletons/base/modules/facts/CHANGELOG.md +26 -0
  18. data/acceptance/skeletons/base/modules/facts/CONTRIBUTING.md +279 -0
  19. data/acceptance/skeletons/base/modules/facts/Gemfile +98 -0
  20. data/acceptance/skeletons/base/modules/facts/LICENSE +201 -0
  21. data/acceptance/skeletons/base/modules/facts/README.md +45 -0
  22. data/acceptance/skeletons/base/modules/facts/Rakefile +8 -0
  23. data/acceptance/skeletons/base/modules/facts/checksums.json +42 -0
  24. data/acceptance/skeletons/base/modules/facts/lib/puppet/functions/facts/group_by.rb +14 -0
  25. data/acceptance/skeletons/base/modules/facts/metadata.json +62 -0
  26. data/acceptance/skeletons/base/modules/facts/plans/info.pp +16 -0
  27. data/acceptance/skeletons/base/modules/facts/plans/init.pp +13 -0
  28. data/acceptance/skeletons/base/modules/facts/tasks/bash.json +5 -0
  29. data/acceptance/skeletons/base/modules/facts/tasks/bash.sh +93 -0
  30. data/acceptance/skeletons/base/modules/facts/tasks/init.json +10 -0
  31. data/acceptance/skeletons/base/modules/facts/tasks/powershell.json +4 -0
  32. data/acceptance/skeletons/base/modules/facts/tasks/powershell.ps1 +56 -0
  33. data/acceptance/skeletons/base/modules/facts/tasks/ruby.json +4 -0
  34. data/acceptance/skeletons/base/modules/facts/tasks/ruby.rb +40 -0
  35. data/acceptance/skeletons/provisioner/Vagrantfile +19 -0
  36. data/acceptance/skeletons/trigger/Vagrantfile +22 -0
  37. data/acceptance/vagrant-spec.config.rb +22 -0
  38. data/lib/vagrant-bolt.rb +57 -0
  39. data/lib/vagrant-bolt/command.rb +65 -0
  40. data/lib/vagrant-bolt/config.rb +6 -0
  41. data/lib/vagrant-bolt/config/bolt.rb +135 -0
  42. data/lib/vagrant-bolt/config/global.rb +172 -0
  43. data/lib/vagrant-bolt/config_builder.rb +11 -0
  44. data/lib/vagrant-bolt/config_builder/config.rb +150 -0
  45. data/lib/vagrant-bolt/config_builder/monkey_patches.rb +71 -0
  46. data/lib/vagrant-bolt/config_builder/provisioner.rb +106 -0
  47. data/lib/vagrant-bolt/config_builder/triggers.rb +29 -0
  48. data/lib/vagrant-bolt/plugin.rb +39 -0
  49. data/lib/vagrant-bolt/provisioner.rb +18 -0
  50. data/lib/vagrant-bolt/runner.rb +88 -0
  51. data/lib/vagrant-bolt/util/bolt.rb +139 -0
  52. data/lib/vagrant-bolt/util/config.rb +43 -0
  53. data/lib/vagrant-bolt/util/machine.rb +73 -0
  54. data/lib/vagrant-bolt/version.rb +5 -0
  55. data/spec/spec_helper.rb +12 -0
  56. data/spec/unit/config/bolt_spec.rb +150 -0
  57. data/spec/unit/config/global_spec.rb +95 -0
  58. data/spec/unit/provisioner/bolt_spec.rb +39 -0
  59. data/spec/unit/runner/runner_spec.rb +122 -0
  60. data/spec/unit/util/bolt_spec.rb +148 -0
  61. data/spec/unit/util/config_spec.rb +53 -0
  62. data/spec/unit/vagrant_spec.rb +9 -0
  63. data/tasks/acceptance.rake +45 -0
  64. data/tasks/spec.rake +5 -0
  65. data/templates/locales/en.yml +24 -0
  66. data/vagrant-bolt.gemspec +24 -0
  67. metadata +109 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b5fba8cd90a1ba29c44dd28d5a1d7d6de8c8276a742386b1f24eacc900e638fc
4
+ data.tar.gz: 75713e7c5c1f6b1c5e8338ec9a9012188258224c049b22ea8c929fffa15772bd
5
+ SHA512:
6
+ metadata.gz: 469933d26046b905881486ad771febef1310b6a99dc3911df6075ea28b1a62e8e262bb2202c327b837e195b0977548afee47d73b3b63651f760c806ad37badc0
7
+ data.tar.gz: 0bb43ca82eef7a6aac4a5cbabec09130f9d8d81d19aa3155db7154fbf24174c7bf9c8a18494e162646d9e747c7ecd64ddb7b5fb4e7cd5246a6fdd8fd3d19e30b
@@ -0,0 +1,15 @@
1
+ *.swp
2
+ .bundle
3
+ .vendor
4
+ spec/fixtures
5
+ .ruby-version
6
+ .yardoc
7
+ /doc
8
+ Gemfile.lock
9
+ Gemfile.local
10
+ *.gem
11
+ *.log
12
+ *.bak
13
+ .vagrant
14
+ /modules
15
+ *.box
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,124 @@
1
+ ---
2
+ AllCops:
3
+ DisplayCopNames: true
4
+ TargetRubyVersion: '2.4'
5
+ Include:
6
+ - "lib/**/*.rb"
7
+ - "**/Vagrantfile"
8
+ - "spec/**/*.rb"
9
+ - "acceptance/**/*.rb"
10
+ - "**/Rakefile"
11
+ - "**/*.task"
12
+ Exclude:
13
+ - "bin/*"
14
+ - "modules/**/*"
15
+ - ".vendor/**/*"
16
+ - ".bundle/**/*"
17
+ - "**/Gemfile"
18
+ - "pkg/**/*"
19
+ - "spec/fixtures/**/*"
20
+ - "vendor/**/*"
21
+ - ".vagrant/**/*"
22
+ DisabledByDefault: false
23
+ Metrics/LineLength:
24
+ Description: People have wide screens, use them.
25
+ Max: 200
26
+ Enabled: true
27
+ Style/BlockDelimiters:
28
+ Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
29
+ be consistent then.
30
+ EnforcedStyle: braces_for_chaining
31
+ Enabled: true
32
+ Style/ClassAndModuleChildren:
33
+ Description: Compact style reduces the required amount of indentation.
34
+ EnforcedStyle: compact
35
+ Enabled: true
36
+ Style/EmptyElse:
37
+ Description: Enforce against empty else clauses, but allow `nil` for clarity.
38
+ EnforcedStyle: empty
39
+ Enabled: true
40
+ Style/FormatString:
41
+ EnforcedStyle: percent
42
+ Enabled: true
43
+ Style/FormatStringToken:
44
+ EnforcedStyle: template
45
+ Enabled: true
46
+ Style/Lambda:
47
+ Description: Prefer the keyword for easier discoverability.
48
+ EnforcedStyle: literal
49
+ Enabled: true
50
+ Style/RegexpLiteral:
51
+ EnforcedStyle: percent_r
52
+ Enabled: true
53
+ Style/TernaryParentheses:
54
+ Description: Checks for use of parentheses around ternary conditions. Enforce parentheses
55
+ on complex expressions for better readability, but seriously consider breaking
56
+ it up.
57
+ EnforcedStyle: require_parentheses_when_complex
58
+ Enabled: true
59
+ Style/TrailingCommaInArguments:
60
+ Description: Prefer always trailing comma on multiline argument lists. This makes
61
+ diffs, and re-ordering nicer.
62
+ EnforcedStyleForMultiline: comma
63
+ Enabled: true
64
+ Style/TrailingCommaInHashLiteral:
65
+ Description: Prefer always trailing comma on multiline literals. This makes diffs,
66
+ and re-ordering nicer.
67
+ EnforcedStyleForMultiline: comma
68
+ Enabled: true
69
+ Style/TrailingCommaInArrayLiteral:
70
+ Description: Prefer always trailing comma on multiline literals. This makes diffs,
71
+ and re-ordering nicer.
72
+ EnforcedStyleForMultiline: comma
73
+ Enabled: true
74
+ Style/SymbolArray:
75
+ Description: Using percent style obscures symbolic intent of array's contents.
76
+ EnforcedStyle: brackets
77
+ Enabled: true
78
+ Style/Documentation:
79
+ Exclude:
80
+ - spec/**/*
81
+ Enabled: false
82
+ Style/WordArray:
83
+ EnforcedStyle: brackets
84
+ Enabled: true
85
+ Style/CollectionMethods:
86
+ Enabled: true
87
+ Style/MethodCalledOnDoEndBlock:
88
+ Enabled: true
89
+ Style/StringMethods:
90
+ Enabled: true
91
+ Metrics/AbcSize:
92
+ Enabled: false
93
+ Metrics/MethodLength:
94
+ Enabled: false
95
+ Metrics/CyclomaticComplexity:
96
+ Enabled: false
97
+ Metrics/PerceivedComplexity:
98
+ Enabled: false
99
+ Metrics/MethodLength:
100
+ Enabled: true
101
+ ExcludedMethods:
102
+ - initialize
103
+ - finalize!
104
+ - validate
105
+ - to_proc
106
+ Max: 25
107
+ Metrics/ClassLength:
108
+ Enabled: false
109
+ Metrics/ModuleLength:
110
+ Enabled: true
111
+ Style/StringLiterals:
112
+ Enabled: false
113
+ Naming/FileName:
114
+ Enabled: false
115
+ Style/FrozenStringLiteralComment:
116
+ Exclude:
117
+ - "**/Vagrantfile"
118
+ Metrics/BlockLength:
119
+ Exclude:
120
+ - "**/Vagrantfile"
121
+ - "spec/**/*.rb"
122
+ - "acceptance/**/*.rb"
123
+ Style/RescueStandardError:
124
+ EnforcedStyle: implicit
@@ -0,0 +1,28 @@
1
+ ---
2
+ sudo: false
3
+ dist: trusty
4
+ language: ruby
5
+ cache: bundler
6
+ before_install:
7
+ - bundle -v
8
+ - rm -f Gemfile.lock
9
+ - gem update --system
10
+ - gem --version
11
+ - bundle -v
12
+ notifications:
13
+ email: false
14
+ script:
15
+ - 'bundle exec rake rubocop spec'
16
+ bundler_args: --without system_tests
17
+ env:
18
+ global:
19
+ - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
20
+ rvm:
21
+ - 2.5.0
22
+ matrix:
23
+ fast_finish: true
24
+ include:
25
+ - rvm: 2.4.4
26
+ env: TEST_VAGRANT_VERSION=v2.2.2
27
+ - rvm: 2.5.0
28
+ env: TEST_VAGRANT_VERSION=HEAD
@@ -0,0 +1 @@
1
+ --markup markdown
data/Gemfile ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ require 'rubygems/version'
5
+
6
+ vagrant_branch = ENV['TEST_VAGRANT_VERSION'] || 'v2.2.2'
7
+
8
+ group :plugins do
9
+ gemspec
10
+ end
11
+
12
+ group :development do
13
+ gem 'rake'
14
+ gem 'redcarpet'
15
+ gem 'rubocop'
16
+ gem 'rubocop-rspec'
17
+ gem 'yard', '~> 0.9.16'
18
+ end
19
+
20
+ group :test do
21
+ if %r{head}i.match?(vagrant_branch)
22
+ gem 'vagrant', git: 'https://github.com/hashicorp/vagrant.git',
23
+ branch: 'master'
24
+ else
25
+ gem 'vagrant', git: 'https://github.com/hashicorp/vagrant.git',
26
+ tag: vagrant_branch
27
+ end
28
+
29
+ gem 'vagrant-spec', git: 'https://github.com/hashicorp/vagrant-spec.git'
30
+ end
31
+
32
+ group :system_tests do
33
+ gem 'bolt', ">=1.5.0"
34
+ end
35
+
36
+
37
+ eval_gemfile "#{__FILE__}.local" if File.exist? "#{__FILE__}.local"
data/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ Licensed under the Apache License, Version 2.0 (the "License");
2
+ you may not use this file except in compliance with the License.
3
+ You may obtain a copy of the License at
4
+
5
+ http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ forge "http://forge.puppetlabs.com"
4
+
5
+ moduledir File.join(File.dirname(__FILE__), 'modules')
6
+
7
+ mod 'puppetlabs-facts', '0.3.1'
@@ -0,0 +1,431 @@
1
+ vagrant-bolt
2
+ ============
3
+
4
+ Manage [vagrant](https://www.vagrantup.com) machines with [Puppet Bolt](https://puppet.com/docs/bolt).
5
+
6
+ Synopsis
7
+ --------
8
+
9
+ **vagrant-bolt** is a [vagrant](https://www.vagrantup.com) plugin enabling the use of [Puppet Bolt](https://puppet.com/docs/bolt) as a provisioner. Bolt commands can be configured in the Vagrantfile to be run as a provisioner or integrated with triggers. Bolt tasks and Plans can help automate configuration and orchestrate changes across machines.
10
+
11
+ Usage
12
+ -----
13
+
14
+ The vagrant-bolt plugin can be used either as a provisioner or in a ruby block trigger. Both methods can use the bolt config object to inherit configuration options. The provisioner and trigger can provision bolt tasks and plans using the locally installed bolt command and modules.
15
+
16
+ ### Ruby Triggers
17
+
18
+ Ruby triggers, implemented in Vagrant 2.2.0, allow for specifying a block of ruby code as the trigger. See the [trigger documentation](https://www.vagrantup.com/docs/triggers/) for more information around triggers. Below is an example Vagrantfile to add a bolt ruby trigger at the root.
19
+
20
+ ~~~ruby
21
+ require 'vagrant-bolt'
22
+ Vagrant.configure("2") do |config|
23
+ config.vm.box = "ubuntu/xenial64"
24
+
25
+ # Using a global bolt trigger for a plan
26
+ # This will fire on all machines after :up
27
+ config.trigger.after :up do |trigger|
28
+ trigger.name = "Bolt \"facts\" after :up"
29
+ trigger.ruby do |env, machine|
30
+ VagrantBolt.plan("facts", env, machine)
31
+ end
32
+ end
33
+ end
34
+ ~~~
35
+
36
+ Tasks, plans, and commands can be configured using the appropiate methods. `VagrantBolt.task` for tasks, `VagrantBolt.plan` for plans, and `VagrantBolt.command` for commands.
37
+
38
+ ### Provisioner
39
+
40
+ vagrant-bolt also provides a traditional provisioner which can be added to a machine. Below is an example Vagrantfile which runs a bolt task on a machine.
41
+
42
+ ~~~ruby
43
+ require 'vagrant-bolt'
44
+ Vagrant.configure("2") do |config|
45
+ config.vm.box = "ubuntu/xenial64"
46
+
47
+ config.vm.define 'server' do |node|
48
+ node.vm.provision :bolt do |bolt|
49
+ bolt.command = :task
50
+ bolt.name = "service::linux"
51
+ bolt.params = { name: "cron", action: "restart" }
52
+ bolt.run_as = "root"
53
+ end
54
+ end
55
+ end
56
+ ~~~
57
+
58
+ Configuration Options
59
+ ---------------------
60
+
61
+ Configuring the vagrant-bolt plugin can be done through the provisioner config and in the trigger method. Each way has different capabilities, so they may fit different use cases.
62
+
63
+ ### Config Objects
64
+
65
+ The plugin provides a `bolt` config object at the `root`, `vm`, and `provisioner` levels. Each level inherits from the parent and are all merged into the final configuration. An example Vagrantfile has all three levels included.
66
+
67
+ ~~~ruby
68
+ require 'vagrant-bolt'
69
+ Vagrant.configure("2") do |config|
70
+ config.vm.box = "ubuntu/xenial64"
71
+ # Root level config will be applied to all bolt provisioners and triggers
72
+ config.bolt.verbose = true
73
+
74
+ config.vm.define 'server' do |node|
75
+ # VM level config will be applied to all bolt provisioners and triggers for the VM
76
+ node.bolt.run_as = "root"
77
+ node.vm.provision :bolt do |bolt|
78
+ # Provisioner level config is only applied to this provisioner
79
+ bolt.command = :task
80
+ bolt.name = "facts"
81
+ end
82
+ end
83
+ end
84
+ ~~~
85
+
86
+ The configuration above would result in the `facts` task being run on the VM with `run_as = root`, and `verbose = true`. Configuration items defined in a more specific scope will override the least specific scope, and arrays will be deep merged.
87
+
88
+ The config object applies to the triggers as well. The example Vagrantfile will result in the same options being applied.
89
+
90
+ ~~~ruby
91
+ require 'vagrant-bolt'
92
+ Vagrant.configure("2") do |config|
93
+ config.vm.box = "ubuntu/xenial64"
94
+ # Root level config will be applied to all bolt provisioners and triggers
95
+ config.bolt.verbose = true
96
+
97
+ config.vm.define 'server' do |node|
98
+ # VM level config will be applied to all bolt provisioners and triggers for the VM
99
+ node.bolt.run_as = "root"
100
+ node.trigger.after :up do |trigger|
101
+ trigger.name = "Bolt \"facts\" after :up"
102
+ trigger.ruby do |env, machine|
103
+ VagrantBolt.task("facts", env, machine)
104
+ end
105
+ end
106
+ end
107
+ end
108
+ ~~~
109
+
110
+ ### Trigger options
111
+
112
+ In addition to the config objects, the trigger method takes options for additional configuration. Unlike the config objects, the options specified in the method strictly override the config objects and are not merged. Below is an example of using the config objects with method overrides.
113
+
114
+ ~~~ruby
115
+ require 'vagrant-bolt'
116
+ Vagrant.configure("2") do |config|
117
+ config.vm.box = "ubuntu/xenial64"
118
+ # Root level config will be applied to all bolt provisioners and triggers
119
+ config.bolt.verbose = true
120
+
121
+ config.vm.define 'server' do |node|
122
+ # VM level config will be applied to all bolt provisioners and triggers for the VM
123
+ node.bolt.run_as = 'root'
124
+ node.trigger.after :up do |trigger|
125
+ trigger.name = "Bolt \"facts\" after up"
126
+ trigger.ruby do |env, machine|
127
+ # Specify additional **options for the task
128
+ VagrantBolt.task(
129
+ "facts",
130
+ env,
131
+ machine,
132
+ host_key_check: false,
133
+ verbose: false,
134
+ )
135
+ end
136
+ end
137
+ end
138
+ end
139
+ ~~~
140
+
141
+ The configuration above would result in the `facts` task being run on the VM with `run_as = root`, `host_key_check = false`, and `verbose = false`. The `verbose` defined in the method will override the root level `verbose` option.
142
+
143
+ #### Trigger Methods
144
+
145
+ The methods for a bolt command in a trigger allow for a task, plan, or command. All methods take the same arguments.
146
+
147
+ * **VagrantBolt.task**
148
+ * Description: Run a bolt task based on the config and arguments
149
+ * Parameters:
150
+ * Required: `name` A string containing the name of the task to run
151
+ * Required: `env` The env object
152
+ * Required: `machine` The machine object
153
+ * Optional: `**args` A hash of [Plugin Settings](#plugin-settings) which override any previous config
154
+ * **VagrantBolt.plan**
155
+ * Description: Run a bolt plan based on the config and arguments
156
+ * Parameters:
157
+ * Required: `name` A string containing the name of the plan to run
158
+ * Required: `env` The env object
159
+ * Required: `machine` The machine object
160
+ * Optional: `**args` A hash of [Plugin Settings](#plugin-settings) which override any previous config
161
+ * **VagrantBolt.command**
162
+ * Description: Run a bolt command based on the config and arguments
163
+ * Parameters:
164
+ * Required: `name` A string containing the command to run
165
+ * Required: `env` The env object
166
+ * Required: `machine` The machine object
167
+ * Optional: `**args` A hash of [Plugin Settings](#plugin-settings) which override any previous config
168
+
169
+ Example of the arguments can be seen below.
170
+
171
+ Run the `facts` task using a specific user and password.
172
+
173
+ ~~~ruby
174
+ VagrantBolt.task('facts', env, machine, user: 'ubuntu', password: 'testpassword')
175
+ ~~~
176
+
177
+ Run the `facts` plan on `server1` and `server2`.
178
+
179
+ ~~~ruby
180
+ VagrantBolt.plan('facts', env, machine, nodes: [:server1, :server2])
181
+ ~~~
182
+
183
+ Run the `hostname` command on all nodes.
184
+
185
+ ~~~ruby
186
+ VagrantBolt.command('/bin/hostname', env, machine, nodes: 'all')
187
+ ~~~
188
+
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.
190
+
191
+ ~~~ruby
192
+ VagrantBolt.task(
193
+ 'service::linux',
194
+ env,
195
+ machine,
196
+ run_as: 'root',
197
+ bolt_exe: '/usr/local/bin/bolt',
198
+ params: { name: "cron", action: "restart" },
199
+ )
200
+ ~~~
201
+
202
+ Plugin Settings
203
+ ---------------
204
+
205
+ The settings available in the triggers and the provisioner are the same.
206
+
207
+ **Required Settings**
208
+
209
+ * `command`
210
+ * Description: A string containing plan or task to determine which will be used
211
+ * Valid Values: `task`, `plan`, and `command`
212
+ * `name`
213
+ * Description: A string containing name of the task, plan, or command to run
214
+
215
+ **Optional Settings**
216
+
217
+ * `bolt_exe`
218
+ * Description: A string containing the full path to the bolt executable
219
+ * Default: `bolt`
220
+ * `boltdir`
221
+ * Description: A string containing the bolt working directory
222
+ * Default: The vagrant root
223
+ * `node_list`
224
+ * Description: A string containing bolt node list in URI format
225
+ * This will override `nodes` and `excludes`
226
+ * Default: `%{protocol}://%{ssh_ip}:%{ssh_port}` if `nodes` is not specified
227
+ * `nodes`
228
+ * Description: An array of machine names to run the task or plan on
229
+ * The `node_list` will override this setting.
230
+ * A special `ALL` string can be used instead of an array to use all active machines in the environment
231
+ * Valid Values: An array of machine symbols or the string "ALL"
232
+ * Default: `[]`
233
+ * `excludes`
234
+ * Description: An array of machine names to not run the task on
235
+ * The `node_list` will override this setting.
236
+ * This setting will take precidence over `nodes`
237
+ * Valid Values: An array of machine symbols
238
+ * Default: `[]`
239
+ * `params`
240
+ * Description: A hash of the params for the bolt task or plan
241
+ * `password`
242
+ * Description: A string containing the password bolt will use to connect to the machine
243
+ * `user`
244
+ * Description: A string containing the user bolt will use to connect to the machine
245
+ * Default: The user vagrant uses to connect to the machine
246
+ * `port`
247
+ * Description: A string containing the port bolt will use to connect to the machine
248
+ * Default: The port that vagrant uses to connect to the machine
249
+ * `sudo_password`
250
+ * Description: A string containing the password bolt will use to escalate privileges on the machine
251
+ * `host_key_check`
252
+ * Description: A boolean which controls if the connection should check the host key on the remote host (linux)
253
+ * Default: `false`
254
+ * `private_key`
255
+ * Description: A string containing the path to a ssh private key that bolt will use to connect to the machine
256
+ * Default: The key vagrant uses to connect to the machine
257
+ * `ssl`
258
+ * Description: A boolean which controls if the connection should use SSL on with WinRM (Windows)
259
+ * `ssl_verify`
260
+ * Description: A boolean which controls if the connection should verify SSL on with WinRM (Windows)
261
+ * `modulepath`
262
+ * Description: A string containing the path to bolt modules
263
+ * Default: `modules` in the vagrant root
264
+ * `tmpdir`
265
+ * Description: A string containing the directory to upload and execute temporary files on the target
266
+ * `verbose`
267
+ * Description: A boolean which controls if bolt will output verbose logs
268
+ * `debug`
269
+ * Description: A boolean which controls if bolt will output debug logs
270
+ * `run_as`
271
+ * Description: A string containing the user to run commands as on the machine
272
+ * `args`
273
+ * Description: A string containing additional arguments to be passed into the bolt command
274
+ * `features`
275
+ * Description: An array containing the capabilities of the target that can be used to select a specific task implementation.
276
+ * `vars`
277
+ * Description: A hash containing arbitrary data that may be passed to run_* functions or used for logic in plans
278
+ * `facts`
279
+ * Description: A hash containing observed information about the node including what can be collected by Facter
280
+
281
+ Config Builder
282
+ --------------
283
+
284
+ This module also supports the [oscar/config_builder](https://github.com/oscar-stack/vagrant-config_builder) plugin for configuration. If [oscar/config_builder](https://github.com/oscar-stack/vagrant-config_builder) is installed, bolt can be configured similar to the [Configuration Options section](#configuration-options) with a few small differences.
285
+
286
+ ### Configuration
287
+
288
+ The configuration can be specified at the root, VM, and Provisioner levels.
289
+
290
+ An example of this configuration is below.
291
+
292
+ ~~~ruby
293
+ ---
294
+ # VM Default level config
295
+ vm_defaults:
296
+ bolt:
297
+ run_as: root
298
+ vms:
299
+ - name: server
300
+ # VM level config
301
+ bolt:
302
+ user: vagrant
303
+ tmpdir: /tmp
304
+ port: 1234
305
+ provisioners:
306
+ # Bolt provisioner
307
+ - type: bolt
308
+ command: task
309
+ name: facts
310
+ ~~~
311
+
312
+ ### Trigger Configuration
313
+
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.
315
+
316
+ * `trigger_type`
317
+ * Description: A symbol of the trigger type.
318
+ * Valid Values: `:before` or `:after`
319
+ * `trigger_commands`
320
+ * Description: An array of symbols for the commands to run the trigger on
321
+ * Valid Values: An array of symbols such as `[:up, :provision, :halt]`
322
+
323
+ These will live under the `bolt_triggers` namespace which exists at the root and VM levels. `bolt_triggers` accepts an array of bolt triggers. Below is an example of using a VM level trigger for a specific VM.
324
+
325
+ ~~~ruby
326
+ ---
327
+ vms:
328
+ - name: server
329
+ bolt_triggers:
330
+ - trigger_type: :after
331
+ trigger_commands:
332
+ - :provision
333
+ - :up
334
+ command: task
335
+ name: facts
336
+ ~~~
337
+
338
+ Below is an example of using a VM default trigger, which will apply to all machines.
339
+
340
+ ~~~ruby
341
+ ---
342
+ vm_defaults:
343
+ bolt_triggers:
344
+ - trigger_type: :after
345
+ trigger_commands:
346
+ - :provision
347
+ - :up
348
+ command: task
349
+ name: facts
350
+ vms:
351
+ - name: server
352
+ ~~~
353
+
354
+ Commands
355
+ --------
356
+
357
+ Vagrant bolt comes with a single command that helps to run ad-hoc bolt commands. The `vagrant bolt` command is available to run bolt commands locally using the inventory file for the vagrant machines.
358
+
359
+ The format of the command is below.
360
+
361
+ ~~~shell
362
+ Usage: vagrant bolt <options> [bolt options]
363
+
364
+ Options:
365
+
366
+ -u, --[no-]updateinventory Update the inventory file (defaults to false)
367
+ ~~~
368
+
369
+ The command can be used to deploy the Puppetfile, for example.
370
+
371
+ ~~~shell
372
+ vagrant bolt puppetfile install
373
+ ~~~
374
+
375
+ It can be used to run ad-hoc tasks on a node by specifying the node by its machine name.
376
+
377
+ ~~~shell
378
+ vagrant bolt -u task run facts -n server
379
+ ~~~
380
+
381
+ 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
+
383
+ All arguments except for the `-u` will be passed to bolt, so a bolt command like the exaple below can be run.
384
+
385
+ ~~~shell
386
+ vagrant bolt command run 'date' -n agent,master
387
+ ~~~
388
+
389
+ Other Use Cases
390
+ ---------------
391
+
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 nodes, 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 nodes 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
+
394
+ ~~~ruby
395
+ require 'vagrant-bolt'
396
+ Vagrant.configure("2") do |config|
397
+ config.vm.box = "alpine/alpine64"
398
+
399
+ config.trigger.after :up, :provision, :halt, :destroy do |trigger|
400
+ trigger.name = "Manage a seperate inventory file"
401
+ trigger.ruby do |env, machine|
402
+ VagrantBolt::Util::Bolt.update_inventory_file(
403
+ env,
404
+ File.expand_path('inventory.yaml', File.dirname(__FILE__)),
405
+ )
406
+ end
407
+ end
408
+ config.vm.define 'server'
409
+ end
410
+ ~~~
411
+
412
+ Installation
413
+ ------------
414
+
415
+ The plugin can be installed through vagrant's plugin manager. Please ensure to meet the requirements prior to installing `vagrant-bolt`.
416
+
417
+ ~~~shell
418
+ vagrant plugin install vagrant-bolt
419
+ ~~~
420
+
421
+ Requirements
422
+ ------------
423
+
424
+ * Vagrant 2.2.0+ is required for this plugin.
425
+ * Bolt 1.5+ 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
+ * Ruby 2.3+
427
+
428
+ Known Issues
429
+ ------------
430
+
431
+ * Machine names with hyphens in them are not valid in bolt 1.5.0. This is because of <https://tickets.puppetlabs.com/browse/BOLT-1022>.