kitchen-terraform 3.3.1 → 4.0.0

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.md +45 -28
  5. data/lib/kitchen/driver/terraform.rb +87 -66
  6. data/lib/kitchen/provisioner/terraform.rb +1 -1
  7. data/lib/kitchen/terraform/client_version_verifier.rb +3 -3
  8. data/lib/kitchen/terraform/command/output.rb +43 -40
  9. data/lib/kitchen/{verifier/terraform/configure_inspec_runner_host.rb → terraform/config_attribute/systems.rb} +18 -11
  10. data/lib/kitchen/terraform/config_attribute/variable_files.rb +1 -1
  11. data/lib/kitchen/terraform/config_schemas/system.rb +555 -0
  12. data/lib/kitchen/terraform/{breaking/kitchen_instance.rb → config_schemas/systems.rb} +16 -5
  13. data/lib/kitchen/terraform/configurable.rb +2 -6
  14. data/lib/kitchen/terraform/inspec.rb +74 -0
  15. data/lib/kitchen/terraform/inspec_options_mapper.rb +49 -0
  16. data/lib/kitchen/terraform/inspec_with_hosts.rb +49 -0
  17. data/lib/kitchen/terraform/inspec_without_hosts.rb +44 -0
  18. data/lib/kitchen/terraform/shell_out.rb +13 -10
  19. data/lib/kitchen/terraform/system.rb +120 -0
  20. data/lib/kitchen/terraform/system_attrs_resolver.rb +57 -0
  21. data/lib/kitchen/terraform/system_hosts_resolver.rb +45 -0
  22. data/lib/kitchen/terraform/version.rb +60 -17
  23. data/lib/kitchen/verifier/terraform.rb +162 -156
  24. metadata +45 -41
  25. metadata.gz.sig +0 -0
  26. data/lib/kitchen/terraform/config_attribute/groups.rb +0 -148
  27. data/lib/kitchen/terraform/config_schemas/groups.rb +0 -52
  28. data/lib/kitchen/terraform/deprecating/kitchen_instance.rb +0 -61
  29. data/lib/kitchen/terraform/kitchen_instance.rb +0 -49
  30. data/lib/kitchen/verifier/terraform/configure_inspec_runner_attributes.rb +0 -98
  31. data/lib/kitchen/verifier/terraform/configure_inspec_runner_backend.rb +0 -32
  32. data/lib/kitchen/verifier/terraform/configure_inspec_runner_controls.rb +0 -41
  33. data/lib/kitchen/verifier/terraform/configure_inspec_runner_port.rb +0 -40
  34. data/lib/kitchen/verifier/terraform/configure_inspec_runner_ssh_key.rb +0 -41
  35. data/lib/kitchen/verifier/terraform/configure_inspec_runner_user.rb +0 -40
  36. data/lib/kitchen/verifier/terraform/enumerate_groups_and_hostnames.rb +0 -82
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f583f33eb358a79ac661e3e108e4d236f7fe4f303f9022947efb8a83b05cb1b2
4
- data.tar.gz: 32fcb9bb51b28bb1a806d9137055edc6a27adc668906da9e4d3cbc1e0fc81daf
3
+ metadata.gz: 5921183f754b305ec9a7858690b3fca108721241bbff30dd4ce36b2768d5a985
4
+ data.tar.gz: 5b66ac4f0369e0287cd23cdb3ee5a5322a59e64dd40bb6a5dc1b0e0f42a8393a
5
5
  SHA512:
6
- metadata.gz: c45754dc6cf770e90a5cf9ba2d1e664a19b3495c14a1ecb60283feac045cf0cfef916b5246a79f1f8f3b008c6e5a4ff32801465ce6ed1b056af06b465a3784be
7
- data.tar.gz: 66af7f6b159e36b97c1c5c331dd1409b2a9143471c0be43e506a401836acfb1904fd6e8b8fb2dfae8d107d9953f395ceaef6ca2091a32319eeacc0c092b8b06e
6
+ metadata.gz: 1b1cb8ec7d383ebee037e69062fc5494bc4c730b6dbbbb53056fade27472258284bd0b13bfd53b2e171d04e032b42723bb89a4df22c911ccb7ceacca9e7fc1b8
7
+ data.tar.gz: d6561c34bcae17b877cc62c520e3dd3495c75c3c107ee5f657db9ecaf41b16c55e6f45a8770e7092ac35b5fed2f4d0fc77a56490da2e875f50bfe0735a933df3
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  [![Build status][build-status-shield]][build-status]
10
10
  [![Test coverage][test-coverage-shield]][test-coverage]
11
11
  [![Maintainability][maintainability-shield]][maintainability]
12
- [![Dependencies][gemnasium-shield]][gemnasium]
12
+ [![Dependencies][hakiri-shield]][hakiri]
13
13
 
14
14
  [![Gitter chat][gitter-shield]][gitter]
15
15
 
@@ -19,7 +19,7 @@ which enable a system to use Test Kitchen to converge a
19
19
  state with [InSpec][inspec] controls.
20
20
 
21
21
  As Kitchen-Terraform integrates several distinctive technologies in a
22
- nontrivial manner, reviewing the documenation of each of the
22
+ nontrivial manner, reviewing the documentation of each of the
23
23
  aforementioned products is strongly encouraged.
24
24
 
25
25
  ## Installation
@@ -34,7 +34,7 @@ Installation instructions can be found in the
34
34
  [Terraform: Install Terraform][terraform-install] article.
35
35
 
36
36
  Kitchen-Terraform supports versions of Terraform in the interval of
37
- `>= 0.10.2, < 0.12.0`.
37
+ `>= 0.11.4, < 0.12.0`.
38
38
 
39
39
  [tfenv] can be used to manage versions of Terraform on the system.
40
40
 
@@ -48,7 +48,7 @@ Installation instructions can be found in the
48
48
 
49
49
  Kitchen-Terraform aims to support all versions of Ruby that are in
50
50
  ["normal" or "security" maintenance][ruby-branches], which is currently
51
- the interval of `>= 2.2, < 2.5`.
51
+ the interval of `>= 2.3, < 2.6`.
52
52
 
53
53
  [rbenv] can be used to manage versions of Ruby on the system.
54
54
 
@@ -75,7 +75,7 @@ the semantic versioning of the Ruby gem.
75
75
  source "https://rubygems.org/" do
76
76
  gem(
77
77
  "kitchen-terraform",
78
- "~> 3.1"
78
+ "~> 4.0"
79
79
  )
80
80
  end
81
81
  ```
@@ -103,7 +103,7 @@ example.
103
103
  > Installing Kitchen-Terraform with RubyGems
104
104
 
105
105
  ```sh
106
- gem install kitchen-terraform --version 3.1.0
106
+ gem install kitchen-terraform --version 4.0.0
107
107
  ```
108
108
 
109
109
  This approach is not recommended as it requires more effort to install
@@ -141,11 +141,10 @@ which utilizes the [Docker provider][docker-provider].
141
141
 
142
142
  The test system is assumed to be running Ubuntu 17.04.
143
143
 
144
- Kitchen-Terraform and its dependencies are assumed to have been
145
- installed on the test system as described in the
146
- [Installation](#installation) section.
144
+ Terraform, Ruby, and Bundler are assumed to have been installed on the
145
+ test system as described in the [Installation](#installation) section.
147
146
 
148
- The [Docker Community Editiion][docker-community-edition] is assumed to
147
+ The [Docker Community Edition][docker-community-edition] is assumed to
149
148
  have been installed on the test system.
150
149
 
151
150
  The working directory on the test system is assumed to contain a
@@ -157,8 +156,8 @@ hierarchy of files comprising the following blocks.
157
156
  .
158
157
  ├── .kitchen.yml
159
158
  ├── Gemfile
160
- ├── Gemfile.lock
161
159
  ├── main.tf
160
+ ├── outputs.tf
162
161
  └── test
163
162
  └── integration
164
163
  └── example
@@ -167,6 +166,14 @@ hierarchy of files comprising the following blocks.
167
166
  └── inspec.yml
168
167
  ```
169
168
 
169
+ > Gemfile
170
+
171
+ ```ruby
172
+ source "https://rubygems.org/"
173
+
174
+ gem 'kitchen-terraform'
175
+ ```
176
+
170
177
  > ./.kitchen.yml (Test Kitchen configuration)
171
178
 
172
179
  ```yaml
@@ -176,16 +183,15 @@ driver:
176
183
  provisioner:
177
184
  name: terraform
178
185
 
179
- transport:
180
- name: ssh
181
- password: root
182
-
183
186
  verifier:
184
187
  name: terraform
185
- groups:
188
+ systems:
186
189
  - name: container
190
+ backend: ssh
191
+ hosts_output: container_hostname
192
+ password: root
187
193
  port: 2222
188
- username: root
194
+ user: root
189
195
 
190
196
  platforms:
191
197
  - name: ubuntu
@@ -222,6 +228,15 @@ resource "docker_container" "ubuntu" {
222
228
  }
223
229
  ```
224
230
 
231
+ > ./outputs.tf
232
+
233
+ ```hcl
234
+ output "container_hostname" {
235
+ description = "The hostname of the container."
236
+ value = "127.0.0.1"
237
+ }
238
+ ```
239
+
225
240
  > ./test/integration/example/inspec.yml
226
241
 
227
242
  ```yaml
@@ -253,6 +268,7 @@ and verify that the container is running Ubuntu.
253
268
  > Verifying with Kitchen-Terraform
254
269
 
255
270
  ```sh
271
+ $ bundle install
256
272
  $ bundle exec kitchen test
257
273
  -----> Starting Kitchen...
258
274
  ...
@@ -267,7 +283,7 @@ $$$$$$ Running command `terraform apply...`
267
283
  Finished converging <example-ubuntu>...
268
284
  ...
269
285
  -----> Verifying <example-ubuntu>...
270
- Verifying host 'localhost' of group 'container'
286
+ Verifying host 'localhost' of system 'container'
271
287
  ...
272
288
  ✔ operating_system: the operating system is Ubuntu
273
289
  ...
@@ -345,8 +361,9 @@ Kitchen-Terraform is maintained by New Context.
345
361
  Kitchen-Terraform is distributed under the [Apache License][license].
346
362
 
347
363
  <!-- Markdown links and image definitions -->
348
- [build-status-shield]: https://img.shields.io/travis/newcontext-oss/kitchen-terraform.svg?style=plastic
349
- [build-status]: https://travis-ci.org/newcontext-oss/kitchen-terraform
364
+
365
+ [build-status-shield]: https://img.shields.io/travis/newcontext-oss/kitchen-terraform.svg
366
+ [build-status]: https://travis-ci.com/newcontext-oss/kitchen-terraform
350
367
  [bundler-getting-started]: https://bundler.io/#getting-started
351
368
  [bundler-in-depth]: https://bundler.io/gemfile.html
352
369
  [bundler]: https://bundler.io/index.html#getting-started
@@ -356,19 +373,19 @@ Kitchen-Terraform is distributed under the [Apache License][license].
356
373
  [docker]: https://www.docker.com/
357
374
  [docker-community-edition]: https://store.docker.com/editions/community/docker-ce-server-ubuntu
358
375
  [docker-provider]: https://www.terraform.io/docs/providers/docker/index.html
359
- [gem-downloads-total-shield]: https://img.shields.io/gem/dt/kitchen-terraform.svg?style=plastic
360
- [gem-downloads-version-shield]: https://img.shields.io/gem/dtv/kitchen-terraform.svg?style=plastic
361
- [gem-version-shield]: https://img.shields.io/gem/v/kitchen-terraform.svg?style=plastic
362
- [gemnasium-shield]: https://img.shields.io/gemnasium/newcontext-oss/kitchen-terraform.svg?style=plastic
363
- [gemnasium]: https://beta.gemnasium.com/projects/github.com/newcontext-oss/kitchen-terraform
364
- [gitter-shield]: https://img.shields.io/gitter/room/kitchen-terraform/Lobby.svg?style=plastic
376
+ [gem-downloads-total-shield]: https://img.shields.io/gem/dt/kitchen-terraform.svg
377
+ [gem-downloads-version-shield]: https://img.shields.io/gem/dtv/kitchen-terraform.svg
378
+ [gem-version-shield]: https://img.shields.io/gem/v/kitchen-terraform.svg
379
+ [hakiri-shield]: https://hakiri.io/github/newcontext-oss/kitchen-terraform/master.svg
380
+ [hakiri]: https://hakiri.io/github/newcontext-oss/kitchen-terraform/
381
+ [gitter-shield]: https://img.shields.io/gitter/room/kitchen-terraform/Lobby.svg
365
382
  [gitter]: https://gitter.im/kitchen-terraform/Lobby
366
383
  [inspec]: https://www.inspec.io/
367
384
  [kitchen-terraform-gem]: https://rubygems.org/gems/kitchen-terraform
368
385
  [kitchen-terraform-logo]: https://raw.githubusercontent.com/newcontext-oss/kitchen-terraform/master/assets/logo.png
369
386
  [kitchen-terraform-tutorials]: https://newcontext-oss.github.io/kitchen-terraform/tutorials/
370
387
  [license]: https://github.com/newcontext-oss/kitchen-terraform/blob/master/LICENSE
371
- [maintainability-shield]: https://img.shields.io/codeclimate/maintainability/newcontext-oss/kitchen-terraform.svg?style=plastic
388
+ [maintainability-shield]: https://api.codeclimate.com/v1/badges/73d4a2280a30e680bac4/maintainability
372
389
  [maintainability]: https://codeclimate.com/github/newcontext-oss/kitchen-terraform/maintainability
373
390
  [new-context-github]: https://github.com/newcontext
374
391
  [new-context-linkedin]: https://www.linkedin.com/company/-new-context-
@@ -387,7 +404,7 @@ Kitchen-Terraform is distributed under the [Apache License][license].
387
404
  [terraform-provisioner]: http://www.rubydoc.info/github/newcontext-oss/kitchen-terraform/Kitchen/Provisioner/Terraform
388
405
  [terraform-verifier]: http://www.rubydoc.info/github/newcontext-oss/kitchen-terraform/Kitchen/Verifier/Terraform
389
406
  [terraform]: https://www.terraform.io/
390
- [test-coverage-shield]: https://img.shields.io/codeclimate/c/newcontext-oss/kitchen-terraform.svg?style=plastic
407
+ [test-coverage-shield]: https://api.codeclimate.com/v1/badges/73d4a2280a30e680bac4/test_coverage
391
408
  [test-coverage]: https://codeclimate.com/github/newcontext-oss/kitchen-terraform/test_coverage
392
409
  [test-kitchen-configuration-file]: https://docs.chef.io/config_yml_kitchen.html
393
410
  [test-kitchen]: http://kitchen.ci/index.html
@@ -97,7 +97,7 @@ end
97
97
  # ===== Destroying the Terraform State
98
98
  #
99
99
  # terraform destroy \
100
- # -force \
100
+ # -auto-approve \
101
101
  # -lock=<lock> \
102
102
  # -lock-timeout=<lock_timeout>s \
103
103
  # -input=false \
@@ -182,6 +182,13 @@ end
182
182
  class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
183
183
  kitchen_driver_api_version 2
184
184
 
185
+ no_parallel_for(
186
+ :create,
187
+ :converge,
188
+ :setup,
189
+ :destroy
190
+ )
191
+
185
192
  include ::Kitchen::Terraform::ConfigAttribute::BackendConfigurations
186
193
 
187
194
  include ::Kitchen::Terraform::ConfigAttribute::Color
@@ -204,35 +211,6 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
204
211
 
205
212
  include ::Kitchen::Terraform::Configurable
206
213
 
207
- # This method queries for the names of the action methods which must be run in serial via a shared mutex.
208
- #
209
- # If the version satisfies the requirement of ~> 3.3 then no names are returned.
210
- #
211
- # If the version satisfies the requirement of >= 4 then +:create+, +:converge+, +:setup+, and +:destroy+ are returned.
212
- #
213
- # @param version [::Kitchen::Terraform::Version] the version to compare against the requirements.
214
- # @return [::Array<Symbol>] the action method names.
215
- def self.serial_actions(version: ::Kitchen::Terraform::Version.new)
216
- version
217
- .if_satisfies requirement: ::Gem::Requirement.new("~> 3.3") do
218
- no_parallel_for
219
- end
220
-
221
- version
222
- .if_satisfies requirement: ::Gem::Requirement.new(">= 4") do
223
- super()
224
- .empty? and
225
- no_parallel_for(
226
- :create,
227
- :converge,
228
- :setup,
229
- :destroy
230
- )
231
- end
232
-
233
- super()
234
- end
235
-
236
214
  # Applies changes to the state by selecting the test workspace, updating the dependency modules, validating the root
237
215
  # module, applying the state changes, and retrieving the state output.
238
216
  #
@@ -246,8 +224,12 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
246
224
  apply_run_apply
247
225
  ::Kitchen::Terraform::Command::Output
248
226
  .run(
249
- duration: config_command_timeout,
250
- logger: logger,
227
+ options:
228
+ {
229
+ cwd: config_root_module_directory,
230
+ live_stream: logger,
231
+ timeout: config_command_timeout
232
+ },
251
233
  &block
252
234
  )
253
235
  end
@@ -300,8 +282,12 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
300
282
  ::Kitchen::Terraform::ShellOut
301
283
  .run(
302
284
  command: "version",
303
- duration: 600,
304
- logger: logger
285
+ options:
286
+ {
287
+ cwd: ::Dir.pwd,
288
+ live_stream: logger,
289
+ timeout: 600
290
+ }
305
291
  )
306
292
  )
307
293
  )
@@ -328,10 +314,13 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
328
314
  "#{parallelism_flag} " \
329
315
  "-refresh=true " \
330
316
  "#{variables_flags} " \
331
- "#{variable_files_flags} " \
332
- "#{root_module_directory}",
333
- duration: config_command_timeout,
334
- logger: logger
317
+ "#{variable_files_flags}",
318
+ options:
319
+ {
320
+ cwd: config_root_module_directory,
321
+ live_stream: logger,
322
+ timeout: config_command_timeout
323
+ }
335
324
  )
336
325
  end
337
326
 
@@ -339,9 +328,13 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
339
328
  def apply_run_get
340
329
  ::Kitchen::Terraform::ShellOut
341
330
  .run(
342
- command: "get -update #{root_module_directory}",
343
- duration: config_command_timeout,
344
- logger: logger
331
+ command: "get -update",
332
+ options:
333
+ {
334
+ cwd: config_root_module_directory,
335
+ live_stream: logger,
336
+ timeout: config_command_timeout
337
+ }
345
338
  )
346
339
  end
347
340
 
@@ -354,10 +347,13 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
354
347
  "-check-variables=true " \
355
348
  "#{color_flag} " \
356
349
  "#{variables_flags} " \
357
- "#{variable_files_flags} " \
358
- "#{root_module_directory}",
359
- duration: config_command_timeout,
360
- logger: logger
350
+ "#{variable_files_flags}",
351
+ options:
352
+ {
353
+ cwd: config_root_module_directory,
354
+ live_stream: logger,
355
+ timeout: config_command_timeout
356
+ }
361
357
  )
362
358
  end
363
359
 
@@ -392,10 +388,13 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
392
388
  "-get=true " \
393
389
  "-get-plugins=true " \
394
390
  "#{plugin_directory_flag} " \
395
- "-verify-plugins=true " \
396
- "#{root_module_directory}",
397
- duration: config_command_timeout,
398
- logger: logger
391
+ "-verify-plugins=true",
392
+ options:
393
+ {
394
+ cwd: config_root_module_directory,
395
+ live_stream: logger,
396
+ timeout: config_command_timeout
397
+ }
399
398
  )
400
399
  end
401
400
 
@@ -405,7 +404,7 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
405
404
  .run(
406
405
  command:
407
406
  "destroy " \
408
- "-force " \
407
+ "-auto-approve " \
409
408
  "#{lock_flag} " \
410
409
  "#{lock_timeout_flag} " \
411
410
  "-input=false " \
@@ -413,10 +412,13 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
413
412
  "#{parallelism_flag} " \
414
413
  "-refresh=true " \
415
414
  "#{variables_flags} " \
416
- "#{variable_files_flags} " \
417
- "#{root_module_directory}",
418
- duration: config_command_timeout,
419
- logger: logger
415
+ "#{variable_files_flags}",
416
+ options:
417
+ {
418
+ cwd: config_root_module_directory,
419
+ live_stream: logger,
420
+ timeout: config_command_timeout
421
+ }
420
422
  )
421
423
  end
422
424
 
@@ -436,10 +438,13 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
436
438
  "-get=true " \
437
439
  "-get-plugins=true " \
438
440
  "#{plugin_directory_flag} " \
439
- "-verify-plugins=true " \
440
- "#{root_module_directory}",
441
- duration: config_command_timeout,
442
- logger: logger
441
+ "-verify-plugins=true",
442
+ options:
443
+ {
444
+ cwd: config_root_module_directory,
445
+ live_stream: logger,
446
+ timeout: config_command_timeout
447
+ }
443
448
  )
444
449
  end
445
450
 
@@ -448,8 +453,12 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
448
453
  ::Kitchen::Terraform::ShellOut
449
454
  .run(
450
455
  command: "workspace delete kitchen-terraform-#{instance_name}",
451
- duration: config_command_timeout,
452
- logger: logger
456
+ options:
457
+ {
458
+ cwd: config_root_module_directory,
459
+ live_stream: logger,
460
+ timeout: config_command_timeout
461
+ }
453
462
  )
454
463
  end
455
464
 
@@ -458,8 +467,12 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
458
467
  ::Kitchen::Terraform::ShellOut
459
468
  .run(
460
469
  command: "workspace select default",
461
- duration: config_command_timeout,
462
- logger: logger
470
+ options:
471
+ {
472
+ cwd: config_root_module_directory,
473
+ live_stream: logger,
474
+ timeout: config_command_timeout
475
+ }
463
476
  )
464
477
  end
465
478
 
@@ -500,15 +513,23 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
500
513
  ::Kitchen::Terraform::ShellOut
501
514
  .run(
502
515
  command: "workspace select kitchen-terraform-#{instance_name}",
503
- duration: config_command_timeout,
504
- logger: logger
516
+ options:
517
+ {
518
+ cwd: config_root_module_directory,
519
+ live_stream: logger,
520
+ timeout: config_command_timeout
521
+ }
505
522
  )
506
523
  rescue ::Kitchen::Terraform::Error
507
524
  ::Kitchen::Terraform::ShellOut
508
525
  .run(
509
526
  command: "workspace new kitchen-terraform-#{instance_name}",
510
- duration: config_command_timeout,
511
- logger: logger
527
+ options:
528
+ {
529
+ cwd: config_root_module_directory,
530
+ live_stream: logger,
531
+ timeout: config_command_timeout
532
+ }
512
533
  )
513
534
  end
514
535