kitchen-google 1.5.0 → 2.1.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.
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify dependencies in gemspec:
4
- gemspec
5
-
6
- gem "chefstyle", git: "https://github.com/chef/chefstyle"
data/README.md DELETED
@@ -1,446 +0,0 @@
1
- # Kitchen::Gce - A Test Kitchen Driver for Google Compute Engine
2
-
3
- [![Build Status](https://travis-ci.org/test-kitchen/kitchen-google.png?branch=master)](https://travis-ci.org/test-kitchen/kitchen-google)
4
- [![Code Climate](https://codeclimate.com/github/test-kitchen/kitchen-google.png)](https://codeclimate.com/github/test-kitchen/kitchen-google)
5
-
6
- This is a [Test Kitchen](https://github.com/opscode/test-kitchen/)
7
- driver for Google Compute Engine. While similar to EC2 and other IaaS
8
- providers, GCE has a couple of advantages for Chef cookbook testing:
9
-
10
- * (Subjectively) faster instance launch times; and
11
- * Sub-hour billing.
12
-
13
- ## Requirements
14
-
15
- ### Ruby Version
16
-
17
- Ruby 2.0 or greater.
18
-
19
- ### Google Cloud Platform (GCP) Project
20
- A [Google Cloud Platform](https://cloud.google.com) account is
21
- required. If you do not already have an appropriate "project" in
22
- which to run your test-kitchen instances, create one, noting the
23
- "project id".
24
-
25
- ### Authentication and Authorization
26
-
27
- The [underlying API](https://github.com/google/google-api-ruby-client) this plugin uses relies on the
28
- [Google Auth Library](https://github.com/google/google-auth-library-ruby) to handle authentication to the
29
- Google Cloud API. The auth library expects that there is a JSON credentials file located at:
30
-
31
- `~/.config/gcloud/application_default_credentials.json`
32
-
33
- The easiest way to create this is to download and install the [Google Cloud SDK](https://cloud.google.com/sdk/) and run the
34
- `gcloud auth application-default login` command which will create the credentials file for you.
35
-
36
- If you already have a file you'd like to use that is in a different location, set the
37
- `GOOGLE_APPLICATION_CREDENTIALS` environment variable with the full path to that file.
38
-
39
- ### SSH Keys
40
-
41
- #### Project Level Keys
42
-
43
- In order to bootstrap Linux nodes, you will first need to ensure your SSH
44
- keys are set up correctly. Ensure your SSH public key is properly entered
45
- into your project's Metadata tab in the GCP Console. GCE will add your key
46
- to the appropriate user's `~/.ssh/authorized_keys` file when Chef first
47
- connects to perform the bootstrap process.
48
-
49
- * If you don't have one, create a key using `ssh-keygen`
50
- * Log in to the GCP console, select your project, go to Compute Engine, and go to the Metadata tab.
51
- * Select the "SSH Keys" tab.
52
- * Add a new item, and paste in your public key.
53
- * Note: to change the username automatically detected for the key, prefix your key with the username
54
- you plan to use to connect to a new instance. For example, if you plan to connect
55
- as "chefuser", your key should look like: `chefuser:ssh-rsa AAAAB3N...`
56
- * Click "Save".
57
-
58
- Alternatively, the Google Cloud SDK (a.k.a. `gcloud`) will create a SSH key
59
- for you when you create and access your first instance:
60
-
61
- 1. Create a small test instance:
62
- `gcloud compute instances create instance1 --zone us-central1-f --image-family=debian-8 --image-project=debian-cloud --machine-type g1-small`
63
- 1. Ensure your SSH keys allow access to the new instance
64
- `gcloud compute ssh instance1 --zone us-central1-f`
65
- 1. Log out and delete the instance
66
- `gcloud compute instances delete instance1 --zone us-central1-f`
67
-
68
- You will now have a local SSH keypair, `~/.ssh/google_compute_engine[.pub]` that
69
- will be used for connecting to your GCE Linux instances for this local username
70
- when you use the `gcloud compute ssh` command. You can tell Test Kitchen to use
71
- this key by adding it to the transport section of your .kitchen.yml:
72
-
73
- ```yaml
74
- transport:
75
- ssh_key:
76
- - ~/.ssh/google_compute_engine
77
- ```
78
-
79
- You can find [more information on configuring SSH keys](https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys) in
80
- the Google Compute Engine documentation.
81
-
82
- #### Instance Level Keys
83
-
84
- It is possible to [add keys](https://cloud.google.com/compute/docs/storing-retrieving-metadata#default)
85
- that are not included in the project's metadata to an instance. Do this by
86
- listing additional keys in custom metadata (see below for more about [setting
87
- metadata](#metadata)).
88
-
89
- For example, given a workspace that has environment variables set for `USER`
90
- (the username to connect as) and `SSH_KEY` (the path to the private key to use):
91
-
92
- ```yaml
93
- driver:
94
- name: gce
95
- ...
96
- metadata:
97
- ssh-keys: <%= ENV['USER'] + ':' + IO.binread("#{ENV['SSH_KEY']}.pub").rstrip! %>
98
-
99
- transport:
100
- username: <%= ENV['USER'] %>
101
- ssh_key: <%= ENV['SSH_KEY'] %>
102
- ```
103
-
104
- ## Installation
105
-
106
- Install the gem with:
107
-
108
- ```sh
109
- gem install kitchen-google
110
- ```
111
-
112
- Or, even better, if you're using the ChefDK:
113
-
114
- ```sh
115
- chef gem install kitchen-google
116
- ```
117
-
118
- If you're using Bundler, simply add it to your Gemfile:
119
-
120
- ```ruby
121
- gem "kitchen-google", "~> 1.0"
122
- ```
123
-
124
- ... and then run `bundle install`.
125
-
126
-
127
- ## Configuration
128
-
129
- ### `project`
130
-
131
- **Required**. The project ID of the GCP project into which Test Kitchen
132
- instances will be launched. This can be found on the "Manage All Projects"
133
- screen, found under the "Select a Project" drop-down at the top of the
134
- GCP console.
135
-
136
- Note that this parameter requires the "Project ID", not the "Project Name."
137
-
138
- Example: "funky-penguin-12345"
139
-
140
- ### `image_project`
141
-
142
- The project ID of the GCP project to search for the configured image or image
143
- family. This must be specified to find either public images or your own images
144
- that exist in another project.
145
-
146
- Example: "ubuntu-os-cloud"
147
-
148
- ### `image_family`
149
-
150
- The family of the image to initialize your boot disk from, the latest
151
- non-deprecated image will be used.
152
-
153
- Note that this parameter will be ignored if `image_name` is also specified.
154
-
155
- Example: "ubuntu-1604-lts"
156
-
157
- ### `image_name`
158
-
159
- The name of the disk image to use as the source image for the boot disk.
160
-
161
- Example: `centos-7-v20170124`
162
-
163
- This parameter will override `image_family` if they are both specified.
164
-
165
- If `image_project` is not specified, only the GCP project specified in `project`
166
- will be searched.
167
-
168
- ### `zone`
169
-
170
- **Required if `region` is left blank.** The name of the GCE zone in which to
171
- launch your instances.
172
-
173
- Example: `us-east1-b`
174
-
175
- ### `region`
176
-
177
- **Required if zone is left blank.** The name of the region in which to
178
- launch your instances. A zone in the region will be randomly selected.
179
-
180
- Example: `us-central1`
181
-
182
- This parameter will be ignored if `zone` is specified.
183
-
184
- ### `inst_name`
185
-
186
- **Optional** Name to give to instance. If given, must be under 63 characters
187
- in length. Any character that is not alphanumeric or a hyphen will be converted
188
- to a hyphen. Unlike EC2's "Name" tag, this is used as an instance identifier and
189
- must be unique. By default, a unique name will be auto-generated; note that
190
- auto-generated names must be used if there is more than one test suite. Default:
191
- `tk-<suite>-<platform>-<UUID>`
192
-
193
- ### `auto_migrate`
194
-
195
- Boolean specifying whether or not to automatically migrate the instance
196
- to a host in the event of host maintenance. Default: `false`
197
-
198
- ### `email`
199
-
200
- **Required for Windows instances.** The email address of the
201
- currently-logged-in GCP user.
202
-
203
- While the credentials file specified in the Authentication and Authorization
204
- section is used for all API interactions, the email address is required when
205
- performing the necessary password reset prior to bootstrapping the instance.
206
-
207
- ### `machine_type`
208
-
209
- GCE instance type (size) to launch; default: `n1-standard-1`
210
-
211
- ### `network`
212
-
213
- GCE network that instance will be attached to; default: `default`
214
-
215
- ### `network_project`
216
-
217
- GCE project which network belongs to; default is same as `project`
218
-
219
- ### `subnet`
220
-
221
- GCE subnetwork that instance will be attached to. Only applies to custom networks.
222
-
223
- ### `subnet_project`
224
-
225
- GCE project which subnet belongs to. Only applies when `subnet` is used; default is same as `project`
226
-
227
- ### `preemptible`
228
-
229
- If set to `true`, GCE instance will be brought up as a [preemptible](https://cloud.google.com/compute/docs/instances/preemptible) virtual machine,
230
- that runs at a much lower price than normal instances. However, Compute
231
- Engine might terminate (preempt) these instances if it requires access
232
- to those resources for other tasks; default: `false`
233
-
234
- ### `service_account_name`
235
-
236
- The name of the service account to use when enabling account scopes. This
237
- is usually an email-formatted service account name created via the "Permissions"
238
- tab of the GCP console.
239
-
240
- This is ignored unless you specify any `service_account_scopes`.
241
-
242
- Default: "default"
243
-
244
- ### `service_account_scopes`
245
-
246
- An array of scopes to add to the instance, used to grant additional permissions
247
- within GCP.
248
-
249
- The scopes can either be a full URL (i.e. `https://www.googleapis.com/auth/devstorage.read_write`),
250
- the short-name (i.e. `devstorage.read_write`), or a gcloud alias (i.e. `storage-rw`).
251
-
252
- See the output of `gcloud compute instances create --help` for a full list of scopes.
253
-
254
- ### `tags`
255
-
256
- Array of tags to associate with instance; default: `[]`
257
-
258
- ### `use_private_ip`
259
-
260
- Boolean indicating whether or not to connect to the instance using its
261
- private IP address. If `true`, kitchen-google will also not provision
262
- a public IP for this instance. Default: `false`
263
-
264
- ### `wait_time`
265
-
266
- Amount of time, in seconds, to wait for any API interactions. Default: 600
267
-
268
- ### `refresh_rate`
269
-
270
- Amount of time, in seconds, to refresh the status of an API interaction. Default: 2
271
-
272
- ### `metadata`
273
-
274
- Allows custom instance metadata to be set.
275
- The following metadata is set by default if no metadata configuration is provided:
276
- Default:
277
-
278
-
279
- "created-by" => "test-kitchen",
280
- "test-kitchen-instance" => <instance.name>,
281
- "test-kitchen-user" => <env_user>,
282
-
283
- ### Disk configuration
284
-
285
- NOTE: In order to support multiple disks in this driver, the disk configuration has been reworked. However, old .kitchen-files will keep working and simply be adapted automatically.
286
-
287
- ```yaml
288
- driver:
289
- disks:
290
- disk0:
291
- autodelete_disk: false
292
- disk1:
293
- disk_size: 30
294
- disk2:
295
- disk_size: 50
296
- ```
297
-
298
- In the above example the `disk0` would be automatically be used as the bootdisk (/dev/sda), `disk1` would be mounted as /dev/sdb and be 30 gigabytes in size. `disk2` would be mounted as /dev/sdc and 50 gigabytes in size. Any of these disks could be the bootdisk (see below), but since none is specified, disk0 is automatically elected. Note that if `disk1` would be set as bootdisk using `boot: true` it will be mounted as /dev/sda.
299
-
300
- #### `boot`
301
-
302
- Specifies wether or not a disk should be used as the boot disk for the instance. By default the first disk will be used as boot disk.
303
-
304
- #### `autodelete_disk` - deprecated as standalone option
305
-
306
- Boolean specifying whether or not to automatically delete boot disk
307
- for test instance. Default: `true`
308
-
309
- *This option is deprecated as a standlone configuration, but can be applied on a per disk level.*
310
-
311
- NOTE: If you set this to false, once Test Kitchen destroys your instance,
312
- the boot disk used will remain in your project. You will need to manually delete it to
313
- avoid consuming unused resources by either using the `gcloud compute disks delete`
314
- command in the GCP SDK or by using `knife google disk delete` from
315
- [knife-google](https://github.com/chef/knife-google).
316
-
317
- #### `disk_size` - deprecated as standalone option
318
-
319
- Size, in gigabytes, of boot disk. Default: `10`.
320
-
321
- *This option is deprecated as a standlone configuration, but can be applied on a per disk level.*
322
-
323
- Some images, such as windows images, have a larger source image size
324
- and require the disk_size to be the same size or larger than the source.
325
- An error message will be displayed to you indicating this requirement
326
- if necessary.
327
-
328
- #### `disk_type` - deprecated as standalone option
329
-
330
- Type of the disk. Default: `pd-standard`.
331
-
332
- *This option is deprecated as a standlone configuration, but can be applied on a per disk level.*
333
-
334
- Valid disk types:
335
-
336
- - `pd-standard`: Attached magnetic hard drive
337
- - `pd-ssd`: Attached SSD
338
- - `local-ssd`: [Local scratch SSD](https://cloud.google.com/compute/docs/disks/#localssds). NOTE: You cannot specify their size. They always are 375 GB!
339
-
340
- ### Transport Settings
341
-
342
- Beginning with Test Kitchen 1.4, settings related to the transport (i.e. how to connect
343
- to the instance) have been moved to the `transport` section of the config, such as the
344
- username, password, SSH key path, etc.
345
-
346
- Therefore, you will need to update the transport section with the username configured
347
- for the SSH Key you imported into your project metadata as described in the "SSH Keys"
348
- section above. For example, if you are connecting as the "chefuser", your .kitchen.yml
349
- might have a section like this:
350
-
351
- ```yaml
352
- transport:
353
- username: chefuser
354
- ```
355
-
356
- Additionally, if you do not wish to use the standard default SSH key (`~/.ssh/id_rsa`),
357
- you can set the `ssh_key` parameter in the `transport` section of your .kitchen.yml.
358
- For example, if you want to use the SSH key auto-generated by the GCP SDK:
359
-
360
- ```yaml
361
- transport:
362
- ssh_key:
363
- - ~/.ssh/google_compute_engine
364
- ```
365
-
366
- ## Example .kitchen.yml
367
-
368
- ```yaml
369
- ---
370
- driver:
371
- name: gce
372
- project: mycompany-test
373
- zone: us-east1-c
374
- email: me@mycompany.com
375
- tags:
376
- - devteam
377
- - test-kitchen
378
- service_account_scopes:
379
- - devstorage.read_write
380
- - userinfo.email
381
-
382
- provisioner:
383
- name: chef_zero
384
-
385
- transport:
386
- username: chefuser
387
-
388
- platforms:
389
- - name: centos-7
390
- driver:
391
- image_project: centos-cloud
392
- image_name: centos-7-v20170124
393
- metadata:
394
- application: centos
395
- release: a
396
- version: 7
397
- - name: ubuntu-16.04
398
- driver:
399
- image_project: ubuntu-os-cloud
400
- image_family: ubuntu-1604-lts
401
- metadata:
402
- application: ubuntu
403
- release: a
404
- version: 1604
405
- - name: windows
406
- driver:
407
- image_project: windows-cloud
408
- image_name: windows-server-2012-r2-dc-v20170117
409
- disk_size: 50
410
- metadata:
411
- application: windows
412
- release: a
413
- version: cloud
414
-
415
- suites:
416
- - name: default
417
- run_list:
418
- - recipe[gcetest::default]
419
- attributes:
420
- ```
421
-
422
- ## Development
423
-
424
- Source is hosted on [GitHub](https://github.com/test-kitchen/kitchen-google).
425
-
426
- * Pull requests are welcome, using topic branches if possible:
427
-
428
- 1. Fork the repo.
429
- 2. Create a feature branch, commit changes to it and push them.
430
- 3. Submit a pull request.
431
-
432
- * Report issues or submit feature requests on [GitHub](https://github.com/test-kitchen/kitchen-google/issues)
433
-
434
- ## Author, Acknowledgements, Etc.
435
-
436
- Created and maintained by [Andrew Leonard](http://andyleonard.com)
437
- ([andy@hurricane-ridge.com](mailto:andy@hurricane-ridge.com)).
438
-
439
- The initial release drew heavily on the
440
- [kitchen-ec2](https://github.com/opscode/kitchen-ec2/) gem for both
441
- inspiration and implementation details. Any bugs, however, are solely
442
- the author's own doing.
443
-
444
- ## License
445
-
446
- Licensed under Apache 2.0.