test-kitchen 1.23.2 → 1.23.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -0
  3. data/.gitmodules +0 -0
  4. data/.travis.yml +0 -4
  5. data/CHANGELOG.md +40 -0
  6. data/MAINTAINERS.md +2 -1
  7. data/Rakefile +9 -0
  8. data/docs/CONTRIBUTING.md +8 -0
  9. data/docs/LICENSE +22 -0
  10. data/docs/README.md +78 -0
  11. data/docs/archetypes/default.md +6 -0
  12. data/docs/config.toml +36 -0
  13. data/docs/content/docs/_index.md +5 -0
  14. data/docs/content/docs/drivers/_index.md +27 -0
  15. data/docs/content/docs/drivers/azurerm.md +44 -0
  16. data/docs/content/docs/drivers/vagrant.md +39 -0
  17. data/docs/content/docs/getting-started/00-introduction.md +14 -0
  18. data/docs/content/docs/getting-started/01-installing.md +64 -0
  19. data/docs/content/docs/getting-started/02-getting-help.md +59 -0
  20. data/docs/content/docs/getting-started/03-creating-cookbook.md +46 -0
  21. data/docs/content/docs/getting-started/04-kitchen-yml.md +56 -0
  22. data/docs/content/docs/getting-started/05-instances.md +79 -0
  23. data/docs/content/docs/getting-started/06-writing-recipe.md +21 -0
  24. data/docs/content/docs/getting-started/07-running-converge.md +134 -0
  25. data/docs/content/docs/getting-started/08-manually-verifying.md +55 -0
  26. data/docs/content/docs/getting-started/09-writing-test.md +49 -0
  27. data/docs/content/docs/getting-started/10-running-verify.md +120 -0
  28. data/docs/content/docs/getting-started/11-running-test.md +168 -0
  29. data/docs/content/docs/getting-started/12-adding-platform.md +206 -0
  30. data/docs/content/docs/getting-started/13-adding-feature.md +30 -0
  31. data/docs/content/docs/getting-started/14-adding-suite.md +60 -0
  32. data/docs/content/docs/getting-started/15-adding-test.md +66 -0
  33. data/docs/content/docs/getting-started/16-adding-recipe.md +53 -0
  34. data/docs/content/docs/getting-started/17-excluding-platforms.md +101 -0
  35. data/docs/content/docs/getting-started/18-next-steps.md +23 -0
  36. data/docs/content/docs/getting-started/_index.md +5 -0
  37. data/docs/content/docs/provisioners/_index.md +36 -0
  38. data/docs/content/docs/provisioners/chef.md +69 -0
  39. data/docs/content/docs/provisioners/shell.md +31 -0
  40. data/docs/content/docs/reference/_index.md +5 -0
  41. data/docs/content/docs/reference/configuration.md +53 -0
  42. data/docs/content/docs/reference/examples.md +97 -0
  43. data/docs/content/docs/reference/faq.md +58 -0
  44. data/docs/content/docs/reference/fixtures.md +32 -0
  45. data/docs/content/docs/reference/glossary.md +34 -0
  46. data/docs/content/docs/reference/lifecycle-hooks.md +68 -0
  47. data/docs/content/docs/reference/reboots.md +24 -0
  48. data/docs/content/docs/verifiers/_index.md +14 -0
  49. data/docs/content/docs/verifiers/inspec.md +44 -0
  50. data/docs/content/docs/verifiers/serverspec.md +20 -0
  51. data/docs/static/images/chef-logo.png +0 -0
  52. data/docs/static/images/chef-logo.svg +1 -0
  53. data/docs/static/images/github-banner.png +0 -0
  54. data/docs/static/images/github-banner.svg +71 -0
  55. data/docs/static/images/kitchen-logo.png +0 -0
  56. data/docs/static/images/logo-block.svg +222 -0
  57. data/docs/static/images/logo.png +0 -0
  58. data/docs/static/images/logos-group.png +0 -0
  59. data/docs/static/images/terminal-1.png +0 -0
  60. data/docs/static/images/terminal-1.svg +589 -0
  61. data/docs/static/images/terminal-2.png +0 -0
  62. data/docs/static/images/terminal-2.svg +235 -0
  63. data/docs/static/images/terminal-3.png +0 -0
  64. data/docs/static/images/terminal-3.svg +439 -0
  65. data/docs/static/index.html +59 -0
  66. data/docs/static/javascripts/all.js +348 -0
  67. data/docs/static/javascripts/vendor/foundation.min.js +4 -0
  68. data/docs/static/javascripts/vendor/jquery.min.js +5 -0
  69. data/docs/static/javascripts/vendor/what-input.js +336 -0
  70. data/docs/static/stylesheets/site.css +4667 -0
  71. data/docs/themes/kitchen/layouts/_default/baseof.html +53 -0
  72. data/docs/themes/kitchen/layouts/_default/list.html +4 -0
  73. data/docs/themes/kitchen/layouts/_default/redirect.html +10 -0
  74. data/docs/themes/kitchen/layouts/_default/single.html +6 -0
  75. data/docs/themes/kitchen/layouts/partials/core/head.html +6 -0
  76. data/docs/themes/kitchen/layouts/partials/kitchen/footer.html +18 -0
  77. data/docs/themes/kitchen/layouts/partials/kitchen/head.html +4 -0
  78. data/docs/themes/kitchen/layouts/partials/kitchen/header.html +26 -0
  79. data/docs/themes/kitchen/layouts/partials/search-docs.html +3 -0
  80. data/docs/themes/kitchen/layouts/partials/sidebar.html +33 -0
  81. data/docs/themes/kitchen/layouts/shortcodes/button.html +1 -0
  82. data/docs/themes/kitchen/layouts/shortcodes/codeblock.html +8 -0
  83. data/docs/themes/kitchen/layouts/shortcodes/cta.html +5 -0
  84. data/docs/themes/kitchen/layouts/shortcodes/danger.html +1 -0
  85. data/docs/themes/kitchen/layouts/shortcodes/example_fqdn.html +1 -0
  86. data/docs/themes/kitchen/layouts/shortcodes/info.html +1 -0
  87. data/docs/themes/kitchen/layouts/shortcodes/ol-styled.html +3 -0
  88. data/docs/themes/kitchen/layouts/shortcodes/success.html +1 -0
  89. data/docs/themes/kitchen/layouts/shortcodes/tip.html +1 -0
  90. data/docs/themes/kitchen/layouts/shortcodes/warning.html +1 -0
  91. data/docs/themes/kitchen/static/css/kitchen.css +10 -0
  92. data/docs/themes/kitchen/static/css/kitchen.css.map +7 -0
  93. data/docs/themes/kitchen/static/fonts/Muli-Bold.ttf +0 -0
  94. data/docs/themes/kitchen/static/fonts/Muli-Regular.ttf +0 -0
  95. data/docs/themes/kitchen/static/fonts/Muli-SemiBold.ttf +0 -0
  96. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.eot +0 -0
  97. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.svg +1104 -0
  98. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.ttf +0 -0
  99. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.woff +0 -0
  100. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.woff2 +0 -0
  101. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.eot +0 -0
  102. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.svg +372 -0
  103. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.ttf +0 -0
  104. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.woff +0 -0
  105. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.woff2 +0 -0
  106. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.eot +0 -0
  107. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.svg +1896 -0
  108. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.ttf +0 -0
  109. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.woff +0 -0
  110. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.woff2 +0 -0
  111. data/docs/themes/kitchen/static/images/chef-logo-light.svg +36 -0
  112. data/docs/themes/kitchen/static/images/chef-logo-white.svg +38 -0
  113. data/docs/themes/kitchen/static/images/chef-logo.svg +37 -0
  114. data/docs/themes/kitchen/static/images/favicon.ico +0 -0
  115. data/docs/themes/kitchen/static/js/scripts-all.js +7 -0
  116. data/docs/themes/kitchen/static/js/source/chef-hugo.js +116 -0
  117. data/docs/themes/kitchen/static/js/source/omnitruck.js +82 -0
  118. data/docs/themes/kitchen/static/js/source/segment.js +52 -0
  119. data/docs/themes/kitchen/static/sass/_buttons.scss +161 -0
  120. data/docs/themes/kitchen/static/sass/_core.scss +24 -0
  121. data/docs/themes/kitchen/static/sass/_forms.scss +14 -0
  122. data/docs/themes/kitchen/static/sass/_mixins.scss +133 -0
  123. data/docs/themes/kitchen/static/sass/_typography.scss +34 -0
  124. data/docs/themes/kitchen/static/sass/_variables.scss +82 -0
  125. data/docs/themes/kitchen/static/sass/kitchen.scss +7 -0
  126. data/docs/themes/kitchen/static/sass/kitchen/_footer.scss +50 -0
  127. data/docs/themes/kitchen/static/sass/kitchen/_header.scss +187 -0
  128. data/docs/themes/kitchen/static/sass/kitchen/_homepage.scss +27 -0
  129. data/docs/themes/kitchen/static/sass/kitchen/_utility-bar.scss +173 -0
  130. data/docs/themes/kitchen/static/sass/partials/_alerts.scss +32 -0
  131. data/docs/themes/kitchen/static/sass/partials/_bg.scss +19 -0
  132. data/docs/themes/kitchen/static/sass/partials/_blurbs.scss +25 -0
  133. data/docs/themes/kitchen/static/sass/partials/_callout.scss +15 -0
  134. data/docs/themes/kitchen/static/sass/partials/_cards.scss +54 -0
  135. data/docs/themes/kitchen/static/sass/partials/_dropdown.scss +77 -0
  136. data/docs/themes/kitchen/static/sass/partials/_grid.scss +87 -0
  137. data/docs/themes/kitchen/static/sass/partials/_padding.scss +73 -0
  138. data/docs/themes/kitchen/static/sass/partials/_sidebar.scss +71 -0
  139. data/docs/themes/kitchen/static/sass/partials/_tabs.scss +125 -0
  140. data/docs/themes/kitchen/static/sass/typography/_chroma.scss +366 -0
  141. data/docs/themes/kitchen/static/sass/typography/_code.scss +72 -0
  142. data/docs/themes/kitchen/static/sass/typography/_headers.scss +90 -0
  143. data/docs/themes/kitchen/static/sass/typography/_links.scss +127 -0
  144. data/docs/themes/kitchen/static/sass/typography/_lists.scss +155 -0
  145. data/docs/themes/kitchen/static/sass/typography/_prose.scss +29 -0
  146. data/docs/themes/kitchen/static/sass/typography/_text.scss +221 -0
  147. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_animated.scss +20 -0
  148. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_bordered-pulled.scss +20 -0
  149. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_core.scss +16 -0
  150. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_fixed-width.scss +6 -0
  151. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_icons.scss +992 -0
  152. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_larger.scss +23 -0
  153. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_list.scss +18 -0
  154. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_mixins.scss +57 -0
  155. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_rotated-flipped.scss +23 -0
  156. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_screen-reader.scss +5 -0
  157. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_stacked.scss +31 -0
  158. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_variables.scss +1005 -0
  159. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-brands.scss +21 -0
  160. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-regular.scss +22 -0
  161. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-solid.scss +23 -0
  162. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fontawesome.scss +16 -0
  163. data/docs/themes/kitchen/theme.toml +8 -0
  164. data/lib/kitchen/provisioner/chef_base.rb +6 -6
  165. data/lib/kitchen/transport/ssh.rb +2 -2
  166. data/lib/kitchen/transport/winrm.rb +32 -9
  167. data/lib/kitchen/version.rb +1 -1
  168. data/spec/kitchen/data_munger_spec.rb +13 -13
  169. data/spec/kitchen/driver/exec_spec.rb +1 -1
  170. data/spec/kitchen/lifecycle_hooks_spec.rb +6 -6
  171. data/spec/kitchen/provisioner/chef_base_spec.rb +26 -26
  172. data/spec/kitchen/transport/winrm_spec.rb +46 -10
  173. metadata +160 -3
@@ -0,0 +1,49 @@
1
+ ---
2
+ title: Writing a Test
3
+ slug: writing-test
4
+ menu:
5
+ docs:
6
+ parent: getting_started
7
+ weight: 90
8
+ ---
9
+
10
+ Being able to manually verify the Chef run is great but it would be even better if we had an executable test that would fail if our assumptions were ever proven to be false. Remember how we manually verified that Git was installed in the previous section? Seems like a pretty decent first test to me!
11
+
12
+ Kitchen presumes you want to test things and supports a variety of different frameworks for doing so. For the purpose of our guide we're going to use a framework called InSpec which kitchen consumes via the `kitchen-inspec` plugin. For more information on available testing frameworks check out [Verifiers](/docs/verifiers)
13
+
14
+ The cookbook skeleton already has conveniently created a test for you at `test/integration/default/default_test.rb`. Open this file in your editor and edit to match the following content:
15
+
16
+ ~~~
17
+ # # encoding: utf-8
18
+
19
+ describe package('git') do
20
+ it { should be_installed }
21
+ end
22
+ ~~~
23
+
24
+ Why `test/integration/default/default_test.rb`? Let's take a look again at our `.kitchen.yml`:
25
+
26
+ ~~~
27
+ # relevant sections of config
28
+ ---
29
+ verifier:
30
+ name: inspec
31
+
32
+ suites:
33
+ - name: default
34
+ run_list:
35
+ - recipe[git_cookbook::default]
36
+ verifier:
37
+ inspec_tests:
38
+ - test/integration/default
39
+ attributes:
40
+ ~~~
41
+
42
+ Here we are telling the verifier with the `inspec_tests` key to look in this directory. In our example we are pointing to a local directory but `kitchen-inspec` supports [remote locations](https://github.com/chef/kitchen-inspec#use-remote-inspec-profiles) such as git repositories or even a Chef Automate server.
43
+
44
+ Can you guess what this does even if you haven't seen an InSpec test before? If not, then take a look at InSpec's [package resource documentation](http://inspec.io/docs/reference/resources/package/). Otherwise your friends in the [Chef Community Slack](http://community-slack.chef.io/) should be able to help.
45
+
46
+ <div class="sidebar--footer">
47
+ <a class="button primary-cta" href="/docs/getting-started/running-verify">Next - kitchen verify</a>
48
+ <a class="sidebar--footer--back" href="/docs/getting-started/manually-verifying">Back to previous step</a>
49
+ </div>
@@ -0,0 +1,120 @@
1
+ ---
2
+ title: kitchen verify
3
+ slug: running-verify
4
+ menu:
5
+ docs:
6
+ parent: getting_started
7
+ weight: 100
8
+ ---
9
+
10
+ In order to execute our test, we use the command `kitchen verify`:
11
+
12
+ ~~~
13
+ $ kitchen verify default-ubuntu-1604
14
+ -----> Starting Kitchen (v1.23.2)
15
+ -----> Setting up <default-ubuntu-1604>...
16
+ Finished setting up <default-ubuntu-1604> (0m0.00s).
17
+ -----> Verifying <default-ubuntu-1604>...
18
+ Loaded tests from {:path=>".Users.cheeseplus.focus.git_cookbook.test.integration.default"}
19
+
20
+ Profile: tests from {:path=>"/Users/cheeseplus/focus/git_cookbook/test/integration/default"} (tests from {:path=>".Users.cheeseplus.focus.git_cookbook.test.integration.default"})
21
+ Version: (not specified)
22
+ Target: ssh://vagrant@127.0.0.1:2222
23
+
24
+ System Package git
25
+ ✔ should be installed
26
+
27
+ Test Summary: 1 successful, 0 failures, 0 skipped
28
+ Finished verifying <default-ubuntu-1604> (0m0.28s).
29
+ -----> Kitchen is finished. (0m3.33s)
30
+ ~~~
31
+
32
+ A few things of note from the output above:
33
+
34
+ * `Verifying <default-ubuntu-1604>` output corresponds to the start of the **Verify Action**
35
+ * `✔ git should be installed` is output from the InSpec test
36
+
37
+
38
+ <div class="callout">
39
+ <h3 class="callout--title">Pro Tip</h3>
40
+ If using a Bash-like shell, <code>echo $?</code> is will print the exit code of the last run shell command. This would show that the <code>kitchen verify</code> command exited cleanly with <code>0</code>.
41
+ </div>
42
+
43
+ Let's check the status of our instance again:
44
+
45
+ ~~~
46
+ $ kitchen list
47
+ Instance Driver Provisioner Verifier Transport Last Action Last Error
48
+ default-ubuntu-1604 Vagrant ChefZero Inspec Ssh Verified <None>
49
+ ~~~
50
+
51
+ So what would a failing test look like? Let's see. Open `test/integration/default/default_test.rb` and edit the test so that we're testing that git is _not_ installed:
52
+
53
+ ~~~
54
+ describe package('git') do
55
+ it { should_not be_installed }
56
+ end
57
+ ~~~
58
+
59
+ And re-run the **verify** subcommand:
60
+
61
+ ~~~
62
+ $ kitchen verify default-ubuntu-1604
63
+ -----> Starting Kitchen (v1.23.2)
64
+ -----> Verifying <default-ubuntu-1604>...
65
+ Loaded tests from {:path=>".Users.cheeseplus.focus.git_cookbook.test.integration.default"}
66
+
67
+ Profile: tests from {:path=>"/Users/cheeseplus/focus/git_cookbook/test/integration/default"} (tests from {:path=>".Users.cheeseplus.focus.git_cookbook.test.integration.default"})
68
+ Version: (not specified)
69
+ Target: ssh://vagrant@127.0.0.1:2222
70
+
71
+ System Package git
72
+ × should not be installed
73
+ expected System Package git not to be installed
74
+
75
+ Test Summary: 0 successful, 1 failure, 0 skipped
76
+ >>>>>> ------Exception-------
77
+ >>>>>> Class: Kitchen::ActionFailed
78
+ >>>>>> Message: 1 actions failed.
79
+ >>>>>> Verify failed on instance <default-ubuntu-1604>. Please see .kitchen/logs/default-ubuntu-1604.log for more details
80
+ >>>>>> ----------------------
81
+ >>>>>> Please see .kitchen/logs/kitchen.log for more details
82
+ >>>>>> Also try running `kitchen diagnose --all` for configuration
83
+ ~~~
84
+
85
+ Unsurprisingly, we get the message `× should not be installed` and kitchen throws an exception.
86
+
87
+ Let's revert our forced failure:
88
+
89
+ ~~~
90
+ describe package('git') do
91
+ it { should be_installed }
92
+ end
93
+ ~~~
94
+
95
+ Then verify our revert:
96
+
97
+ ~~~
98
+ $ kitchen verify default-ubuntu-1604
99
+ -----> Starting Kitchen (v1.23.2)
100
+ -----> Verifying <default-ubuntu-1604>...
101
+ Loaded tests from {:path=>".Users.cheeseplus.focus.git_cookbook.test.integration.default"}
102
+
103
+ Profile: tests from {:path=>"/Users/cheeseplus/focus/git_cookbook/test/integration/default"} (tests from {:path=>".Users.cheeseplus.focus.git_cookbook.test.integration.default"})
104
+ Version: (not specified)
105
+ Target: ssh://vagrant@127.0.0.1:2222
106
+
107
+ System Package git
108
+ ✔ should be installed
109
+
110
+ Test Summary: 1 successful, 0 failures, 0 skipped
111
+ Finished verifying <default-ubuntu-1604> (0m0.32s).
112
+ -----> Kitchen is finished. (0m3.06s)
113
+ ~~~
114
+
115
+ One of the advantages of `kitchen-inspec` is that the InSpec tests are executed from the host over the transport (SSH or WinRM) to the instance. No tests need to be uploaded to the instance itself.
116
+
117
+ <div class="sidebar--footer">
118
+ <a class="button primary-cta" href="/docs/getting-started/running-test">Next - kitchen test</a>
119
+ <a class="sidebar--footer--back" href="/docs/getting-started/writing-test">Back to previous step</a>
120
+ </div>
@@ -0,0 +1,168 @@
1
+ ---
2
+ title: kitchen test
3
+ slug: running-test
4
+ menu:
5
+ docs:
6
+ parent: getting_started
7
+ weight: 110
8
+ ---
9
+
10
+ Now it's time to introduce to the **test** meta-action which helps you automate all the previous actions so far into one command. Checking `kitchen list`, the "Last Action" of our instance should be "Verified". With this in mind, let's run `kitchen test`:
11
+
12
+ ~~~
13
+ -----> Starting Kitchen (v1.23.2)
14
+ -----> Cleaning up any prior instances of <default-ubuntu-1604>
15
+ -----> Destroying <default-ubuntu-1604>...
16
+ ==> default: Forcing shutdown of VM...
17
+ ==> default: Destroying VM and associated drives...
18
+ Vagrant instance <default-ubuntu-1604> destroyed.
19
+ Finished destroying <default-ubuntu-1604> (0m5.56s).
20
+ -----> Testing <default-ubuntu-1604>
21
+ -----> Creating <default-ubuntu-1604>...
22
+ Bringing machine 'default' up with 'virtualbox' provider...
23
+ ==> default: Importing base box 'bento/ubuntu-16.04'...
24
+ ==> default: Matching MAC address for NAT networking...
25
+ ==> default: Checking if box 'bento/ubuntu-16.04' is up to date...
26
+ ==> default: Setting the name of the VM: default-ubuntu-1604_default_1537638619562_49760
27
+ ==> default: Clearing any previously set network interfaces...
28
+ ==> default: Preparing network interfaces based on configuration...
29
+ default: Adapter 1: nat
30
+ ==> default: Forwarding ports...
31
+ default: 22 (guest) => 2222 (host) (adapter 1)
32
+ ==> default: Booting VM...
33
+ ==> default: Waiting for machine to boot. This may take a few minutes...
34
+ default: SSH address: 127.0.0.1:2222
35
+ default: SSH username: vagrant
36
+ default: SSH auth method: private key
37
+ default:
38
+ default: Vagrant insecure key detected. Vagrant will automatically replace
39
+ default: this with a newly generated keypair for better security.
40
+ default:
41
+ default: Inserting generated public key within guest...
42
+ default: Removing insecure key from the guest if it's present...
43
+ default: Key inserted! Disconnecting and reconnecting using new SSH key...
44
+ ==> default: Machine booted and ready!
45
+ ==> default: Checking for guest additions in VM...
46
+ ==> default: Setting hostname...
47
+ ==> default: Mounting shared folders...
48
+ default: /tmp/omnibus/cache => /Users/cheeseplus/.kitchen/cache
49
+ ==> default: Machine not provisioned because `--no-provision` is specified.
50
+ [SSH] Established
51
+ Vagrant instance <default-ubuntu-1604> created.
52
+ Finished creating <default-ubuntu-1604> (0m36.40s).
53
+ -----> Converging <default-ubuntu-1604>...
54
+ Preparing files for transfer
55
+ Preparing dna.json
56
+ Resolving cookbook dependencies with Berkshelf 7.0.6...
57
+ Removing non-cookbook files before transfer
58
+ Preparing validation.pem
59
+ Preparing client.rb
60
+ -----> Installing Chef Omnibus (install only if missing)
61
+ Downloading https://omnitruck.chef.io/install.sh to file /tmp/install.sh
62
+ Trying wget...
63
+ Download complete.
64
+ ubuntu 16.04 x86_64
65
+ Getting information for chef stable for ubuntu...
66
+ downloading https://omnitruck.chef.io/stable/chef/metadata?v=&p=ubuntu&pv=16.04&m=x86_64
67
+ to file /tmp/install.sh.1561/metadata.txt
68
+ Trying wget...
69
+ Download complete.
70
+ ubuntu 16.04 x86_64
71
+ Getting information for chef stable for ubuntu...
72
+ downloading https://omnitruck.chef.io/stable/chef/metadata?v=&p=ubuntu&pv=16.04&m=x86_64
73
+ to file /tmp/install.sh.1561/metadata.txt
74
+ trying wget...
75
+ sha1 174eb82ebe2eddc9c370487de6c124907f6d2f3a
76
+ sha256 70ce695d2bf9fb01279a726148c0600544f1cd431642fa98d6696ef4c1dfc3c9
77
+ url https://packages.chef.io/files/stable/chef/14.5.27/ubuntu/16.04/chef_14.5.27-1_amd64.deb
78
+ version 14.5.27
79
+ downloaded metadata file looks valid...
80
+ /tmp/omnibus/cache/chef_14.5.27-1_amd64.deb exists
81
+ Comparing checksum with sha256sum...
82
+
83
+ WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
84
+
85
+ You are installing an omnibus package without a version pin. If you are installing
86
+ on production servers via an automated process this is DANGEROUS and you will
87
+ be upgraded without warning on new releases, even to new major releases.
88
+ Letting the version float is only appropriate in desktop, test, development or
89
+ CI/CD environments.
90
+
91
+ WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
92
+
93
+ Installing chef
94
+ installing with dpkg...
95
+ Selecting previously unselected package chef.
96
+ (Reading database ... 38378 files and directories currently installed.)
97
+ Preparing to unpack .../cache/chef_14.5.27-1_amd64.deb ...
98
+ Unpacking chef (14.5.27-1) ...
99
+ Setting up chef (14.5.27-1) ...
100
+ Thank you for installing Chef!
101
+ Transferring files to <default-ubuntu-1604>
102
+ Starting Chef Client, version 14.5.27
103
+ Creating a new client identity for default-ubuntu-1604 using the validator key.
104
+ resolving cookbooks for run list: ["git_cookbook::default"]
105
+ Synchronizing Cookbooks:
106
+ - git_cookbook (0.1.0)
107
+ Installing Cookbook Gems:
108
+ Compiling Cookbooks...
109
+ Converging 1 resources
110
+ Recipe: git_cookbook::default
111
+ * apt_package[git] action install (up to date)
112
+
113
+ Running handlers:
114
+ Running handlers complete
115
+ Chef Client finished, 0/1 resources updated in 01 seconds
116
+ Downloading files from <default-ubuntu-1604>
117
+ Finished converging <default-ubuntu-1604> (0m22.87s).
118
+ -----> Setting up <default-ubuntu-1604>...
119
+ Finished setting up <default-ubuntu-1604> (0m0.00s).
120
+ -----> Verifying <default-ubuntu-1604>...
121
+ Loaded tests from {:path=>".Users.cheeseplus.focus.git_cookbook.test.integration.default"}
122
+
123
+ Profile: tests from {:path=>"/Users/cheeseplus/focus/git_cookbook/test/integration/default"} (tests from {:path=>".Users.cheeseplus.focus.git_cookbook.test.integration.default"})
124
+ Version: (not specified)
125
+ Target: ssh://vagrant@127.0.0.1:2222
126
+
127
+ System Package git
128
+ ✔ should be installed
129
+
130
+ Test Summary: 1 successful, 0 failures, 0 skipped
131
+ Finished verifying <default-ubuntu-1604> (0m0.29s).
132
+ -----> Destroying <default-ubuntu-1604>...
133
+ ==> default: Forcing shutdown of VM...
134
+ ==> default: Destroying VM and associated drives...
135
+ Vagrant instance <default-ubuntu-1604> destroyed.
136
+ Finished destroying <default-ubuntu-1604> (0m5.61s).
137
+ Finished testing <default-ubuntu-1604> (1m10.75s).
138
+ -----> Kitchen is finished. (1m13.21s)
139
+ ~~~
140
+
141
+ There's only one remaining action left that needs a mention: the **Destroy Action** which as one might expect, destroys the instance. With this in mind, here's what kitchen is doing in the **Test Action**:
142
+
143
+ 1. Destroys the instance if it exists
144
+ 2. Creates the instance
145
+ 3. Converges the instance
146
+ 4. Verifies the instance with InSpec
147
+ 5. Destroys the instance
148
+
149
+ A few details with regards to test:
150
+
151
+ * Kitchen will abort the run on the instance at the first sign of trouble. This means that if your Chef run fails then InSpec won't be run and the instance won't be destroyed. This gives you a chance to inspect the state of the instance and fix any issues.
152
+ * The behavior of the final destroy action can be overridden if desired. Check out the CLI help for the `--destroy` flag using `kitchen help test`.
153
+ * The primary use case in mind for this meta-action is in a Continuous Integration environment or a command for developers to run before check in or after a fresh clone. If you're using this in your test-code-verify development cycle it's going to quickly become very slow and frustrating. You're better off running the **converge** and **verify** sub-commands in development and save the **test** sub-command when you need to verify the end-to-end run of your code.
154
+
155
+ Finally, let's check the status of the instance:
156
+
157
+ ~~~
158
+ $ kitchen list
159
+ Instance Driver Provisioner Verifier Transport Last Action Last Error
160
+ default-ubuntu-1604 Vagrant ChefZero Inspec Ssh <Not Created> <None>
161
+ ~~~
162
+
163
+ Back to square one.
164
+
165
+ <div class="sidebar--footer">
166
+ <a class="button primary-cta" href="/docs/getting-started/adding-platform">Next - Adding a Platform</a>
167
+ <a class="sidebar--footer--back" href="/docs/getting-started/running-verify">Back to previous step</a>
168
+ </div>
@@ -0,0 +1,206 @@
1
+ ---
2
+ title: Adding a Platform
3
+ slug: adding-platform
4
+ menu:
5
+ docs:
6
+ parent: getting_started
7
+ weight: 120
8
+ ---
9
+
10
+ Now that we have Ubuntu working, let's add support for CentOS to our cookbook. This shouldn't be too bad. Open `.kitchen.yml` in your editor and the `centos-7` line to your platforms list so that it resembles:
11
+
12
+ ~~~
13
+ ---
14
+ driver:
15
+ name: vagrant
16
+
17
+ provisioner:
18
+ name: chef_zero
19
+
20
+ verifier:
21
+ name: inspec
22
+
23
+ platforms:
24
+ - name: ubuntu-16.04
25
+ - name: centos-7
26
+
27
+ suites:
28
+ - name: default
29
+ run_list:
30
+ - recipe[git_cookbook::default]
31
+ verifier:
32
+ inspec_tests:
33
+ - test/integration/default
34
+ attributes:
35
+ ~~~
36
+
37
+ Now let's check the status of our instances:
38
+
39
+ ~~~
40
+ $ kitchen list
41
+ Instance Driver Provisioner Verifier Transport Last Action Last Error
42
+ default-ubuntu-1604 Vagrant ChefZero Inspec Ssh <Not Created> <None>
43
+ default-centos-7 Vagrant ChefZero Inspec Ssh <Not Created> <None>
44
+ ~~~
45
+
46
+ We're going to use two shortcuts in the next command:
47
+
48
+ * Each instance has a simple state machine that tracks where it is in its lifecycle. Given its current state and the desired state, the instance is smart enough to run all actions in between current and desired.
49
+ * Any `kitchen` subcommand that takes an instance name as an argument can take a Ruby regular expression that will be used to glob a list of instances together. This means that `kitchen test ubuntu` would run the **test** action on all instances that had `ubuntu` in their name. Note that the **list** subcommand also takes the regex-globbing argument so feel free to experiment there.
50
+
51
+ In our next example we'll select the `default-centos-7` instance with simply `7` and will take it from uncreated to verified in one command.
52
+
53
+ Let's see how CentOS runs our cookbook:
54
+
55
+ ~~~
56
+ $ kitchen verify 7
57
+ -----> Starting Kitchen (v1.23.2)
58
+ -----> Creating <default-centos-7>...
59
+ Bringing machine 'default' up with 'virtualbox' provider...
60
+ ==> default: Box 'bento/centos-7' could not be found. Attempting to find and install...
61
+ default: Box Provider: virtualbox
62
+ default: Box Version: >= 0
63
+ ==> default: Loading metadata for box 'bento/centos-7'
64
+ default: URL: https://vagrantcloud.com/bento/centos-7
65
+ ==> default: Adding box 'bento/centos-7' (v201808.24.0) for provider: virtualbox
66
+ default: Downloading: https://vagrantcloud.com/bento/boxes/centos-7/versions/201808.24.0/providers/virtualbox.box
67
+ ==> default: Successfully added box 'bento/centos-7' (v201808.24.0) for 'virtualbox'!
68
+ ==> default: Importing base box 'bento/centos-7'...
69
+ ==> default: Matching MAC address for NAT networking...
70
+ ==> default: Checking if box 'bento/centos-7' is up to date...
71
+ ==> default: Setting the name of the VM: default-centos-7_default_1537639719415_97528
72
+ ==> default: Clearing any previously set network interfaces...
73
+ ==> default: Preparing network interfaces based on configuration...
74
+ default: Adapter 1: nat
75
+ ==> default: Forwarding ports...
76
+ default: 22 (guest) => 2222 (host) (adapter 1)
77
+ ==> default: Booting VM...
78
+ ==> default: Waiting for machine to boot. This may take a few minutes...
79
+ default: SSH address: 127.0.0.1:2222
80
+ default: SSH username: vagrant
81
+ default: SSH auth method: private key
82
+ default: Warning: Connection reset. Retrying...
83
+ default:
84
+ default: Vagrant insecure key detected. Vagrant will automatically replace
85
+ default: this with a newly generated keypair for better security.
86
+ default:
87
+ default: Inserting generated public key within guest...
88
+ default: Removing insecure key from the guest if it's present...
89
+ default: Key inserted! Disconnecting and reconnecting using new SSH key...
90
+ ==> default: Machine booted and ready!
91
+ ==> default: Checking for guest additions in VM...
92
+ ==> default: Setting hostname...
93
+ ==> default: Mounting shared folders...
94
+ default: /tmp/omnibus/cache => /Users/cheeseplus/.kitchen/cache
95
+ ==> default: Machine not provisioned because `--no-provision` is specified.
96
+ [SSH] Established
97
+ Vagrant instance <default-centos-7> created.
98
+ Finished creating <default-centos-7> (1m33.52s).
99
+ -----> Converging <default-centos-7>...
100
+ Preparing files for transfer
101
+ Preparing dna.json
102
+ Resolving cookbook dependencies with Berkshelf 7.0.6...
103
+ Removing non-cookbook files before transfer
104
+ Preparing validation.pem
105
+ Preparing client.rb
106
+ -----> Installing Chef Omnibus (install only if missing)
107
+ Downloading https://omnitruck.chef.io/install.sh to file /tmp/install.sh
108
+ Trying wget...
109
+ Download complete.
110
+ el 7 x86_64
111
+ Getting information for chef stable for el...
112
+ downloading https://omnitruck.chef.io/stable/chef/metadata?v=&p=el&pv=7&m=x86_64
113
+ to file /tmp/install.sh.3219/metadata.txt
114
+ trying wget...
115
+ sha1 47d9cc239e87a6f4eb3b7d15de6bb68aa66f993f
116
+ sha256 43e9a1ebe8aec723bf4e8503530348d2121fc6ee5a3b035ac4daf87f1712f5b4
117
+ url https://packages.chef.io/files/stable/chef/14.5.27/el/7/chef-14.5.27-1.el7.x86_64.rpm
118
+ version 14.5.27
119
+ downloaded metadata file looks valid...
120
+ /tmp/omnibus/cache/chef-14.5.27-1.el7.x86_64.rpm exists
121
+ Comparing checksum with sha256sum...
122
+
123
+ WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
124
+
125
+ You are installing an omnibus package without a version pin. If you are installing
126
+ on production servers via an automated process this is DANGEROUS and you will
127
+ be upgraded without warning on new releases, even to new major releases.
128
+ Letting the version float is only appropriate in desktop, test, development or
129
+ CI/CD environments.
130
+
131
+ WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
132
+
133
+ Installing chef
134
+ installing with rpm...
135
+ warning: /tmp/omnibus/cache/chef-14.5.27-1.el7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY
136
+ Preparing... ################################# [100%]
137
+ Updating / installing...
138
+ 1:chef-14.5.27-1.el7 ################################# [100%]
139
+ Thank you for installing Chef!
140
+ Transferring files to <default-centos-7>
141
+ Starting Chef Client, version 14.5.27
142
+ Creating a new client identity for default-centos-7 using the validator key.
143
+ resolving cookbooks for run list: ["git_cookbook::default"]
144
+ Synchronizing Cookbooks:
145
+ - git_cookbook (0.1.0)
146
+ Installing Cookbook Gems:
147
+ Compiling Cookbooks...
148
+ Converging 1 resources
149
+ Recipe: git_cookbook::default
150
+ * yum_package[git] action install
151
+ - install version 0:1.8.3.1-14.el7_5.x86_64 of package git
152
+
153
+ Running handlers:
154
+ Running handlers complete
155
+ Chef Client finished, 1/1 resources updated in 14 seconds
156
+ Downloading files from <default-centos-7>
157
+ Finished converging <default-centos-7> (0m35.28s).
158
+ -----> Setting up <default-centos-7>...
159
+ Finished setting up <default-centos-7> (0m0.00s).
160
+ -----> Verifying <default-centos-7>...
161
+ Loaded tests from {:path=>".Users.cheeseplus.focus.git_cookbook.test.integration.default"}
162
+
163
+ Profile: tests from {:path=>"/Users/cheeseplus/focus/git_cookbook/test/integration/default"} (tests from {:path=>".Users.cheeseplus.focus.git_cookbook.test.integration.default"})
164
+ Version: (not specified)
165
+ Target: ssh://vagrant@127.0.0.1:2222
166
+
167
+ System Package git
168
+ ✔ should be installed
169
+
170
+ Test Summary: 1 successful, 0 failures, 0 skipped
171
+ Finished verifying <default-centos-7> (0m0.65s).
172
+ -----> Kitchen is finished. (2m12.04s)
173
+ ~~~
174
+
175
+ Nice! We've verified that our cookbook works on Ubuntu 16.04 and CentOS 7. Since the CentOS instance is no longer needed, let's destroy it for now:
176
+
177
+ ~~~
178
+ $ kitchen destroy
179
+ -----> Starting Kitchen (v1.23.2)
180
+ -----> Destroying <default-ubuntu-1604>...
181
+ Finished destroying <default-ubuntu-1604> (0m0.00s).
182
+ -----> Destroying <default-centos-7>...
183
+ ==> default: Forcing shutdown of VM...
184
+ ==> default: Destroying VM and associated drives...
185
+ Vagrant instance <default-centos-7> destroyed.
186
+ Finished destroying <default-centos-7> (0m5.89s).
187
+ -----> Kitchen is finished. (0m8.62s)
188
+ ~~~
189
+
190
+ Interesting. Kitchen tried to destroy both instances, one that was created and the other that was not. Which brings us to another tip with the `kitchen` command:
191
+
192
+ > **Any `kitchen` subcommand without an instance argument will apply to all instances.**
193
+
194
+ Let's make sure everything has been destroyed:
195
+
196
+ ~~~
197
+ $ kitchen list
198
+ Instance Driver Provisioner Verifier Transport Last Action Last Error
199
+ default-ubuntu-1604 Vagrant ChefZero Inspec Ssh <Not Created> <None>
200
+ default-centos-7 Vagrant ChefZero Inspec Ssh <Not Created> <None>
201
+ ~~~
202
+
203
+ <div class="sidebar--footer">
204
+ <a class="button primary-cta" href="/docs/getting-started/adding-feature">Next - Adding a Feature</a>
205
+ <a class="sidebar--footer--back" href="/docs/getting-started/running-test">Back to previous step</a>
206
+ </div>