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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4085522e906870ad6ced21e1324fd139ffb2f454
4
- data.tar.gz: e0337e83aa1ae41006264dfe93c0ddd2739f63f8
3
+ metadata.gz: 76a9c3e0e6785ad0ce9e9a5f73eb41ffedd5ff13
4
+ data.tar.gz: 345f185a9329e09575fbc5247b8818a62c65f4e8
5
5
  SHA512:
6
- metadata.gz: b0b0e34c10fa46f788a8e36a11d637a2fe6d5e6729f7c023481a5fae135d4df1eab74ee7cf2c9a877bda863ceb3e46a9df27734ebb4857acb60aaa4669ef7c2a
7
- data.tar.gz: a683597a6f9cd2eac0d90cf34bd2b7e4ab7c6612558781c52a78ed646c778b353b513603f9d9b215eb5534a7a6f810d248a27c6e2ca1f790b9953dc3355e5c08
6
+ metadata.gz: 427b6a8e6c0f9485e8072de9c6b68c5762a3f8fa991c747c88539a22242e6e76c64d2f98b8184b70f588c29632bdfcf69df4289610aca1f9149292530c557c28
7
+ data.tar.gz: dc81a39c4cf56add4985c31ea750b4a55be452cc354659dcda30e84a47d073bcb419b6a40572b47f1ba861725fd1de33e5d1dd018dc36fde529f9da972af56d5
@@ -1,9 +1,9 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 1.9.3
5
4
  - 2.0.0
6
5
  - 2.1.0
6
+ - 2.2
7
7
 
8
8
  before_install:
9
9
  - gem update bundler
@@ -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
@@ -1,4 +1,6 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify dependencies in gemspec:
4
4
  gemspec
5
+
6
+ gem "chefstyle", git: "https://github.com/chef/chefstyle"
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 1.9 or greater.
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". Then, within the [Google API
21
- Console](https://code.google.com/apis/console/), create a "service
22
- account" for the project under the "API Access" tab. Save the key
23
- file, and note the email address associated with the service account
24
- (e.g. 123456789012@developer.gserviceaccount.com - not the project
25
- owner's email address).
26
-
27
- If you are not using the `public_key_path` setting (see below) and
28
- have not [set up SSH keys for your GCE
29
- environment](https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys),
30
- you must also do that prior to using kitchen-gce. Also, you will
31
- likely want to add your SSH keys to ssh-agent prior to converging any
32
- instances.
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
- Assuming you are using Bundler, ensure the Gemfile within your Chef
37
- cookbook contains at least the following:
82
+ Install the gem with:
38
83
 
39
- ```ruby
40
- source 'https://rubygems.org'
84
+ ```sh
85
+ gem install kitchen-google
86
+ ```
87
+
88
+ Or, even better, if you're using the ChefDK:
41
89
 
42
- gem 'berkshelf'
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
- group :integration do
45
- gem 'kitchen-gce'
46
- end
96
+ ```ruby
97
+ gem "kitchen-google", "~> 1.0"
47
98
  ```
48
99
 
49
- Then, execute `bundle install`.
100
+ ... and then run `bundle install`.
101
+
50
102
 
51
103
  ## Configuration
52
104
 
53
- ### `area`
105
+ ### `project`
54
106
 
55
- Deprecated - use equivalent [`region`](#region) instead. If both `area` and
56
- `region` are set, the value of `region` will be used.
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
- ### `autodelete_disk`
112
+ Note that this parameter requires the "Project ID", not the "Project Name."
59
113
 
60
- Boolean specifying whether or not to automatically delete boot disk
61
- for test instance. Default: `true`
114
+ Example: "funky-penguin-12345"
62
115
 
63
- ### `disk_size`
116
+ ### `image_name`
64
117
 
65
- Size, in gigabytes, of boot disk. Default: `10`.
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
- ### `google_client_email`
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
- **Required** Email address associated with your GCE service account.
70
- (N.B. - this is not the same as the Google Cloud Platform user's email
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
- ### `google_key_location`
128
+ ### `zone`
75
129
 
76
- **Required** Path to GCE service account key file.
130
+ **Required if `region` is left blank.** The name of the GCE zone in which to
131
+ launch your instances.
77
132
 
78
- ### `google_project`
133
+ Example: `us-east1-b`
79
134
 
80
- **Required** Project ID of the GCE project into which test-kitchen
81
- instances will be launched.
135
+ ### `region`
82
136
 
83
- ### `image_name`
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
- **Required** Operating system image to deploy.
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
- ### `inst_name`
171
+ **Required for Windows instances.** The email address of the
172
+ currently-logged-in GCP user.
88
173
 
89
- Name to give to instance; unlike EC2's "Name" tag, this is used as an
90
- instance identifier and must be unique. If none is specified, a unique
91
- name will be auto-generated; note that auto-generated names must be
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
- ### `public_key_path`
193
+ ### `service_account_name`
111
194
 
112
- Path to the public half of the ssh key that will be deployed to
113
- `~username/.ssh/authorized_keys`; see also [`username`](#username) below.
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
- ### `region`
199
+ This is ignored unless you specify any `service_account_scopes`.
200
+
201
+ Default: "default"
202
+
203
+ ### `service_account_scopes`
116
204
 
117
- Region in which to launch instances. `region` is defined as the part
118
- prior to the second hyphen in an availability zone's name; e.g. in
119
- `us-central1-b`, the region is `us-central1`. Specifying region but
120
- not `zone_name` allows kitchen-gce to avoid launching instances into a
121
- zone that is down for maintenance. If `any` is specified, kitchen-gce
122
- will select a zone from all regions. Default: `us-central1` (lowest
123
- cost region); valid values: `any`, `asia-east1`, `europe-west1`,
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
- ### `username`
217
+ ### `use_private_ip`
131
218
 
132
- Username test-kitchen will log into instance as; default: `ENV['USER']`
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
- ### `zone_name`
223
+ ### `wait_time`
135
224
 
136
- Location into which instances will be launched. If not specified, a
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
- ## Example
227
+ ### `refresh_rate`
140
228
 
141
- An example `.kitchen.yml` file using kitchen-gce might look something
142
- like this:
229
+ Amount of time, in seconds, to refresh the status of an API interaction. Default: 2
143
230
 
144
- ```ruby
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
- driver_plugin: gce
147
- driver_config:
148
- google_client_email: "123456789012@developer.gserviceaccount.com"
149
- google_key_location: "<%= ENV['HOME']%>/gce/1234567890abcdef1234567890abcdef12345678-privatekey.p12"
150
- google_project: "alpha-bravo-123"
151
- network: "kitchenci"
152
- region: any
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: debian-7
156
- driver_config:
157
- image_name: debian-7-wheezy-v20151104
158
- require_chef_omnibus: true
159
- public_key_path: '/home/alice/.ssh/google_compute_engine.pub'
160
- tags: ["somerole"]
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
- run_list: ["recipe[somecookbook]"]
165
- attributes: {}
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/anl/kitchen-gce).
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/anl/kitchen-gce/issues)
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 'rspec/core/rake_task'
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
- task default: [:spec]
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]
@@ -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 = 'kitchen-google'
4
- s.version = '0.3.0'
5
- s.date = '2016-01-23'
6
- s.summary = 'Kitchen::Driver::Gce'
7
- s.description = 'A Test-Kitchen driver for Google Compute Engine'
8
- s.authors = ['Andrew Leonard']
9
- s.email = 'andy@hurricane-ridge.com'
10
- s.files = `git ls-files`.split($/) # rubocop:disable SpecialGlobalVars
11
- s.homepage = 'https://github.com/test-kitchen/kitchen-google'
12
- s.license = 'Apache 2.0'
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 'fog', '>= 1.31.0'
15
- s.add_dependency 'google-api-client'
16
- s.add_dependency 'ridley', '>= 3.0.0' # See GH issue RiotGames/ridley#239
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 'bundler'
20
- s.add_development_dependency 'pry'
21
- s.add_development_dependency 'rake'
22
- s.add_development_dependency 'rspec'
23
- s.add_development_dependency 'rubocop'
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 = '>= 1.9'
27
+ s.required_ruby_version = ">= 2.0"
26
28
  end