kitchen-google 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +14 -0
- data/Gemfile +3 -1
- data/README.md +215 -88
- data/Rakefile +9 -3
- data/kitchen-google.gemspec +22 -20
- data/lib/kitchen/driver/gce.rb +457 -97
- data/lib/kitchen/driver/gce_version.rb +23 -0
- data/spec/kitchen/driver/gce_spec.rb +839 -276
- data/spec/spec_helper.rb +2 -2
- metadata +36 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76a9c3e0e6785ad0ce9e9a5f73eb41ffedd5ff13
|
4
|
+
data.tar.gz: 345f185a9329e09575fbc5247b8818a62c65f4e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 427b6a8e6c0f9485e8072de9c6b68c5762a3f8fa991c747c88539a22242e6e76c64d2f98b8184b70f588c29632bdfcf69df4289610aca1f9149292530c557c28
|
7
|
+
data.tar.gz: dc81a39c4cf56add4985c31ea750b4a55be452cc354659dcda30e84a47d073bcb419b6a40572b47f1ba861725fd1de33e5d1dd018dc36fde529f9da972af56d5
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## 1.0.0 / 2016-03-10
|
2
|
+
|
3
|
+
### New Features
|
4
|
+
|
5
|
+
* #30: use of gcloud authentication files instead of requiring new service accounts
|
6
|
+
* #30: support for service account scope aliases in addition to regular full names/URLs
|
7
|
+
* #30: support for automated public project searching for well-known disk images
|
8
|
+
|
9
|
+
### Improvements
|
10
|
+
|
11
|
+
* #30: rewrite using the google-api-client
|
12
|
+
* #30: use of the new Test Kitchen 1.4+ transport plugins
|
13
|
+
* #30: additional user feedback during API interactions
|
14
|
+
|
1
15
|
## 0.3.0 / 2016-01-23
|
2
16
|
|
3
17
|
### New Features
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -12,85 +12,168 @@ providers, GCE has a couple of advantages for Chef cookbook testing:
|
|
12
12
|
|
13
13
|
## Requirements
|
14
14
|
|
15
|
-
Ruby
|
15
|
+
### Ruby Version
|
16
16
|
|
17
|
+
Ruby 2.0 or greater.
|
18
|
+
|
19
|
+
### Google Cloud Platform (GCP) Project
|
17
20
|
A [Google Cloud Platform](https://cloud.google.com) account is
|
18
21
|
required. If you do not already have an appropriate "project" in
|
19
22
|
which to run your test-kitchen instances, create one, noting the
|
20
|
-
"project id".
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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 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
|
+
In order to bootstrap Linux nodes, you will first need to ensure your SSH
|
42
|
+
keys are set up correctly. Ensure your SSH public key is properly entered
|
43
|
+
into your project's Metadata tab in the GCP Console. GCE will add your key
|
44
|
+
to the appropriate user's `~/.ssh/authorized_keys` file when Chef first
|
45
|
+
connects to perform the bootstrap process.
|
46
|
+
|
47
|
+
* If you don't have one, create a key using `ssh-keygen`
|
48
|
+
* Log in to the GCP console, select your project, go to Compute Engine, and go to the Metadata tab.
|
49
|
+
* Select the "SSH Keys" tab.
|
50
|
+
* Add a new item, and paste in your public key.
|
51
|
+
* Note: to change the username automatically detected for the key, prefix your key with the username
|
52
|
+
you plan to use to connect to a new instance. For example, if you plan to connect
|
53
|
+
as "chefuser", your key should look like: `chefuser:ssh-rsa AAAAB3N...`
|
54
|
+
* Click "Save".
|
55
|
+
|
56
|
+
Alternatively, the Google Cloud SDK (a.k.a. `gcloud`) will create a SSH key
|
57
|
+
for you when you create and access your first instance:
|
58
|
+
|
59
|
+
1. Create a small test instance:
|
60
|
+
`gcloud compute instances create instance1 --zone us-central1-f --image debian-8 --machine-type g1-small`
|
61
|
+
1. Ensure your SSH keys allow access to the new instance
|
62
|
+
`gcloud compute ssh instance1 --zone us-central1-f`
|
63
|
+
1. Log out and delete the instance
|
64
|
+
`gcloud compute instances delete instance1 --zone us-central1-f`
|
65
|
+
|
66
|
+
You will now have a local SSH keypair, `~/.ssh/google_compute_engine[.pub]` that
|
67
|
+
will be used for connecting to your GCE Linux instances for this local username
|
68
|
+
when you use the `gcloud compute ssh` command. You can tell Test Kitchen to use
|
69
|
+
this key by adding it to the transport section of your .kitchen.yml:
|
70
|
+
|
71
|
+
```yaml
|
72
|
+
transport:
|
73
|
+
ssh_key:
|
74
|
+
- ~/.ssh/google_compute_engine
|
75
|
+
```
|
76
|
+
|
77
|
+
You can find [more information on configuring SSH keys](https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys) in
|
78
|
+
the Google Compute Engine documentation.
|
33
79
|
|
34
80
|
## Installation
|
35
81
|
|
36
|
-
|
37
|
-
cookbook contains at least the following:
|
82
|
+
Install the gem with:
|
38
83
|
|
39
|
-
```
|
40
|
-
|
84
|
+
```sh
|
85
|
+
gem install kitchen-google
|
86
|
+
```
|
87
|
+
|
88
|
+
Or, even better, if you're using the ChefDK:
|
41
89
|
|
42
|
-
|
90
|
+
```sh
|
91
|
+
chef gem install kitchen-google
|
92
|
+
```
|
93
|
+
|
94
|
+
If you're using Bundler, simply add it to your Gemfile:
|
43
95
|
|
44
|
-
|
45
|
-
|
46
|
-
end
|
96
|
+
```ruby
|
97
|
+
gem "kitchen-google", "~> 1.0"
|
47
98
|
```
|
48
99
|
|
49
|
-
|
100
|
+
... and then run `bundle install`.
|
101
|
+
|
50
102
|
|
51
103
|
## Configuration
|
52
104
|
|
53
|
-
### `
|
105
|
+
### `project`
|
54
106
|
|
55
|
-
|
56
|
-
|
107
|
+
**Required**. The project ID of the GCP project into which Test Kitchen
|
108
|
+
instances will be launched. This can be found on the "Manage All Projects"
|
109
|
+
screen, found under the "Select a Project" drop-down at the top of the
|
110
|
+
GCP console.
|
57
111
|
|
58
|
-
|
112
|
+
Note that this parameter requires the "Project ID", not the "Project Name."
|
59
113
|
|
60
|
-
|
61
|
-
for test instance. Default: `true`
|
114
|
+
Example: "funky-penguin-12345"
|
62
115
|
|
63
|
-
### `
|
116
|
+
### `image_name`
|
64
117
|
|
65
|
-
|
118
|
+
**Required**. The name of the disk image to use as the source image for
|
119
|
+
the boot disk. Example: `centos-6-v20160219`
|
66
120
|
|
67
|
-
|
121
|
+
The GCP project specified with the `project` configuration parameter will
|
122
|
+
be searched first. If the image cannot be found and it looks like a common
|
123
|
+
public image, the appropriate public project will be searched.
|
68
124
|
|
69
|
-
|
70
|
-
|
71
|
-
account; should be in the form
|
72
|
-
"123456789012@developer.gserviceaccount.com".)
|
125
|
+
You can override the project in which to search for the image with the
|
126
|
+
`image_project` parameter.
|
73
127
|
|
74
|
-
### `
|
128
|
+
### `zone`
|
75
129
|
|
76
|
-
**Required
|
130
|
+
**Required if `region` is left blank.** The name of the GCE zone in which to
|
131
|
+
launch your instances.
|
77
132
|
|
78
|
-
|
133
|
+
Example: `us-east1-b`
|
79
134
|
|
80
|
-
|
81
|
-
instances will be launched.
|
135
|
+
### `region`
|
82
136
|
|
83
|
-
|
137
|
+
**Required if zone is left blank.** The name of the region in which to
|
138
|
+
launch your instances. A zone in the region will be randomly selected.
|
139
|
+
|
140
|
+
Example: `us-central1`
|
141
|
+
|
142
|
+
This parameter will be ignored if `zone` is specified.
|
143
|
+
|
144
|
+
### `autodelete_disk`
|
145
|
+
|
146
|
+
Boolean specifying whether or not to automatically delete boot disk
|
147
|
+
for test instance. Default: `true`
|
148
|
+
|
149
|
+
NOTE: If you set this to false, once Test Kitchen destroys your instance,
|
150
|
+
the boot disk used will remain in your project. You will need to manually delete it to
|
151
|
+
avoid consuming unused resources by either using the `gcloud compute disks delete`
|
152
|
+
command in the GCP SDK or by using `knife google disk delete` from
|
153
|
+
[knife-google](https://github.com/chef/knife-google).
|
154
|
+
|
155
|
+
### `auto_migrate`
|
156
|
+
|
157
|
+
Boolean specifying whether or not to automatically migrate the instance
|
158
|
+
to a host in the event of host maintenance. Default: `false`
|
159
|
+
|
160
|
+
### `disk_size`
|
84
161
|
|
85
|
-
|
162
|
+
Size, in gigabytes, of boot disk. Default: `10`.
|
163
|
+
|
164
|
+
Some images, such as windows images, have a larger source image size
|
165
|
+
and require the disk_size to be the same size or larger than the source.
|
166
|
+
An error message will be displayed to you indicating this requirement
|
167
|
+
if necessary.
|
168
|
+
|
169
|
+
### `email`
|
86
170
|
|
87
|
-
|
171
|
+
**Required for Windows instances.** The email address of the
|
172
|
+
currently-logged-in GCP user.
|
88
173
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
used if there is more than one test suite. Default:
|
93
|
-
`<suite>-<platform>-<UUID>`
|
174
|
+
While the credentials file specified in the Authentication and Authorization
|
175
|
+
section is used for all API interactions, the email address is required when
|
176
|
+
performing the necessary password reset prior to bootstrapping the instance.
|
94
177
|
|
95
178
|
### `machine_type`
|
96
179
|
|
@@ -107,67 +190,111 @@ that runs at a much lower price than normal instances. However, Compute
|
|
107
190
|
Engine might terminate (preempt) these instances if it requires access
|
108
191
|
to those resources for other tasks; default: `false`
|
109
192
|
|
110
|
-
### `
|
193
|
+
### `service_account_name`
|
111
194
|
|
112
|
-
|
113
|
-
|
195
|
+
The name of the service account to use when enabling account scopes. This
|
196
|
+
is usually an email-formatted service account name created via the "Permissions"
|
197
|
+
tab of the GCP console.
|
114
198
|
|
115
|
-
|
199
|
+
This is ignored unless you specify any `service_account_scopes`.
|
200
|
+
|
201
|
+
Default: "default"
|
202
|
+
|
203
|
+
### `service_account_scopes`
|
116
204
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
`us-central1`
|
205
|
+
An array of scopes to add to the instance, used to grant additional permissions
|
206
|
+
within GCP.
|
207
|
+
|
208
|
+
The scopes can either be a full URL (i.e. `https://www.googleapis.com/auth/devstorage.read_write`),
|
209
|
+
the short-name (i.e. `devstorage.read_write`), or a gcloud alias (i.e. `storage-rw`).
|
210
|
+
|
211
|
+
See the output of `gcloud compute instances create --help` for a full list of scopes.
|
125
212
|
|
126
213
|
### `tags`
|
127
214
|
|
128
215
|
Array of tags to associate with instance; default: `[]`
|
129
216
|
|
130
|
-
### `
|
217
|
+
### `use_private_ip`
|
131
218
|
|
132
|
-
|
219
|
+
Boolean indicating whether or not to connect to the instance using its
|
220
|
+
private IP address. If `true`, kitchen-google will also not provision
|
221
|
+
a public IP for this instance. Default: `false`
|
133
222
|
|
134
|
-
### `
|
223
|
+
### `wait_time`
|
135
224
|
|
136
|
-
|
137
|
-
zone is chosen from available zones within the [`region`](#region).
|
225
|
+
Amount of time, in seconds, to wait for any API interactions. Default: 600
|
138
226
|
|
139
|
-
|
227
|
+
### `refresh_rate`
|
140
228
|
|
141
|
-
|
142
|
-
like this:
|
229
|
+
Amount of time, in seconds, to refresh the status of an API interaction. Default: 2
|
143
230
|
|
144
|
-
|
231
|
+
### Transport Settings
|
232
|
+
|
233
|
+
Beginning with Test Kitchen 1.4, settings related to the transport (i.e. how to connect
|
234
|
+
to the instance) have been moved to the `transport` section of the config, such as the
|
235
|
+
username, password, SSH key path, etc.
|
236
|
+
|
237
|
+
Therefore, you will need to update the transport section with the username configured
|
238
|
+
for the SSH Key you imported into your project metadata as described in the "SSH Keys"
|
239
|
+
section above. For example, if you are connecting as the "chefuser", your .kitchen.yml
|
240
|
+
might have a section like this:
|
241
|
+
|
242
|
+
```yaml
|
243
|
+
transport:
|
244
|
+
username: chefuser
|
245
|
+
```
|
246
|
+
|
247
|
+
Additionally, if you do not wish to use the standard default SSH key (`~/.ssh/id_rsa`),
|
248
|
+
you can set the `ssh_key` parameter in the `transport` section of your .kitchen.yml.
|
249
|
+
For example, if you want to use the SSH key auto-generated by the GCP SDK:
|
250
|
+
|
251
|
+
```yaml
|
252
|
+
transport:
|
253
|
+
ssh_key:
|
254
|
+
- ~/.ssh/google_compute_engine
|
255
|
+
```
|
256
|
+
|
257
|
+
## Example .kitchen.yml
|
258
|
+
|
259
|
+
```yaml
|
145
260
|
---
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
261
|
+
driver:
|
262
|
+
name: gce
|
263
|
+
project: mycompany-test
|
264
|
+
zone: us-east1-c
|
265
|
+
email: me@mycompany.com
|
266
|
+
tags:
|
267
|
+
- devteam
|
268
|
+
- test-kitchen
|
269
|
+
service_account_scopes:
|
270
|
+
- devstorage.read_write
|
271
|
+
- userinfo.email
|
272
|
+
|
273
|
+
provisioner:
|
274
|
+
name: chef_zero
|
275
|
+
|
276
|
+
transport:
|
277
|
+
username: chefuser
|
153
278
|
|
154
279
|
platforms:
|
155
|
-
- name:
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
280
|
+
- name: centos
|
281
|
+
driver:
|
282
|
+
image_name: centos-6-v20160219
|
283
|
+
- name: windows
|
284
|
+
driver:
|
285
|
+
image_name: windows-server-2012-r2-dc-v20160112
|
286
|
+
disk_size: 50
|
161
287
|
|
162
288
|
suites:
|
163
|
-
- name: default
|
164
|
-
|
165
|
-
|
289
|
+
- name: default
|
290
|
+
run_list:
|
291
|
+
- recipe[gcetest::default]
|
292
|
+
attributes:
|
166
293
|
```
|
167
294
|
|
168
295
|
## Development
|
169
296
|
|
170
|
-
Source is hosted on [GitHub](https://github.com/
|
297
|
+
Source is hosted on [GitHub](https://github.com/test-kitchen/kitchen-google).
|
171
298
|
|
172
299
|
* Pull requests are welcome, using topic branches if possible:
|
173
300
|
|
@@ -175,7 +302,7 @@ Source is hosted on [GitHub](https://github.com/anl/kitchen-gce).
|
|
175
302
|
2. Create a feature branch, commit changes to it and push them.
|
176
303
|
3. Submit a pull request.
|
177
304
|
|
178
|
-
* Report issues or submit feature requests on [GitHub](https://github.com/
|
305
|
+
* Report issues or submit feature requests on [GitHub](https://github.com/test-kitchen/kitchen-google/issues)
|
179
306
|
|
180
307
|
## Author, Acknowledgements, Etc.
|
181
308
|
|
data/Rakefile
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
-
require
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
4
5
|
|
5
|
-
desc 'Run RSpec unit tests'
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
|
8
|
+
require "chefstyle"
|
9
|
+
require "rubocop/rake_task"
|
10
|
+
RuboCop::RakeTask.new(:style) do |task|
|
11
|
+
task.options << "--display-cop-names"
|
12
|
+
end
|
13
|
+
|
14
|
+
task default: [:spec, :style]
|
data/kitchen-google.gemspec
CHANGED
@@ -1,26 +1,28 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "kitchen/driver/gce_version"
|
4
|
+
|
2
5
|
Gem::Specification.new do |s|
|
3
|
-
s.name =
|
4
|
-
s.version =
|
5
|
-
s.date =
|
6
|
-
s.summary =
|
7
|
-
s.description =
|
8
|
-
s.authors = [
|
9
|
-
s.email =
|
10
|
-
s.files = `git ls-files`.split($/)
|
11
|
-
s.homepage =
|
12
|
-
s.license =
|
6
|
+
s.name = "kitchen-google"
|
7
|
+
s.version = Kitchen::Driver::GCE_VERSION
|
8
|
+
s.date = "2016-03-10"
|
9
|
+
s.summary = "Kitchen::Driver::Gce"
|
10
|
+
s.description = "A Test-Kitchen driver for Google Compute Engine"
|
11
|
+
s.authors = ["Andrew Leonard", "Chef Partner Engineering"]
|
12
|
+
s.email = ["andy@hurricane-ridge.com", "partnereng@chef.io"]
|
13
|
+
s.files = `git ls-files`.split($/)
|
14
|
+
s.homepage = "https://github.com/test-kitchen/kitchen-google"
|
15
|
+
s.license = "Apache 2.0"
|
13
16
|
|
14
|
-
s.add_dependency
|
15
|
-
s.add_dependency
|
16
|
-
s.add_dependency
|
17
|
-
s.add_dependency 'test-kitchen'
|
17
|
+
s.add_dependency "gcewinpass", "~> 1.0"
|
18
|
+
s.add_dependency "google-api-client", "~> 0.9.0"
|
19
|
+
s.add_dependency "test-kitchen"
|
18
20
|
|
19
|
-
s.add_development_dependency
|
20
|
-
s.add_development_dependency
|
21
|
-
s.add_development_dependency
|
22
|
-
s.add_development_dependency
|
23
|
-
s.add_development_dependency
|
21
|
+
s.add_development_dependency "bundler"
|
22
|
+
s.add_development_dependency "pry"
|
23
|
+
s.add_development_dependency "rake"
|
24
|
+
s.add_development_dependency "rspec"
|
25
|
+
s.add_development_dependency "rubocop"
|
24
26
|
|
25
|
-
s.required_ruby_version =
|
27
|
+
s.required_ruby_version = ">= 2.0"
|
26
28
|
end
|