kitchen-vra 3.3.2 → 3.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,63 +1,292 @@
1
1
  # kitchen-vra
2
2
 
3
- A driver to allow Test Kitchen to consume vRealize Automation (vRA) resources to perform testing.
3
+ [![Gem Version](https://badge.fury.io/rb/kitchen-vra.svg)](https://badge.fury.io/rb/kitchen-vra)
4
+
5
+ A [Test Kitchen](https://kitchen.ci/) driver that provisions and destroys machines through [VMware vRealize Automation](https://www.vmware.com/products/vrealize-automation.html) (vRA, now Aria Automation), so you can test your cookbooks and infrastructure code against instances from your own vRA catalog.
6
+
7
+ Rather than talking to a hypervisor directly, this driver submits a catalog request to vRA and waits for the resulting deployment, so test instances follow the same blueprints, approvals, and policies as the rest of your estate.
8
+
9
+ > This documentation uses [Cinc Workstation](https://cinc.sh/) and the `cinc` commands throughout. Everything here works identically with Chef Workstation — see [Using with Chef](#using-with-chef).
10
+
11
+ ## Requirements
12
+
13
+ - Ruby 3.1 or later (already satisfied if you use Cinc Workstation)
14
+ - Access to a vRA 8.x appliance
15
+ - A catalog item that provisions exactly **one** virtual machine — the driver rejects a request that returns more than one server
16
+ - Permission to request that catalog item, and to delete the resulting deployment
4
17
 
5
18
  ## Installation
6
19
 
7
- Add this line to your application's Gemfile:
20
+ This driver ships as part of [Cinc Workstation](https://cinc.sh/start/workstation/). If you have Cinc Workstation installed, there is nothing else to install.
21
+
22
+ To install it into a standalone Ruby:
23
+
24
+ ```sh
25
+ gem install kitchen-vra
26
+ ```
27
+
28
+ Or with Bundler, add it to your `Gemfile`:
8
29
 
9
30
  ```ruby
10
- gem 'kitchen-vra'
31
+ gem "kitchen-vra"
11
32
  ```
12
33
 
13
- And then execute:
34
+ ...then run `bundle install`.
35
+
36
+ ## Authentication
37
+
38
+ Credentials are resolved in this order:
14
39
 
15
- ```shell
16
- bundle
40
+ 1. The `username` and `password` driver options
41
+ 2. The `VRA_USER_NAME` and `VRA_USER_PASSWORD` environment variables
42
+ 3. Cached credentials, if `cache_credentials` was enabled on a previous run
43
+ 4. An interactive prompt
44
+
45
+ Keep credentials out of `kitchen.yml`. The usual approach is the environment:
46
+
47
+ ```sh
48
+ export VRA_USER_NAME='myuser@corp.local'
49
+ export VRA_USER_PASSWORD='mypassword'
17
50
  ```
18
51
 
19
- Or install it yourself as:
52
+ Setting `cache_credentials: true` stores the credentials after a successful run so later runs do not prompt. They are written to `.kitchen/cached_vra`, encrypted under a key derived from `base_url` and readable only by your user. Since `base_url` is not a secret, this hides the password from casual view rather than protecting it treat the file as sensitive and avoid the option on shared machines.
20
53
 
21
- ```shell
22
- gem install kitchen-vra
54
+ ## Quick Start
55
+
56
+ ```yaml
57
+ ---
58
+ driver:
59
+ name: vra
60
+ base_url: https://vra.corp.local
61
+ domain: corp.local
62
+ project_id: 6ba69375-2d1e-4a5e-9e9b-1a1a3f0e6d4c
63
+ image_mapping: Ubuntu 22.04
64
+ flavor_mapping: Small
65
+ catalog_name: Ubuntu Server
66
+ verify_ssl: true
67
+
68
+ provisioner:
69
+ name: cinc_infra
70
+
71
+ verifier:
72
+ name: cinc_auditor
73
+
74
+ platforms:
75
+ - name: ubuntu-22.04
76
+
77
+ suites:
78
+ - name: default
79
+ run_list:
80
+ - recipe[my_cookbook::default]
23
81
  ```
24
82
 
25
- Or even better, install it via ChefDK:
83
+ Then run the full test cycle:
26
84
 
27
- ```shell
28
- chef gem install kitchen-vra
85
+ ```sh
86
+ cinc kitchen test
87
+ ```
88
+
89
+ Or step through it:
90
+
91
+ ```sh
92
+ cinc kitchen create # submit the catalog request and wait for the deployment
93
+ cinc kitchen converge # apply your cookbook
94
+ cinc kitchen verify # run your tests
95
+ cinc kitchen destroy # destroy the vRA deployment
29
96
  ```
30
97
 
31
98
  ## Configuration
32
99
 
33
- See the [kitchen.ci kitchen-vra docs](https://kitchen.ci/docs/drivers/vra/) for a complete list of configuration options.
100
+ All options below are set under the `driver:` key in `kitchen.yml`.
34
101
 
35
- ## License and Authors
102
+ ### Required
103
+
104
+ | Option | Default | Description |
105
+ | --- | --- | --- |
106
+ | `base_url` | *none* | Base URL of the vRA appliance, e.g. `https://vra.corp.local`. Required. |
107
+ | `domain` | *none* | Authentication domain, e.g. `corp.local`. Required. |
108
+ | `project_id` | *none* | ID of the vRA project the deployment is created under. Required. |
109
+ | `image_mapping` | *none* | Name of the vRA image mapping to deploy, e.g. `Ubuntu 22.04`. Required. |
110
+ | `flavor_mapping` | *none* | Name of the vRA flavor mapping, which determines CPU and memory, e.g. `Small`. Required. |
111
+
112
+ You must also identify the catalog item with either `catalog_id` or `catalog_name`.
113
+
114
+ ### Catalog item
115
+
116
+ | Option | Default | Description |
117
+ | --- | --- | --- |
118
+ | `catalog_id` | `nil` | ID of the catalog item to request. |
119
+ | `catalog_name` | `nil` | Name of the catalog item to request, resolved to an ID. Use instead of `catalog_id`. |
120
+ | `version` | `nil` | Version of the catalog item to request. Uses the latest if unset. |
121
+ | `extra_parameters` | `{}` | Additional catalog request parameters, keyed by parameter name. See [Extra parameters](#extra-parameters). |
122
+
123
+ ### Credentials
124
+
125
+ | Option | Default | Description |
126
+ | --- | --- | --- |
127
+ | `username` | `$VRA_USER_NAME` | vRA username. Prompted for if not set anywhere. |
128
+ | `password` | `$VRA_USER_PASSWORD` | vRA password. Prompted for if not set anywhere. |
129
+ | `cache_credentials` | `false` | Cache credentials to disk after a successful run so later runs do not prompt. |
130
+ | `verify_ssl` | `true` | Verify the appliance's TLS certificate. Only disable against a lab with a self-signed certificate. |
131
+ | `tenant` | `nil` | **Deprecated.** Not used for authentication in vRA 8.x. Use `domain` instead. |
132
+
133
+ ### Deployment
134
+
135
+ | Option | Default | Description |
136
+ | --- | --- | --- |
137
+ | `deployment_name` | the platform name | Name given to the vRA deployment. Ignored when `unique_name` is enabled. |
138
+ | `unique_name` | `false` | Name the deployment `deployment_<request id>` instead of using `deployment_name`, so concurrent runs do not collide. |
36
139
 
37
- Author:: Chef Partner Engineering (<partnereng@chef.io>)
140
+ ### Connectivity
38
141
 
39
- Copyright:: Copyright (c) 2022 Chef Software, Inc.
142
+ | Option | Default | Description |
143
+ | --- | --- | --- |
144
+ | `use_dns` | `false` | Connect using the server's DNS name instead of its IP address. Needed when vRA does not report a reachable IP. |
145
+ | `dns_suffix` | `nil` | Suffix appended to the server name when `use_dns` is enabled, e.g. `corp.local`. |
146
+ | `private_key_path` | `~/.ssh/id_rsa` or `~/.ssh/id_dsa` | SSH private key used to connect. The first of those two files that exists is used. |
40
147
 
41
- License:: Apache License, Version 2.0
148
+ ### Timing
42
149
 
43
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
44
- this file except in compliance with the License. You may obtain a copy of the License at
150
+ | Option | Default | Description |
151
+ | --- | --- | --- |
152
+ | `request_timeout` | `600` | Seconds to wait for the catalog request to complete. |
153
+ | `request_refresh_rate` | `2` | Seconds between polls while waiting for the request. |
154
+ | `server_ready_retries` | `1` | Number of times to retry when the server is reported ready but is not yet reachable. Increase this on slow environments. |
45
155
 
46
- ```text
47
- http://www.apache.org/licenses/LICENSE-2.0
156
+ ## Extra parameters
157
+
158
+ `extra_parameters` passes additional inputs to the catalog request. Each entry is
159
+ keyed by the vRA parameter name, and gives the value along with its type:
160
+
161
+ ```yaml
162
+ driver:
163
+ name: vra
164
+ base_url: https://vra.corp.local
165
+ domain: corp.local
166
+ project_id: 6ba69375-2d1e-4a5e-9e9b-1a1a3f0e6d4c
167
+ image_mapping: Ubuntu 22.04
168
+ flavor_mapping: Small
169
+ catalog_name: Ubuntu Server
170
+ extra_parameters:
171
+ environment:
172
+ type: string
173
+ value: test
174
+ disk_size:
175
+ type: integer
176
+ value: 40
177
+ ```
178
+
179
+ ## Examples
180
+
181
+ ### Selecting the catalog item by ID
182
+
183
+ ```yaml
184
+ driver:
185
+ name: vra
186
+ base_url: https://vra.corp.local
187
+ domain: corp.local
188
+ project_id: 6ba69375-2d1e-4a5e-9e9b-1a1a3f0e6d4c
189
+ image_mapping: Ubuntu 22.04
190
+ flavor_mapping: Small
191
+ catalog_id: 9f4d4a7e-1234-4b8b-9c2f-77b6c9f0e111
192
+ version: "2"
193
+ ```
194
+
195
+ ### Running several suites at once
196
+
197
+ Without `unique_name`, concurrent deployments share a name derived from the
198
+ platform, which is confusing in the vRA UI and can collide.
199
+
200
+ ```yaml
201
+ driver:
202
+ name: vra
203
+ base_url: https://vra.corp.local
204
+ domain: corp.local
205
+ project_id: 6ba69375-2d1e-4a5e-9e9b-1a1a3f0e6d4c
206
+ image_mapping: Ubuntu 22.04
207
+ flavor_mapping: Small
208
+ catalog_name: Ubuntu Server
209
+ unique_name: true
210
+ ```
211
+
212
+ ### Connecting by DNS name
213
+
214
+ ```yaml
215
+ driver:
216
+ name: vra
217
+ base_url: https://vra.corp.local
218
+ domain: corp.local
219
+ project_id: 6ba69375-2d1e-4a5e-9e9b-1a1a3f0e6d4c
220
+ image_mapping: Ubuntu 22.04
221
+ flavor_mapping: Small
222
+ catalog_name: Ubuntu Server
223
+ use_dns: true
224
+ dns_suffix: corp.local
225
+ ```
226
+
227
+ ### A slow environment
228
+
229
+ ```yaml
230
+ driver:
231
+ name: vra
232
+ base_url: https://vra.corp.local
233
+ domain: corp.local
234
+ project_id: 6ba69375-2d1e-4a5e-9e9b-1a1a3f0e6d4c
235
+ image_mapping: Ubuntu 22.04
236
+ flavor_mapping: Small
237
+ catalog_name: Ubuntu Server
238
+ request_timeout: 1800
239
+ request_refresh_rate: 10
240
+ server_ready_retries: 5
48
241
  ```
49
242
 
50
- Unless required by applicable law or agreed to in writing, software distributed under the
51
- License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
52
- either express or implied. See the License for the specific language governing permissions
53
- and limitations under the License.
243
+ ### Lab appliance with a self-signed certificate
244
+
245
+ ```yaml
246
+ driver:
247
+ name: vra
248
+ base_url: https://vra.lab.local
249
+ domain: lab.local
250
+ project_id: 6ba69375-2d1e-4a5e-9e9b-1a1a3f0e6d4c
251
+ image_mapping: Ubuntu 22.04
252
+ flavor_mapping: Small
253
+ catalog_name: Ubuntu Server
254
+ verify_ssl: false
255
+ ```
256
+
257
+ ## Troubleshooting
258
+
259
+ **"The vRA request created more than one server."** The driver requires a catalog
260
+ item that provisions exactly one VM. Point it at a single-machine blueprint.
261
+
262
+ **The request succeeds but Test Kitchen cannot connect.** vRA often reports a
263
+ deployment as ready slightly before the guest accepts connections. Raise
264
+ `server_ready_retries`. If vRA reports an unreachable IP, set `use_dns: true`
265
+ along with `dns_suffix`.
266
+
267
+ **Authentication fails on vRA 8.x.** Use `domain`, not `tenant`. The `tenant`
268
+ option is deprecated and is not used for authentication in 8.x.
269
+
270
+ ## Using with Chef
271
+
272
+ This driver is not tied to Cinc. The examples above use Cinc Workstation and the `cinc_infra` provisioner, but the driver works exactly the same with [Chef Workstation](https://www.chef.io/downloads/tools/workstation) — run `kitchen` instead of `cinc kitchen`, and use `chef_infra` instead of `cinc_infra`:
273
+
274
+ ```yaml
275
+ provisioner:
276
+ name: chef_infra
277
+
278
+ verifier:
279
+ name: inspec
280
+ ```
281
+
282
+ No driver configuration changes are needed.
54
283
 
55
284
  ## Contributing
56
285
 
57
- We'd love to hear from you if this doesn't work in your vRA environment. Please log a GitHub issue, or even better, submit a Pull Request with a fix!
286
+ We'd love to hear from you if this doesn't work in your vRA environment. Bug reports and pull requests are welcome on [GitHub](https://github.com/test-kitchen/kitchen-vra). See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, how to run the tests, and the release process.
287
+
288
+ ## License and Authors
289
+
290
+ Author: Chef Partner Engineering (<partnereng@chef.io>)
58
291
 
59
- 1. Fork it ( <https://github.com/chef-partners/kitchen-vra/fork> )
60
- 2. Create your feature branch (`git checkout -b my-new-feature`)
61
- 3. Commit your changes (`git commit -am 'Add some feature'`)
62
- 4. Push to the branch (`git push origin my-new-feature`)
63
- 5. Create a new Pull Request
292
+ Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.
data/Rakefile CHANGED
@@ -3,13 +3,31 @@ require "rspec/core/rake_task"
3
3
  RSpec::Core::RakeTask.new(:test)
4
4
 
5
5
  begin
6
- require "chefstyle"
6
+ require "cookstyle/chefstyle"
7
7
  require "rubocop/rake_task"
8
8
  RuboCop::RakeTask.new(:style) do |task|
9
9
  task.options += ["--display-cop-names", "--no-color"]
10
10
  end
11
11
  rescue LoadError
12
- puts "chefstyle is not available. (sudo) gem install chefstyle to do style checking."
12
+ puts "cookstyle/chefstyle is not available. (sudo) gem install cookstyle to do style checking."
13
13
  end
14
14
 
15
15
  task default: %i{test style}
16
+
17
+ begin
18
+ require "yard"
19
+
20
+ # Options and the file list live in .yardopts so that a bare `yard` from the
21
+ # command line produces exactly what `rake doc` does.
22
+ YARD::Rake::YardocTask.new(:doc)
23
+
24
+ desc "List anything in lib/ that is still undocumented"
25
+ task :doc_coverage do
26
+ sh "yard stats --list-undoc"
27
+ end
28
+ rescue LoadError
29
+ desc "Generate YARD documentation (not installed)"
30
+ task :doc do
31
+ abort "YARD is not installed. Run: bundle install"
32
+ end
33
+ end
data/kitchen-vra.gemspec CHANGED
@@ -7,7 +7,7 @@ require "kitchen/driver/vra_version"
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = "kitchen-vra"
9
9
  spec.version = Kitchen::Driver::VRA_VERSION
10
- spec.authors = ["Chef Commmunity Tools Team"]
10
+ spec.authors = ["Chef Community Tools Team"]
11
11
  spec.email = ["oss@chef.io"]
12
12
  spec.summary = "A Test Kitchen driver for VMware vRealize Automation (vRA)"
13
13
  spec.description = spec.summary
@@ -16,19 +16,13 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0")
18
18
  spec.executables = []
19
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
19
  spec.require_paths = ["lib"]
21
20
 
22
- spec.required_ruby_version = ">= 2.7"
21
+ spec.required_ruby_version = ">= 3.1"
23
22
 
24
23
  spec.add_dependency "test-kitchen"
25
24
  spec.add_dependency "vmware-vra", "~> 3.0", ">= 3.2.0" # 3.0 required for vRA 8.x
26
25
  spec.add_dependency "highline"
27
26
  spec.add_dependency "rack", ">= 1.6", "< 4.0"
28
- spec.add_dependency "ffi-yajl", ">= 2.2.3", "< 2.5.0"
29
- spec.add_development_dependency "rake", "~> 13.0"
30
- spec.add_development_dependency "rspec", "~> 3.2"
31
- spec.add_development_dependency "simplecov", "~> 0.10"
32
- spec.add_development_dependency "webmock", "~> 3.14"
33
- spec.add_development_dependency "chefstyle", "~> 2.2.1"
27
+ spec.add_dependency "ffi-yajl", ">= 2.2.3", "< 3.1.0"
34
28
  end