cloud-mu 3.2.0 → 3.5.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/Dockerfile +1 -1
- data/ansible/roles/mu-nat/tasks/main.yml +3 -0
- data/bin/mu-adopt +12 -1
- data/bin/mu-aws-setup +41 -7
- data/bin/mu-azure-setup +34 -0
- data/bin/mu-configure +214 -119
- data/bin/mu-gcp-setup +37 -2
- data/bin/mu-load-config.rb +2 -1
- data/bin/mu-node-manage +3 -0
- data/bin/mu-refresh-ssl +67 -0
- data/bin/mu-run-tests +28 -6
- data/bin/mu-self-update +30 -10
- data/bin/mu-upload-chef-artifacts +30 -26
- data/cloud-mu.gemspec +10 -8
- data/cookbooks/mu-master/attributes/default.rb +5 -1
- data/cookbooks/mu-master/metadata.rb +2 -2
- data/cookbooks/mu-master/recipes/default.rb +81 -26
- data/cookbooks/mu-master/recipes/init.rb +197 -62
- data/cookbooks/mu-master/recipes/update_nagios_only.rb +1 -1
- data/cookbooks/mu-master/recipes/vault.rb +78 -77
- data/cookbooks/mu-master/templates/default/mods/rewrite.conf.erb +1 -0
- data/cookbooks/mu-master/templates/default/nagios.conf.erb +103 -0
- data/cookbooks/mu-master/templates/default/web_app.conf.erb +14 -30
- data/cookbooks/mu-tools/attributes/default.rb +12 -0
- data/cookbooks/mu-tools/files/centos-6/CentOS-Base.repo +47 -0
- data/cookbooks/mu-tools/libraries/helper.rb +98 -4
- data/cookbooks/mu-tools/libraries/monkey.rb +1 -1
- data/cookbooks/mu-tools/recipes/apply_security.rb +31 -9
- data/cookbooks/mu-tools/recipes/aws_api.rb +8 -2
- data/cookbooks/mu-tools/recipes/base_repositories.rb +1 -1
- data/cookbooks/mu-tools/recipes/gcloud.rb +2 -9
- data/cookbooks/mu-tools/recipes/google_api.rb +7 -0
- data/cookbooks/mu-tools/recipes/rsyslog.rb +8 -1
- data/cookbooks/mu-tools/resources/disk.rb +113 -42
- data/cookbooks/mu-tools/resources/mommacat_request.rb +1 -2
- data/cookbooks/mu-tools/templates/centos-8/sshd_config.erb +215 -0
- data/extras/Gemfile.lock.bootstrap +394 -0
- data/extras/bucketstubs/error.html +0 -0
- data/extras/bucketstubs/index.html +0 -0
- data/extras/clean-stock-amis +11 -3
- data/extras/generate-stock-images +6 -3
- data/extras/git_rpm/build.sh +20 -0
- data/extras/git_rpm/mugit.spec +53 -0
- data/extras/image-generators/AWS/centos7.yaml +19 -16
- data/extras/image-generators/AWS/{rhel7.yaml → rhel71.yaml} +0 -0
- data/extras/image-generators/AWS/{win2k12.yaml → win2k12r2.yaml} +0 -0
- data/extras/image-generators/VMWare/centos8.yaml +15 -0
- data/extras/openssl_rpm/build.sh +19 -0
- data/extras/openssl_rpm/mussl.spec +46 -0
- data/extras/python_rpm/muthon.spec +14 -4
- data/extras/ruby_rpm/muby.spec +9 -5
- data/extras/sqlite_rpm/build.sh +19 -0
- data/extras/sqlite_rpm/muqlite.spec +47 -0
- data/install/installer +7 -5
- data/modules/mommacat.ru +2 -2
- data/modules/mu.rb +14 -7
- data/modules/mu/adoption.rb +5 -5
- data/modules/mu/cleanup.rb +47 -25
- data/modules/mu/cloud.rb +29 -1
- data/modules/mu/cloud/dnszone.rb +0 -2
- data/modules/mu/cloud/machine_images.rb +1 -1
- data/modules/mu/cloud/providers.rb +6 -1
- data/modules/mu/cloud/resource_base.rb +16 -7
- data/modules/mu/cloud/ssh_sessions.rb +5 -1
- data/modules/mu/cloud/wrappers.rb +20 -7
- data/modules/mu/config.rb +28 -12
- data/modules/mu/config/bucket.rb +31 -2
- data/modules/mu/config/cache_cluster.rb +1 -1
- data/modules/mu/config/cdn.rb +100 -0
- data/modules/mu/config/container_cluster.rb +1 -1
- data/modules/mu/config/database.rb +3 -3
- data/modules/mu/config/dnszone.rb +4 -3
- data/modules/mu/config/endpoint.rb +1 -0
- data/modules/mu/config/firewall_rule.rb +1 -1
- data/modules/mu/config/function.rb +16 -7
- data/modules/mu/config/job.rb +89 -0
- data/modules/mu/config/notifier.rb +7 -18
- data/modules/mu/config/ref.rb +55 -9
- data/modules/mu/config/schema_helpers.rb +12 -3
- data/modules/mu/config/server.rb +11 -5
- data/modules/mu/config/server_pool.rb +2 -2
- data/modules/mu/config/vpc.rb +11 -10
- data/modules/mu/defaults/AWS.yaml +106 -106
- data/modules/mu/deploy.rb +40 -14
- data/modules/mu/groomers/chef.rb +2 -2
- data/modules/mu/master.rb +70 -3
- data/modules/mu/mommacat.rb +28 -9
- data/modules/mu/mommacat/daemon.rb +13 -7
- data/modules/mu/mommacat/naming.rb +2 -2
- data/modules/mu/mommacat/search.rb +16 -5
- data/modules/mu/mommacat/storage.rb +67 -32
- data/modules/mu/providers/aws.rb +298 -85
- data/modules/mu/providers/aws/alarm.rb +5 -5
- data/modules/mu/providers/aws/bucket.rb +284 -50
- data/modules/mu/providers/aws/cache_cluster.rb +26 -26
- data/modules/mu/providers/aws/cdn.rb +782 -0
- data/modules/mu/providers/aws/collection.rb +16 -16
- data/modules/mu/providers/aws/container_cluster.rb +84 -64
- data/modules/mu/providers/aws/database.rb +59 -55
- data/modules/mu/providers/aws/dnszone.rb +29 -12
- data/modules/mu/providers/aws/endpoint.rb +535 -50
- data/modules/mu/providers/aws/firewall_rule.rb +32 -26
- data/modules/mu/providers/aws/folder.rb +1 -1
- data/modules/mu/providers/aws/function.rb +300 -134
- data/modules/mu/providers/aws/group.rb +16 -14
- data/modules/mu/providers/aws/habitat.rb +4 -4
- data/modules/mu/providers/aws/job.rb +469 -0
- data/modules/mu/providers/aws/loadbalancer.rb +67 -45
- data/modules/mu/providers/aws/log.rb +17 -17
- data/modules/mu/providers/aws/msg_queue.rb +22 -13
- data/modules/mu/providers/aws/nosqldb.rb +99 -8
- data/modules/mu/providers/aws/notifier.rb +137 -65
- data/modules/mu/providers/aws/role.rb +119 -83
- data/modules/mu/providers/aws/search_domain.rb +166 -30
- data/modules/mu/providers/aws/server.rb +209 -118
- data/modules/mu/providers/aws/server_pool.rb +95 -130
- data/modules/mu/providers/aws/storage_pool.rb +19 -11
- data/modules/mu/providers/aws/user.rb +5 -5
- data/modules/mu/providers/aws/userdata/linux.erb +5 -4
- data/modules/mu/providers/aws/vpc.rb +109 -54
- data/modules/mu/providers/aws/vpc_subnet.rb +43 -39
- data/modules/mu/providers/azure.rb +78 -12
- data/modules/mu/providers/azure/server.rb +20 -4
- data/modules/mu/providers/cloudformation/server.rb +1 -1
- data/modules/mu/providers/google.rb +21 -5
- data/modules/mu/providers/google/bucket.rb +1 -1
- data/modules/mu/providers/google/container_cluster.rb +1 -1
- data/modules/mu/providers/google/database.rb +1 -1
- data/modules/mu/providers/google/firewall_rule.rb +1 -1
- data/modules/mu/providers/google/folder.rb +7 -3
- data/modules/mu/providers/google/function.rb +66 -31
- data/modules/mu/providers/google/group.rb +1 -1
- data/modules/mu/providers/google/habitat.rb +1 -1
- data/modules/mu/providers/google/loadbalancer.rb +1 -1
- data/modules/mu/providers/google/role.rb +6 -3
- data/modules/mu/providers/google/server.rb +1 -1
- data/modules/mu/providers/google/server_pool.rb +1 -1
- data/modules/mu/providers/google/user.rb +1 -1
- data/modules/mu/providers/google/vpc.rb +28 -3
- data/modules/tests/aws-jobs-functions.yaml +46 -0
- data/modules/tests/aws-servers-with-handrolled-iam.yaml +37 -0
- data/modules/tests/centos6.yaml +4 -0
- data/modules/tests/centos7.yaml +4 -0
- data/modules/tests/ecs.yaml +2 -2
- data/modules/tests/eks.yaml +1 -1
- data/modules/tests/functions/node-function/lambda_function.js +10 -0
- data/modules/tests/functions/python-function/lambda_function.py +12 -0
- data/modules/tests/k8s.yaml +1 -1
- data/modules/tests/microservice_app.yaml +288 -0
- data/modules/tests/rds.yaml +5 -5
- data/modules/tests/regrooms/rds.yaml +5 -5
- data/modules/tests/server-with-scrub-muisms.yaml +1 -1
- data/modules/tests/super_complex_bok.yml +2 -2
- data/modules/tests/super_simple_bok.yml +2 -2
- metadata +42 -17
|
@@ -144,7 +144,7 @@ module MU
|
|
|
144
144
|
# @param noop [Boolean]: If true, will only print what would be done
|
|
145
145
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
146
146
|
# @return [void]
|
|
147
|
-
def self.cleanup(noop: false, ignoremaster: false, credentials: nil, flags: {})
|
|
147
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, credentials: nil, flags: {})
|
|
148
148
|
flags["habitat"] ||= MU::Cloud::Google.defaultProject(credentials)
|
|
149
149
|
|
|
150
150
|
resp = MU::Cloud::Google.storage(credentials: credentials).list_buckets(flags['habitat'])
|
|
@@ -744,7 +744,7 @@ module MU
|
|
|
744
744
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
745
745
|
# @param region [String]: The cloud provider region in which to operate
|
|
746
746
|
# @return [void]
|
|
747
|
-
def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
747
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
748
748
|
|
|
749
749
|
flags["habitat"] ||= MU::Cloud::Google.defaultProject(credentials)
|
|
750
750
|
return if !MU::Cloud.resourceClass("Google", "Habitat").isLive?(flags["habitat"], credentials)
|
|
@@ -100,7 +100,7 @@ module MU
|
|
|
100
100
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
101
101
|
# @param region [String]: The cloud provider region in which to operate
|
|
102
102
|
# @return [void]
|
|
103
|
-
def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
103
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
104
104
|
flags["habitat"] ||= MU::Cloud::Google.defaultProject(credentials)
|
|
105
105
|
|
|
106
106
|
# instances = MU::Cloud::Google.sql(credentials: credentials).list_instances(flags['habitat'], filter: %Q{userLabels.mu-id:"#{MU.deploy_id.downcase}"})
|
|
@@ -207,7 +207,7 @@ end
|
|
|
207
207
|
# @param noop [Boolean]: If true, will only print what would be done
|
|
208
208
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
209
209
|
# @return [void]
|
|
210
|
-
def self.cleanup(noop: false, ignoremaster: false, credentials: nil, flags: {})
|
|
210
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, credentials: nil, flags: {})
|
|
211
211
|
flags["habitat"] ||= MU::Cloud::Google.defaultProject(credentials)
|
|
212
212
|
return if !MU::Cloud.resourceClass("Google", "Habitat").isLive?(flags["habitat"], credentials)
|
|
213
213
|
filter = %Q{(labels.mu-id = "#{MU.deploy_id.downcase}")}
|
|
@@ -162,7 +162,7 @@ module MU
|
|
|
162
162
|
# @param noop [Boolean]: If true, will only print what would be done
|
|
163
163
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
164
164
|
# @return [void]
|
|
165
|
-
def self.cleanup(noop: false, ignoremaster: false, credentials: nil, flags: {})
|
|
165
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, credentials: nil, flags: {})
|
|
166
166
|
filter = %Q{(labels.mu-id = "#{MU.deploy_id.downcase}")}
|
|
167
167
|
if !ignoremaster and MU.mu_public_ip
|
|
168
168
|
filter += %Q{ AND (labels.mu-master-ip = "#{MU.mu_public_ip.gsub(/\./, "_")}")}
|
|
@@ -265,8 +265,12 @@ module MU
|
|
|
265
265
|
|
|
266
266
|
if args[:cloud_id]
|
|
267
267
|
raw_id = args[:cloud_id].sub(/^folders\//, "")
|
|
268
|
-
|
|
269
|
-
|
|
268
|
+
begin
|
|
269
|
+
resp = MU::Cloud::Google.folder(credentials: args[:credentials]).get_folder("folders/"+raw_id)
|
|
270
|
+
found[resp.name] = resp if resp
|
|
271
|
+
rescue ::Google::Apis::ClientError => e
|
|
272
|
+
raise e if e.message !~ /forbidden: /
|
|
273
|
+
end
|
|
270
274
|
|
|
271
275
|
elsif args[:flags] and args[:flags]['display_name']
|
|
272
276
|
|
|
@@ -119,6 +119,9 @@ module example.com/cloudfunction
|
|
|
119
119
|
# Called automatically by {MU::Deploy#createResources}
|
|
120
120
|
def groom
|
|
121
121
|
desc = {}
|
|
122
|
+
|
|
123
|
+
func_obj = buildDesc
|
|
124
|
+
|
|
122
125
|
labels = Hash[@tags.keys.map { |k|
|
|
123
126
|
[k.downcase, @tags[k].downcase.gsub(/[^-_a-z0-9]/, '-')] }
|
|
124
127
|
]
|
|
@@ -140,6 +143,10 @@ module example.com/cloudfunction
|
|
|
140
143
|
if cloud_desc.available_memory_mb != @config['memory']
|
|
141
144
|
need_update = true
|
|
142
145
|
end
|
|
146
|
+
if cloud_desc.service_account_email != func_obj.service_account_email
|
|
147
|
+
need_update = true
|
|
148
|
+
end
|
|
149
|
+
|
|
143
150
|
if @config['environment_variable']
|
|
144
151
|
@config['environment_variable'].each { |var|
|
|
145
152
|
if !cloud_desc.environment_variables or
|
|
@@ -161,7 +168,17 @@ module example.com/cloudfunction
|
|
|
161
168
|
File.read("#{dir}/current.zip")
|
|
162
169
|
}
|
|
163
170
|
|
|
164
|
-
|
|
171
|
+
tempfile = nil
|
|
172
|
+
new = if @config['code']['zip_file'] or @config['code']['path']
|
|
173
|
+
if @config['code']['path']
|
|
174
|
+
tempfile = Tempfile.new(["function", ".zip"])
|
|
175
|
+
MU.log "#{@mu_name} using code at #{@config['code']['path']}"
|
|
176
|
+
MU::Master.zipDir(@config['code']['path'], tempfile.path)
|
|
177
|
+
@config['code']['zip_file'] = tempfile.path
|
|
178
|
+
else
|
|
179
|
+
MU.log "#{@mu_name} using code packaged at #{@config['code']['zip_file']}"
|
|
180
|
+
end
|
|
181
|
+
# @code_sha256 = Base64.encode64(Digest::SHA256.digest(zip)).chomp
|
|
165
182
|
File.read(@config['code']['zip_file'])
|
|
166
183
|
elsif @config['code']['gs_url']
|
|
167
184
|
@config['code']['gs_url'].match(/^gs:\/\/([^\/]+)\/(.*)/)
|
|
@@ -172,25 +189,31 @@ module example.com/cloudfunction
|
|
|
172
189
|
File.read(dir+"/new.zip")
|
|
173
190
|
}
|
|
174
191
|
end
|
|
192
|
+
|
|
175
193
|
if @config['code']['gs_url'] and
|
|
176
194
|
(@config['code']['gs_url'] != cloud_desc.source_archive_url or
|
|
177
195
|
current != new)
|
|
178
196
|
need_update = true
|
|
179
|
-
elsif @config['code']['zip_file'] and current != new
|
|
197
|
+
elsif (@config['code']['zip_file'] or @config['code']['path']) and current != new
|
|
180
198
|
need_update = true
|
|
181
|
-
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
if @config['vpc_connector']
|
|
202
|
+
if cloud_desc.vpc_connector != @config['vpc_connector'] or
|
|
203
|
+
cloud_desc.vpc_connector_egress_settings != (@config['vpc_connector_allow_all_egress'] ? "ALL_TRAFFIC" : "PRIVATE_RANGES_ONLY")
|
|
204
|
+
need_update = true
|
|
205
|
+
end
|
|
182
206
|
end
|
|
183
207
|
|
|
184
208
|
if need_update
|
|
185
|
-
|
|
186
|
-
MU.log "Updating Cloud Function #{@mu_name}", MU::NOTICE, details: func_obj
|
|
209
|
+
MU.log "Updating Cloud Function #{@cloud_id}", MU::NOTICE, details: func_obj
|
|
187
210
|
begin
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
rescue ::Google::Apis::ClientError
|
|
193
|
-
MU.log "Error updating Cloud Function #{@mu_name}.", MU::ERR
|
|
211
|
+
MU::Cloud::Google.function(credentials: @credentials).patch_project_location_function(
|
|
212
|
+
@cloud_id,
|
|
213
|
+
func_obj
|
|
214
|
+
)
|
|
215
|
+
rescue ::Google::Apis::ClientError => e
|
|
216
|
+
MU.log "Error updating Cloud Function #{@mu_name}.", MU::ERR, e.message
|
|
194
217
|
if desc[:source_archive_url]
|
|
195
218
|
main_file = nil
|
|
196
219
|
HELLO_WORLDS.each_pair { |runtime, code|
|
|
@@ -207,6 +230,11 @@ module example.com/cloudfunction
|
|
|
207
230
|
# service_account_email: sa.kitten.cloud_desc.email,
|
|
208
231
|
# labels: labels,
|
|
209
232
|
|
|
233
|
+
if tempfile
|
|
234
|
+
tempfile.close
|
|
235
|
+
tempfile.unlink
|
|
236
|
+
end
|
|
237
|
+
|
|
210
238
|
end
|
|
211
239
|
|
|
212
240
|
# Return the metadata for this project's configuration
|
|
@@ -233,7 +261,7 @@ module example.com/cloudfunction
|
|
|
233
261
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
234
262
|
# @param region [String]: The cloud provider region
|
|
235
263
|
# @return [void]
|
|
236
|
-
def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
264
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
237
265
|
flags["habitat"] ||= MU::Cloud::Google.defaultProject(credentials)
|
|
238
266
|
return if !MU::Cloud.resourceClass("Google", "Habitat").isLive?(flags["habitat"], credentials)
|
|
239
267
|
# Make sure we catch regional *and* zone functions
|
|
@@ -354,6 +382,7 @@ module example.com/cloudfunction
|
|
|
354
382
|
def self.schema(config)
|
|
355
383
|
toplevel_required = ["runtime"]
|
|
356
384
|
schema = {
|
|
385
|
+
"roles" => MU::Cloud.resourceClass("Google", "User").schema(config)[1]["roles"],
|
|
357
386
|
"triggers" => {
|
|
358
387
|
"type" => "array",
|
|
359
388
|
"items" => {
|
|
@@ -448,6 +477,7 @@ module example.com/cloudfunction
|
|
|
448
477
|
content_type: "application/zip",
|
|
449
478
|
name: filename
|
|
450
479
|
)
|
|
480
|
+
|
|
451
481
|
MU::Cloud::Google.storage(credentials: credentials).insert_object(
|
|
452
482
|
bucket,
|
|
453
483
|
obj_obj,
|
|
@@ -487,7 +517,7 @@ module example.com/cloudfunction
|
|
|
487
517
|
end
|
|
488
518
|
# XXX list_project_locations
|
|
489
519
|
|
|
490
|
-
if !function['code'] or (!function['code']['zip_file'] and !function['code']['gs_url'])
|
|
520
|
+
if !function['code'] or (!function['code']['zip_file'] and !function['code']['gs_url'] and !function['code']['path'])
|
|
491
521
|
MU.log "Must specify a code source in Cloud Function #{function['name']}", MU::ERR
|
|
492
522
|
ok = false
|
|
493
523
|
elsif function['code']['zip_file']
|
|
@@ -557,22 +587,14 @@ module example.com/cloudfunction
|
|
|
557
587
|
|
|
558
588
|
location = "projects/"+@config['project']+"/locations/"+@config['region']
|
|
559
589
|
sa = nil
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
end
|
|
567
|
-
rescue ::Google::Apis::ClientError => e
|
|
568
|
-
if e.message.match(/notFound:/)
|
|
569
|
-
sleep 10
|
|
570
|
-
retries += 1
|
|
571
|
-
retry
|
|
572
|
-
end
|
|
573
|
-
end while !sa or !sa.cloud_desc and retries < 5
|
|
590
|
+
need_sa = Proc.new {
|
|
591
|
+
!sa or !sa.kitten or !sa.kitten.cloud_desc
|
|
592
|
+
}
|
|
593
|
+
MU.retrier(loop_if: need_sa, wait: 10, max: 6) { |retries, _wait|
|
|
594
|
+
sa = MU::Config::Ref.get(@config['service_account'])
|
|
595
|
+
}
|
|
574
596
|
|
|
575
|
-
if
|
|
597
|
+
if need_sa.call()
|
|
576
598
|
raise MuError, "Failed to get service account cloud id from #{@config['service_account'].to_s}"
|
|
577
599
|
end
|
|
578
600
|
|
|
@@ -583,7 +605,7 @@ module example.com/cloudfunction
|
|
|
583
605
|
# entry_point: "hello_world",
|
|
584
606
|
entry_point: @config['handler'],
|
|
585
607
|
description: @deploy.deploy_id,
|
|
586
|
-
service_account_email: sa.cloud_desc.email,
|
|
608
|
+
service_account_email: sa.kitten.cloud_desc.email,
|
|
587
609
|
labels: labels,
|
|
588
610
|
available_memory_mb: @config['memory']
|
|
589
611
|
}
|
|
@@ -596,7 +618,6 @@ module example.com/cloudfunction
|
|
|
596
618
|
if @config['vpc_connector']
|
|
597
619
|
desc[:vpc_connector] = @config['vpc_connector']
|
|
598
620
|
desc[:vpc_connector_egress_settings] = @config['vpc_connector_allow_all_egress'] ? "ALL_TRAFFIC" : "PRIVATE_RANGES_ONLY"
|
|
599
|
-
pp desc
|
|
600
621
|
elsif @vpc
|
|
601
622
|
desc[:network] = @vpc.url.sub(/^.*?\/projects\//, 'projects/')
|
|
602
623
|
end
|
|
@@ -627,8 +648,22 @@ module example.com/cloudfunction
|
|
|
627
648
|
# }
|
|
628
649
|
if @config['code']['gs_url']
|
|
629
650
|
desc[:source_archive_url] = @config['code']['gs_url']
|
|
630
|
-
elsif @config['code']['zip_file']
|
|
651
|
+
elsif @config['code']['zip_file'] or @config['code']['path']
|
|
652
|
+
tempfile = nil
|
|
653
|
+
if @config['code']['path']
|
|
654
|
+
tempfile = Tempfile.new(["function", ".zip"])
|
|
655
|
+
MU.log "#{@mu_name} using code at #{@config['code']['path']}"
|
|
656
|
+
MU::Master.zipDir(@config['code']['path'], tempfile.path)
|
|
657
|
+
@config['code']['zip_file'] = tempfile.path
|
|
658
|
+
else
|
|
659
|
+
MU.log "#{@mu_name} using code packaged at #{@config['code']['zip_file']}"
|
|
660
|
+
end
|
|
631
661
|
desc[:source_archive_url] = MU::Cloud::Google::Function.uploadPackage(@config['code']['zip_file'], @mu_name+"-cloudfunction.zip", credentials: @credentials)
|
|
662
|
+
|
|
663
|
+
if tempfile
|
|
664
|
+
tempfile.close
|
|
665
|
+
tempfile.unlink
|
|
666
|
+
end
|
|
632
667
|
end
|
|
633
668
|
|
|
634
669
|
# Dir.mktmpdir(@mu_name) { |dir|
|
|
@@ -140,7 +140,7 @@ module MU
|
|
|
140
140
|
# @param noop [Boolean]: If true, will only print what would be done
|
|
141
141
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
142
142
|
# @return [void]
|
|
143
|
-
def self.cleanup(noop: false, ignoremaster: false, credentials: nil, flags: {})
|
|
143
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, credentials: nil, flags: {})
|
|
144
144
|
MU::Cloud::Google.getDomains(credentials)
|
|
145
145
|
my_org = MU::Cloud::Google.getOrg(credentials)
|
|
146
146
|
|
|
@@ -222,7 +222,7 @@ module MU
|
|
|
222
222
|
# @param noop [Boolean]: If true, will only print what would be done
|
|
223
223
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
224
224
|
# @return [void]
|
|
225
|
-
def self.cleanup(noop: false, ignoremaster: false, credentials: nil, flags: {})
|
|
225
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, credentials: nil, flags: {})
|
|
226
226
|
resp = MU::Cloud::Google.resource_manager(credentials: credentials).list_projects
|
|
227
227
|
|
|
228
228
|
if resp and resp.projects
|
|
@@ -146,7 +146,7 @@ module MU
|
|
|
146
146
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
147
147
|
# @param region [String]: The cloud provider region
|
|
148
148
|
# @return [void]
|
|
149
|
-
def self.cleanup(noop: false, ignoremaster: false, region: nil, credentials: nil, flags: {})
|
|
149
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: nil, credentials: nil, flags: {})
|
|
150
150
|
flags["habitat"] ||= MU::Cloud::Google.defaultProject(credentials)
|
|
151
151
|
return if !MU::Cloud.resourceClass("Google", "Habitat").isLive?(flags["habitat"], credentials)
|
|
152
152
|
filter = %Q{(labels.mu-id = "#{MU.deploy_id.downcase}")}
|
|
@@ -465,7 +465,7 @@ module MU
|
|
|
465
465
|
# @param noop [Boolean]: If true, will only print what would be done
|
|
466
466
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
467
467
|
# @return [void]
|
|
468
|
-
def self.cleanup(noop: false, ignoremaster: false, credentials: nil, flags: {})
|
|
468
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, credentials: nil, flags: {})
|
|
469
469
|
customer = MU::Cloud::Google.customerID(credentials)
|
|
470
470
|
my_org = MU::Cloud::Google.getOrg(credentials)
|
|
471
471
|
|
|
@@ -581,7 +581,7 @@ module MU
|
|
|
581
581
|
}
|
|
582
582
|
end
|
|
583
583
|
if args[:cloud_id]
|
|
584
|
-
found.reject! { |k, _v| k !=
|
|
584
|
+
found.reject! { |k, _v| k != args[:cloud_id] }
|
|
585
585
|
end
|
|
586
586
|
|
|
587
587
|
# Now go get everything that's bound here
|
|
@@ -745,6 +745,7 @@ module MU
|
|
|
745
745
|
end
|
|
746
746
|
|
|
747
747
|
entity_types.each_pair { |entity_type, entities|
|
|
748
|
+
next if entity_type == "deleted"
|
|
748
749
|
mu_entitytype = (entity_type == "serviceAccount" ? "user" : entity_type)+"s"
|
|
749
750
|
entities.each { |entity|
|
|
750
751
|
next if entity.nil?
|
|
@@ -925,7 +926,9 @@ module MU
|
|
|
925
926
|
}
|
|
926
927
|
|
|
927
928
|
MU::Cloud.resourceClass("Google", "Folder").find(credentials: credentials).keys.each { |folder|
|
|
928
|
-
MU::Cloud.resourceClass("Google", "Folder").bindings(folder, credentials: credentials)
|
|
929
|
+
folder_bindings = MU::Cloud.resourceClass("Google", "Folder").bindings(folder, credentials: credentials)
|
|
930
|
+
next if !folder_bindings
|
|
931
|
+
folder_bindings.each { |binding|
|
|
929
932
|
insertBinding("folders", folder, binding)
|
|
930
933
|
}
|
|
931
934
|
}
|
|
@@ -1290,7 +1290,7 @@ next if !create
|
|
|
1290
1290
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
1291
1291
|
# @param region [String]: The cloud provider region
|
|
1292
1292
|
# @return [void]
|
|
1293
|
-
def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
1293
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
1294
1294
|
flags["habitat"] ||= MU::Cloud::Google.defaultProject(credentials)
|
|
1295
1295
|
return if !MU::Cloud.resourceClass("Google", "Habitat").isLive?(flags["habitat"], credentials)
|
|
1296
1296
|
|
|
@@ -431,7 +431,7 @@ end
|
|
|
431
431
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
432
432
|
# @param region [String]: The cloud provider region
|
|
433
433
|
# @return [void]
|
|
434
|
-
def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
434
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
435
435
|
flags["habitat"] ||= MU::Cloud::Google.defaultProject(credentials)
|
|
436
436
|
return if !MU::Cloud.resourceClass("Google", "Habitat").isLive?(flags["habitat"], credentials)
|
|
437
437
|
filter = %Q{(labels.mu-id = "#{MU.deploy_id.downcase}")}
|
|
@@ -254,7 +254,7 @@ module MU
|
|
|
254
254
|
# @param noop [Boolean]: If true, will only print what would be done
|
|
255
255
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
256
256
|
# @return [void]
|
|
257
|
-
def self.cleanup(noop: false, ignoremaster: false, credentials: nil, flags: {})
|
|
257
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, credentials: nil, flags: {})
|
|
258
258
|
MU::Cloud::Google.getDomains(credentials)
|
|
259
259
|
my_org = MU::Cloud::Google.getOrg(credentials)
|
|
260
260
|
|
|
@@ -364,6 +364,12 @@ end
|
|
|
364
364
|
}
|
|
365
365
|
end
|
|
366
366
|
|
|
367
|
+
|
|
368
|
+
# The API is filled with lies
|
|
369
|
+
@subnets.reject! { |s|
|
|
370
|
+
!MU::Cloud::Google.listRegions(credentials: @credentials).include?(s.az)
|
|
371
|
+
}
|
|
372
|
+
|
|
367
373
|
return @subnets
|
|
368
374
|
end
|
|
369
375
|
|
|
@@ -442,14 +448,19 @@ end
|
|
|
442
448
|
|
|
443
449
|
# Check for a subnet in this VPC matching one or more of the specified
|
|
444
450
|
# criteria, and return it if found.
|
|
445
|
-
def getSubnet(cloud_id: nil, name: nil, tag_key: nil, tag_value: nil, ip_block: nil, region: nil)
|
|
451
|
+
def getSubnet(cloud_id: nil, name: nil, tag_key: nil, tag_value: nil, ip_block: nil, region: nil, subnet_mu_name: nil)
|
|
446
452
|
if !cloud_id.nil? and cloud_id.match(/^https:\/\//)
|
|
447
453
|
cloud_id.match(/\/regions\/([^\/]+)\/subnetworks\/([^\/]+)$/)
|
|
448
454
|
region = Regexp.last_match[1]
|
|
449
455
|
cloud_id = Regexp.last_match[2]
|
|
450
456
|
cloud_id.gsub!(/.*?\//, "")
|
|
451
457
|
end
|
|
452
|
-
|
|
458
|
+
|
|
459
|
+
if name
|
|
460
|
+
subnet_mu_name ||= @config['scrub_mu_isms'] ? @cloud_id+name.downcase : MU::Cloud::Google.nameStr(@deploy.getResourceName(name, max_length: 61))
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
MU.log "getSubnet(cloud_id: #{cloud_id}, name: #{name}, tag_key: #{tag_key}, tag_value: #{tag_value}, ip_block: #{ip_block}, region: #{region}, subnet_mu_name: #{subnet_mu_name})", MU::DEBUG, details: caller[0]
|
|
453
464
|
subnets.each { |subnet|
|
|
454
465
|
next if region and subnet.az != region
|
|
455
466
|
if !cloud_id.nil? and !subnet.cloud_id.nil? and subnet.cloud_id.to_s == cloud_id.to_s
|
|
@@ -457,6 +468,9 @@ end
|
|
|
457
468
|
elsif !name.nil? and !subnet.name.nil? and
|
|
458
469
|
subnet.name.downcase.to_s == name.downcase.to_s
|
|
459
470
|
return subnet
|
|
471
|
+
elsif !subnet_mu_name.nil? and !subnet.name.nil? and
|
|
472
|
+
subnet.name.downcase.to_s == subnet_mu_name.downcase.to_s
|
|
473
|
+
return subnet
|
|
460
474
|
end
|
|
461
475
|
}
|
|
462
476
|
return nil
|
|
@@ -537,7 +551,7 @@ MU.log "ROUTES TO #{target_instance.name}", MU::WARN, details: resp
|
|
|
537
551
|
# @param noop [Boolean]: If true, will only print what would be done
|
|
538
552
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
539
553
|
# @return [void]
|
|
540
|
-
def self.cleanup(noop: false, ignoremaster: false, credentials: nil, flags: {})
|
|
554
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, credentials: nil, flags: {})
|
|
541
555
|
flags["habitat"] ||= MU::Cloud::Google.defaultProject(credentials)
|
|
542
556
|
return if !MU::Cloud.resourceClass("Google", "Habitat").isLive?(flags["habitat"], credentials)
|
|
543
557
|
filter = %Q{(labels.mu-id = "#{MU.deploy_id.downcase}")}
|
|
@@ -931,6 +945,14 @@ MU.log "ROUTES TO #{target_instance.name}", MU::WARN, details: resp
|
|
|
931
945
|
else
|
|
932
946
|
route['nat_host_name'] = nat['name']
|
|
933
947
|
route['priority'] = 100
|
|
948
|
+
MU::Config.addDependency(vpc, nat['name'], "server", their_phase: "groom", my_phase: "groom")
|
|
949
|
+
vpc["bastion"] = MU::Config::Ref.get(
|
|
950
|
+
name: nat['name'],
|
|
951
|
+
cloud: vpc['cloud'],
|
|
952
|
+
credentials: vpc['credentials'],
|
|
953
|
+
type: "servers"
|
|
954
|
+
)
|
|
955
|
+
|
|
934
956
|
end
|
|
935
957
|
end
|
|
936
958
|
}
|
|
@@ -1172,6 +1194,9 @@ MU.log "ROUTES TO #{target_instance.name}", MU::WARN, details: resp
|
|
|
1172
1194
|
if e.message.match(/notFound: /)
|
|
1173
1195
|
MU.log "Failed to fetch cloud description for Google subnet #{@cloud_id}", MU::WARN, details: { "project" => @parent.habitat_id, "region" => @az, "name" => @cloud_id }
|
|
1174
1196
|
return nil
|
|
1197
|
+
elsif e.message.match(/Unknown region\. /)
|
|
1198
|
+
MU.log "Google subnet #{@cloud_id} seems like it should live in #{@az}, but that's not a valid region", MU::WARN, details: { "project" => @parent.habitat_id, "region" => @az, "name" => @cloud_id }
|
|
1199
|
+
return nil
|
|
1175
1200
|
else
|
|
1176
1201
|
raise e
|
|
1177
1202
|
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# clouds: AWS
|
|
2
|
+
---
|
|
3
|
+
appname: smoketest
|
|
4
|
+
jobs:
|
|
5
|
+
- name: event1
|
|
6
|
+
schedule:
|
|
7
|
+
minute: '0'
|
|
8
|
+
hour: '1'
|
|
9
|
+
day_of_month: '1'
|
|
10
|
+
month: "*"
|
|
11
|
+
day_of_week: "?"
|
|
12
|
+
year: "*"
|
|
13
|
+
targets:
|
|
14
|
+
- type: functions
|
|
15
|
+
name: python-function
|
|
16
|
+
- name: event2
|
|
17
|
+
disabled: true
|
|
18
|
+
schedule:
|
|
19
|
+
minute: '0'
|
|
20
|
+
hour: '2'
|
|
21
|
+
day_of_month: '1'
|
|
22
|
+
month: "*"
|
|
23
|
+
day_of_week: "?"
|
|
24
|
+
year: "*"
|
|
25
|
+
targets:
|
|
26
|
+
- type: functions
|
|
27
|
+
name: node-function
|
|
28
|
+
|
|
29
|
+
functions:
|
|
30
|
+
- name: python-function
|
|
31
|
+
handler: lambda_function.lambda_handler
|
|
32
|
+
memory: 128
|
|
33
|
+
runtime: python3.6
|
|
34
|
+
timeout: 300
|
|
35
|
+
code:
|
|
36
|
+
path: functions/python-function
|
|
37
|
+
environment_variable:
|
|
38
|
+
- key: foo
|
|
39
|
+
value: bar
|
|
40
|
+
- name: node-function
|
|
41
|
+
runtime: nodejs12.x
|
|
42
|
+
handler: lambda_function.lambda_handler
|
|
43
|
+
memory: 256
|
|
44
|
+
timeout: 60
|
|
45
|
+
code:
|
|
46
|
+
path: functions/node-function
|