vagrant-google 2.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +5 -2
- data/lib/vagrant-google/action/run_instance.rb +35 -29
- data/lib/vagrant-google/config.rb +47 -4
- data/lib/vagrant-google/version.rb +1 -1
- data/locales/en.yml +2 -0
- data/tasks/acceptance.rake +1 -0
- data/test/acceptance/provider/image_family_spec.rb +26 -0
- data/test/acceptance/provider/scopes_spec.rb +1 -2
- data/test/acceptance/skeletons/image_family/Vagrantfile +14 -0
- data/test/unit/common/config_test.rb +5 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24b64b7282bcf810918299b7b74856bd1f75e35b
|
4
|
+
data.tar.gz: 422a89d6c2209132a5bedc7a7e2310d9145e5eae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ee8f0aab047c1c96ec6bc7552aa1ee9797381bd7e53f9eba5c17ddd07585c4182a8c7bf47df22d5f4364ee45dce57c6004b8350c2d975da705b1de305a803c4
|
7
|
+
data.tar.gz: 85d96c3e2dac6f08a4dc80995165699cd2864c967c0afcdac464ee35248c052e0b7361bd20745b14495ee8406271b5f4d2a5ab0775af7d447d3264be1aa6e311
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 2.1.0 (May 2018)
|
2
|
+
|
3
|
+
* Add new configuration option `image_project_id` to allow using GCE images from other projects. [seanmalloy]
|
4
|
+
* Add new configuration option `network_project_id` to allow using GCP Shared VPC networks. [seanmalloy]
|
5
|
+
* Add new configuration option `service_account` to allow setting the IAM service account on instances. [seanmalloy]
|
6
|
+
* Deprecate configuration option `service_accounts`. Use `scopes` configuration option instead. [seanmalloy]
|
7
|
+
|
1
8
|
# 2.0.0 (March 2018)
|
2
9
|
|
3
10
|
* Update to use fog-google gem v1
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
[gem]: https://rubygems.org/gems/vagrant-google
|
8
8
|
[gemnasium]: https://gemnasium.com/mitchellh/vagrant-google
|
9
9
|
|
10
|
-
This is a [Vagrant](http://www.vagrantup.com)
|
10
|
+
This is a [Vagrant](http://www.vagrantup.com) 2.0.3+ plugin that adds an
|
11
11
|
[Google Compute Engine](http://cloud.google.com/compute/) (GCE) provider to
|
12
12
|
Vagrant, allowing Vagrant to control and provision instances in GCE.
|
13
13
|
|
@@ -178,6 +178,7 @@ This provider exposes quite a few provider-specific configuration options:
|
|
178
178
|
* `image_family` - Specify an "image family" to pull the latest image from. For example: `centos-7`
|
179
179
|
will pull the most recent CentOS 7 image. For more info, refer to
|
180
180
|
[Google Image documentation](https://cloud.google.com/compute/docs/images#image_families).
|
181
|
+
* `image_project_id` - The ID of the GCP project to search for the `image` or `image_family`.
|
181
182
|
* `instance_group` - Unmanaged instance group to add the machine to. If one
|
182
183
|
doesn't exist it will be created.
|
183
184
|
* `instance_ready_timeout` - The number of seconds to wait for the instance
|
@@ -192,6 +193,7 @@ will pull the most recent CentOS 7 image. For more info, refer to
|
|
192
193
|
e.g. 10/08/2015 13:15:15 is "i-2015081013-15637fda".
|
193
194
|
* `network` - The name of the network to use for the instance. Default is
|
194
195
|
"default".
|
196
|
+
* `network_project_id` - The ID of the GCP project for the network and subnetwork to use for the instance. Default is `google_project_id`.
|
195
197
|
* `subnetwork` - The name of the subnetwork to use for the instance.
|
196
198
|
* `tags` - An array of tags to apply to this instance.
|
197
199
|
* `labels` - Custom key/value pairs of labels to add to the instance.
|
@@ -202,11 +204,12 @@ will pull the most recent CentOS 7 image. For more info, refer to
|
|
202
204
|
* `preemptible` - Boolean whether to enable preemptibility. Default is false.
|
203
205
|
* `auto_restart` - Boolean whether to enable auto_restart. Default is true.
|
204
206
|
* `on_host_maintenance` - What to do on host maintenance. Can be set to `MIGRATE` or `TERMINATE` Default is `MIGRATE`.
|
205
|
-
* `
|
207
|
+
* `scopes` or `service_accounts` - An array of OAuth2 account scopes for
|
206
208
|
services that the instance will have access to. Those can be both full API
|
207
209
|
scopes, just endpoint aliases (the part after `...auth/`), and `gcloud`
|
208
210
|
utility aliases, for example:
|
209
211
|
`['storage-full', 'bigquery', 'https://www.googleapis.com/auth/compute']`.
|
212
|
+
* `service_account` - The IAM service account email to use for the instance.
|
210
213
|
|
211
214
|
These can be set like typical provider-specific configuration:
|
212
215
|
|
@@ -41,29 +41,32 @@ module VagrantPlugins
|
|
41
41
|
zone = env[:machine].provider_config.zone
|
42
42
|
|
43
43
|
# Get the configs
|
44
|
-
zone_config
|
45
|
-
image
|
46
|
-
image_family
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
44
|
+
zone_config = env[:machine].provider_config.get_zone_config(zone)
|
45
|
+
image = zone_config.image
|
46
|
+
image_family = zone_config.image_family
|
47
|
+
image_project_id = zone_config.image_project_id
|
48
|
+
instance_group = zone_config.instance_group
|
49
|
+
name = zone_config.name
|
50
|
+
machine_type = zone_config.machine_type
|
51
|
+
disk_size = zone_config.disk_size
|
52
|
+
disk_name = zone_config.disk_name
|
53
|
+
disk_type = zone_config.disk_type
|
54
|
+
network = zone_config.network
|
55
|
+
network_project_id = zone_config.network_project_id
|
56
|
+
subnetwork = zone_config.subnetwork
|
57
|
+
metadata = zone_config.metadata
|
58
|
+
labels = zone_config.labels
|
59
|
+
tags = zone_config.tags
|
60
|
+
can_ip_forward = zone_config.can_ip_forward
|
61
|
+
use_private_ip = zone_config.use_private_ip
|
62
|
+
external_ip = zone_config.external_ip
|
63
|
+
preemptible = zone_config.preemptible
|
64
|
+
auto_restart = zone_config.auto_restart
|
65
|
+
on_host_maintenance = zone_config.on_host_maintenance
|
66
|
+
autodelete_disk = zone_config.autodelete_disk
|
67
|
+
service_account_scopes = zone_config.scopes
|
68
|
+
service_account = zone_config.service_account
|
69
|
+
project_id = zone_config.google_project_id
|
67
70
|
|
68
71
|
# Launch!
|
69
72
|
env[:ui].info(I18n.t("vagrant_google.launching_instance"))
|
@@ -75,9 +78,11 @@ module VagrantPlugins
|
|
75
78
|
env[:ui].info(" -- Disk name: #{disk_name}")
|
76
79
|
env[:ui].info(" -- Image: #{image}")
|
77
80
|
env[:ui].info(" -- Image family: #{image_family}")
|
81
|
+
env[:ui].info(" -- Image Project: #{image_project_id}") if image_project_id
|
78
82
|
env[:ui].info(" -- Instance Group: #{instance_group}")
|
79
83
|
env[:ui].info(" -- Zone: #{zone}") if zone
|
80
84
|
env[:ui].info(" -- Network: #{network}") if network
|
85
|
+
env[:ui].info(" -- Network Project: #{network_project_id}") if network_project_id
|
81
86
|
env[:ui].info(" -- Subnetwork: #{subnetwork}") if subnetwork
|
82
87
|
env[:ui].info(" -- Metadata: '#{metadata}'")
|
83
88
|
env[:ui].info(" -- Labels: '#{labels}'")
|
@@ -89,20 +94,21 @@ module VagrantPlugins
|
|
89
94
|
env[:ui].info(" -- Auto Restart: #{auto_restart}")
|
90
95
|
env[:ui].info(" -- On Maintenance: #{on_host_maintenance}")
|
91
96
|
env[:ui].info(" -- Autodelete Disk: #{autodelete_disk}")
|
92
|
-
env[:ui].info(" -- Scopes: #{
|
97
|
+
env[:ui].info(" -- Scopes: #{service_account_scopes}") if service_account_scopes
|
98
|
+
env[:ui].info(" -- Service Account: #{service_account}") if service_account
|
93
99
|
|
94
100
|
# Munge image configs
|
95
|
-
image = env[:google_compute].images.get(image).self_link
|
101
|
+
image = env[:google_compute].images.get(image, image_project_id).self_link
|
96
102
|
|
97
103
|
# If image_family is set, get the latest image image from the family.
|
98
104
|
unless image_family.nil?
|
99
|
-
image = env[:google_compute].images.get_from_family(image_family).self_link
|
105
|
+
image = env[:google_compute].images.get_from_family(image_family, image_project_id).self_link
|
100
106
|
end
|
101
107
|
|
102
108
|
# Munge network configs
|
103
109
|
if network != 'default'
|
104
|
-
network = "projects/#{
|
105
|
-
subnetwork = "projects/#{
|
110
|
+
network = "projects/#{network_project_id}/global/networks/#{network}"
|
111
|
+
subnetwork = "projects/#{network_project_id}/regions/#{zone.split('-')[0..1].join('-')}/subnetworks/#{subnetwork}"
|
106
112
|
else
|
107
113
|
network = "global/networks/default"
|
108
114
|
end
|
@@ -118,7 +124,7 @@ module VagrantPlugins
|
|
118
124
|
scheduling = { :automatic_restart => auto_restart, :on_host_maintenance => on_host_maintenance, :preemptible => preemptible}
|
119
125
|
|
120
126
|
# Munge service_accounts / scopes config
|
121
|
-
service_accounts = [ { :scopes =>
|
127
|
+
service_accounts = [ { :email => service_account, :scopes => service_account_scopes } ]
|
122
128
|
|
123
129
|
begin
|
124
130
|
request_start_time = Time.now.to_i
|
@@ -42,6 +42,11 @@ module VagrantPlugins
|
|
42
42
|
# @return [String]
|
43
43
|
attr_accessor :image_family
|
44
44
|
|
45
|
+
# The name of the image_project_id
|
46
|
+
#
|
47
|
+
# @return [String]
|
48
|
+
attr_accessor :image_project_id
|
49
|
+
|
45
50
|
# The instance group name to put the instance in.
|
46
51
|
#
|
47
52
|
# @return [String]
|
@@ -82,6 +87,11 @@ module VagrantPlugins
|
|
82
87
|
# @return [String]
|
83
88
|
attr_accessor :network
|
84
89
|
|
90
|
+
# The name of the network_project_id
|
91
|
+
#
|
92
|
+
# @return [String]
|
93
|
+
attr_accessor :network_project_id
|
94
|
+
|
85
95
|
# The name of the subnetwork
|
86
96
|
#
|
87
97
|
# @return [String]
|
@@ -148,12 +158,20 @@ module VagrantPlugins
|
|
148
158
|
# @return [String]
|
149
159
|
attr_accessor :zone
|
150
160
|
|
151
|
-
# The list of access
|
161
|
+
# The list of access scopes for instance.
|
162
|
+
#
|
163
|
+
# @return [Array]
|
164
|
+
attr_accessor :scopes
|
165
|
+
|
166
|
+
# Deprecated: the list of access scopes for instance.
|
152
167
|
#
|
153
168
|
# @return [Array]
|
154
169
|
attr_accessor :service_accounts
|
155
|
-
|
156
|
-
|
170
|
+
|
171
|
+
# IAM service account for instance.
|
172
|
+
#
|
173
|
+
# @return [String]
|
174
|
+
attr_accessor :service_account
|
157
175
|
|
158
176
|
def initialize(zone_specific=false)
|
159
177
|
@google_client_email = UNSET_VALUE
|
@@ -161,6 +179,7 @@ module VagrantPlugins
|
|
161
179
|
@google_project_id = UNSET_VALUE
|
162
180
|
@image = UNSET_VALUE
|
163
181
|
@image_family = UNSET_VALUE
|
182
|
+
@image_project_id = UNSET_VALUE
|
164
183
|
@instance_group = UNSET_VALUE
|
165
184
|
@machine_type = UNSET_VALUE
|
166
185
|
@disk_size = UNSET_VALUE
|
@@ -169,6 +188,7 @@ module VagrantPlugins
|
|
169
188
|
@metadata = {}
|
170
189
|
@name = UNSET_VALUE
|
171
190
|
@network = UNSET_VALUE
|
191
|
+
@network_project_id = UNSET_VALUE
|
172
192
|
@subnetwork = UNSET_VALUE
|
173
193
|
@tags = []
|
174
194
|
@labels = {}
|
@@ -181,7 +201,9 @@ module VagrantPlugins
|
|
181
201
|
@on_host_maintenance = UNSET_VALUE
|
182
202
|
@instance_ready_timeout = UNSET_VALUE
|
183
203
|
@zone = UNSET_VALUE
|
204
|
+
@scopes = UNSET_VALUE
|
184
205
|
@service_accounts = UNSET_VALUE
|
206
|
+
@service_account = UNSET_VALUE
|
185
207
|
|
186
208
|
# Internal state (prefix with __ so they aren't automatically
|
187
209
|
# merged)
|
@@ -265,6 +287,9 @@ module VagrantPlugins
|
|
265
287
|
# Default image family is nil
|
266
288
|
@image_family = nil if @image_family == UNSET_VALUE
|
267
289
|
|
290
|
+
# Default image project is nil
|
291
|
+
@image_project_id = nil if @image_project_id == UNSET_VALUE
|
292
|
+
|
268
293
|
# Default instance group name is nil
|
269
294
|
@instance_group = nil if @instance_group == UNSET_VALUE
|
270
295
|
|
@@ -289,6 +314,9 @@ module VagrantPlugins
|
|
289
314
|
# Network defaults to 'default'
|
290
315
|
@network = "default" if @network == UNSET_VALUE
|
291
316
|
|
317
|
+
# Network project id defaults to project_id
|
318
|
+
@network_project_id = @google_project_id if @network_project_id == UNSET_VALUE
|
319
|
+
|
292
320
|
# Subnetwork defaults to nil
|
293
321
|
@subnetwork = nil if @subnetwork == UNSET_VALUE
|
294
322
|
|
@@ -319,9 +347,20 @@ module VagrantPlugins
|
|
319
347
|
# Default instance_ready_timeout
|
320
348
|
@instance_ready_timeout = 20 if @instance_ready_timeout == UNSET_VALUE
|
321
349
|
|
322
|
-
# Default
|
350
|
+
# Default access scopes
|
351
|
+
@scopes = nil if @scopes == UNSET_VALUE
|
352
|
+
|
353
|
+
# Default access scopes
|
323
354
|
@service_accounts = nil if @service_accounts == UNSET_VALUE
|
324
355
|
|
356
|
+
# Default IAM service account
|
357
|
+
@service_account = nil if @service_account == UNSET_VALUE
|
358
|
+
|
359
|
+
# Config option service_accounts is deprecated
|
360
|
+
if @service_accounts
|
361
|
+
@scopes = @service_accounts
|
362
|
+
end
|
363
|
+
|
325
364
|
# Compile our zone specific configurations only within
|
326
365
|
# NON-zone-SPECIFIC configurations.
|
327
366
|
unless @__zone_specific
|
@@ -382,6 +421,10 @@ module VagrantPlugins
|
|
382
421
|
errors << I18n.t("vagrant_google.config.image_required") if config.image.nil? && config.image_family.nil?
|
383
422
|
errors << I18n.t("vagrant_google.config.name_required") if @name.nil?
|
384
423
|
|
424
|
+
if @service_accounts
|
425
|
+
machine.env.ui.warn(I18n.t("vagrant_google.config.service_accounts_deprecaated"))
|
426
|
+
end
|
427
|
+
|
385
428
|
{ "Google Provider" => errors }
|
386
429
|
end
|
387
430
|
|
data/locales/en.yml
CHANGED
@@ -75,6 +75,8 @@ en:
|
|
75
75
|
instances.
|
76
76
|
image_and_image_family_set: |-
|
77
77
|
"image" must be unset when setting "image_family"
|
78
|
+
service_accounts_deprecaated: |-
|
79
|
+
"service_accounts is deprecated. Please use scopes instead"
|
78
80
|
#-------------------------------------------------------------------------------
|
79
81
|
# Translations for exception classes
|
80
82
|
#-------------------------------------------------------------------------------
|
data/tasks/acceptance.rake
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
# This tests that an instance referenced by image family can be started properly
|
2
|
+
shared_examples 'provider/image_family' do |provider, options|
|
3
|
+
unless options[:box]
|
4
|
+
raise ArgumentError,
|
5
|
+
"box option must be specified for provider: #{provider}"
|
6
|
+
end
|
7
|
+
|
8
|
+
include_context 'acceptance'
|
9
|
+
|
10
|
+
before do
|
11
|
+
environment.skeleton('image_family')
|
12
|
+
assert_execute('vagrant', 'box', 'add', 'basic', options[:box])
|
13
|
+
assert_execute('vagrant', 'up', "--provider=#{provider}")
|
14
|
+
end
|
15
|
+
|
16
|
+
after do
|
17
|
+
assert_execute('vagrant', 'destroy', '--force')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should bring up machine with image_family option' do
|
21
|
+
status("Test: machine is running after up")
|
22
|
+
result = execute("vagrant", "ssh", "-c", "echo foo")
|
23
|
+
expect(result).to exit_with(0)
|
24
|
+
expect(result.stdout).to match(/foo\n$/)
|
25
|
+
end
|
26
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# This tests that account scopes can be configured correctly
|
2
|
-
#
|
3
|
-
# available and gcloud GCE aliases can be used.
|
2
|
+
# and that gcloud GCE aliases can be used.
|
4
3
|
# (see lib/fog/google/models/compute/server.rb in fog-google)
|
5
4
|
shared_examples 'provider/scopes' do |provider, options|
|
6
5
|
unless options[:box]
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Vagrant.configure("2") do |config|
|
2
|
+
config.vm.box = "basic"
|
3
|
+
|
4
|
+
config.vm.provider :google do |google|
|
5
|
+
|
6
|
+
google.zone = "australia-southeast1-b"
|
7
|
+
|
8
|
+
google.zone_config "australia-southeast1-b" do |zone|
|
9
|
+
zone.name = "vagrant-acceptance-preemptible-#{('a'..'z').to_a.sample(8).join}"
|
10
|
+
zone.disk_type = "pd-ssd"
|
11
|
+
zone.image_family = "centos-7"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -32,6 +32,8 @@ describe VagrantPlugins::Google::Config do
|
|
32
32
|
|
33
33
|
its("name") { should match "i-[0-9]{10}-[0-9a-f]{4}" }
|
34
34
|
its("image") { should be_nil }
|
35
|
+
its("image_family") { should be_nil }
|
36
|
+
its("image_project_id") { should be_nil }
|
35
37
|
its("instance_group") { should be_nil }
|
36
38
|
its("zone") { should == "us-central1-f" }
|
37
39
|
its("network") { should == "default" }
|
@@ -43,7 +45,7 @@ describe VagrantPlugins::Google::Config do
|
|
43
45
|
its("metadata") { should == {} }
|
44
46
|
its("tags") { should == [] }
|
45
47
|
its("labels") { should == {} }
|
46
|
-
its("
|
48
|
+
its("scopes") { should == nil }
|
47
49
|
its("preemptible") { should be_falsey }
|
48
50
|
its("auto_restart") { should }
|
49
51
|
its("on_host_maintenance") { should == "MIGRATE" }
|
@@ -54,8 +56,8 @@ describe VagrantPlugins::Google::Config do
|
|
54
56
|
# simple boilerplate test, so I cut corners here. It just sets
|
55
57
|
# each of these attributes to "foo" in isolation, and reads the value
|
56
58
|
# and asserts the proper result comes back out.
|
57
|
-
[:name, :image, :zone, :instance_ready_timeout, :machine_type, :disk_size, :disk_name, :disk_type,
|
58
|
-
:network, :metadata, :labels, :can_ip_forward, :external_ip, :autodelete_disk].each do |attribute|
|
59
|
+
[:name, :image, :image_family, :image_project_id, :zone, :instance_ready_timeout, :machine_type, :disk_size, :disk_name, :disk_type,
|
60
|
+
:network, :network_project_id, :metadata, :labels, :can_ip_forward, :external_ip, :autodelete_disk].each do |attribute|
|
59
61
|
|
60
62
|
it "should not default #{attribute} if overridden" do
|
61
63
|
instance.send("#{attribute}=".to_sym, "foo")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-google
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Johnson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-05-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog-google
|
@@ -196,6 +196,7 @@ files:
|
|
196
196
|
- tasks/test.rake
|
197
197
|
- test/acceptance/base.rb
|
198
198
|
- test/acceptance/provider/halt_spec.rb
|
199
|
+
- test/acceptance/provider/image_family_spec.rb
|
199
200
|
- test/acceptance/provider/instance_groups_spec.rb
|
200
201
|
- test/acceptance/provider/multi_instance_spec.rb
|
201
202
|
- test/acceptance/provider/preemptible_spec.rb
|
@@ -203,6 +204,7 @@ files:
|
|
203
204
|
- test/acceptance/provider/scopes_spec.rb
|
204
205
|
- test/acceptance/shared/context_google.rb
|
205
206
|
- test/acceptance/skeletons/generic/Vagrantfile
|
207
|
+
- test/acceptance/skeletons/image_family/Vagrantfile
|
206
208
|
- test/acceptance/skeletons/instance_groups/Vagrantfile
|
207
209
|
- test/acceptance/skeletons/multi_instance/Vagrantfile
|
208
210
|
- test/acceptance/skeletons/preemptible/Vagrantfile
|