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
|
@@ -41,8 +41,8 @@ module MU
|
|
|
41
41
|
# Called automatically by {MU::Deploy#createResources}
|
|
42
42
|
def create
|
|
43
43
|
if @config["zones"] == nil
|
|
44
|
-
@config["zones"] = MU::Cloud::AWS.listAZs(region: @
|
|
45
|
-
MU.log "Using zones from #{@
|
|
44
|
+
@config["zones"] = MU::Cloud::AWS.listAZs(region: @region)
|
|
45
|
+
MU.log "Using zones from #{@region}", MU::DEBUG, details: @config['zones']
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
lb_options = {
|
|
@@ -122,15 +122,15 @@ module MU
|
|
|
122
122
|
begin
|
|
123
123
|
if @config['classic']
|
|
124
124
|
MU.log "Creating Elastic Load Balancer #{@mu_name}", details: lb_options
|
|
125
|
-
lb = MU::Cloud::AWS.elb(region: @
|
|
125
|
+
lb = MU::Cloud::AWS.elb(region: @region, credentials: @credentials).create_load_balancer(lb_options)
|
|
126
126
|
else
|
|
127
127
|
MU.log "Creating Application Load Balancer #{@mu_name}", details: lb_options
|
|
128
|
-
lb = MU::Cloud::AWS.elb2(region: @
|
|
128
|
+
lb = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).create_load_balancer(lb_options).load_balancers.first
|
|
129
129
|
begin
|
|
130
130
|
if lb.state.code != "active"
|
|
131
131
|
MU.log "Waiting for ALB #{@mu_name} to enter 'active' state", MU::NOTICE
|
|
132
132
|
sleep 20
|
|
133
|
-
lb = MU::Cloud::AWS.elb2(region: @
|
|
133
|
+
lb = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).describe_load_balancers(
|
|
134
134
|
names: [@mu_name]
|
|
135
135
|
).load_balancers.first
|
|
136
136
|
end
|
|
@@ -170,7 +170,7 @@ module MU
|
|
|
170
170
|
if zones_to_try.size < @config["zones"].size
|
|
171
171
|
zones_to_try.each { |zone|
|
|
172
172
|
begin
|
|
173
|
-
MU::Cloud::AWS.elb(region: @
|
|
173
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).enable_availability_zones_for_load_balancer(
|
|
174
174
|
load_balancer_name: @mu_name,
|
|
175
175
|
availability_zones: [zone]
|
|
176
176
|
)
|
|
@@ -183,7 +183,7 @@ module MU
|
|
|
183
183
|
@targetgroups = {}
|
|
184
184
|
if !@config['healthcheck'].nil? and @config['classic']
|
|
185
185
|
MU.log "Configuring custom health check for ELB #{@mu_name}", details: @config['healthcheck']
|
|
186
|
-
MU::Cloud::AWS.elb(region: @
|
|
186
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).configure_health_check(
|
|
187
187
|
load_balancer_name: @mu_name,
|
|
188
188
|
health_check: {
|
|
189
189
|
target: @config['healthcheck']['target'],
|
|
@@ -229,9 +229,9 @@ module MU
|
|
|
229
229
|
end
|
|
230
230
|
end
|
|
231
231
|
|
|
232
|
-
tg_resp = MU::Cloud::AWS.elb2(region: @
|
|
232
|
+
tg_resp = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).create_target_group(tg_descriptor)
|
|
233
233
|
@targetgroups[tg['name']] = tg_resp.target_groups.first
|
|
234
|
-
MU::Cloud::AWS.elb2(region: @
|
|
234
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).add_tags(
|
|
235
235
|
resource_arns: [tg_resp.target_groups.first.target_group_arn],
|
|
236
236
|
tags: lb_options[:tags]
|
|
237
237
|
)
|
|
@@ -285,7 +285,7 @@ module MU
|
|
|
285
285
|
"ELBSecurityPolicy-TLS-1-2-2017-01"
|
|
286
286
|
end
|
|
287
287
|
end
|
|
288
|
-
listen_resp = MU::Cloud::AWS.elb2(region: @
|
|
288
|
+
listen_resp = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).create_listener(listen_descriptor).listeners.first
|
|
289
289
|
if !l['rules'].nil?
|
|
290
290
|
l['rules'].each { |rule|
|
|
291
291
|
rule_descriptor = {
|
|
@@ -307,14 +307,14 @@ module MU
|
|
|
307
307
|
}
|
|
308
308
|
end
|
|
309
309
|
}
|
|
310
|
-
MU::Cloud::AWS.elb2(region: @
|
|
310
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).create_rule(rule_descriptor)
|
|
311
311
|
}
|
|
312
312
|
end
|
|
313
313
|
}
|
|
314
314
|
else
|
|
315
315
|
@config["listeners"].each { |l|
|
|
316
316
|
if l['ssl_certificate_id']
|
|
317
|
-
MU::Cloud::AWS.elb(region: @
|
|
317
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).set_load_balancer_policies_of_listener(
|
|
318
318
|
load_balancer_name: @cloud_id,
|
|
319
319
|
load_balancer_port: l['lb_port'],
|
|
320
320
|
policy_names: [
|
|
@@ -347,7 +347,7 @@ module MU
|
|
|
347
347
|
if @config['cross_zone_unstickiness']
|
|
348
348
|
MU.log "Enabling cross-zone un-stickiness on #{lb.dns_name}"
|
|
349
349
|
if @config['classic']
|
|
350
|
-
MU::Cloud::AWS.elb(region: @
|
|
350
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).modify_load_balancer_attributes(
|
|
351
351
|
load_balancer_name: @mu_name,
|
|
352
352
|
load_balancer_attributes: {
|
|
353
353
|
cross_zone_load_balancing: {
|
|
@@ -357,7 +357,7 @@ module MU
|
|
|
357
357
|
)
|
|
358
358
|
else
|
|
359
359
|
@targetgroups.values.each { |tg|
|
|
360
|
-
MU::Cloud::AWS.elb2(region: @
|
|
360
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).modify_target_group_attributes(
|
|
361
361
|
target_group_arn: tg.target_group_arn,
|
|
362
362
|
attributes: [
|
|
363
363
|
{
|
|
@@ -373,7 +373,7 @@ module MU
|
|
|
373
373
|
if !@config['idle_timeout'].nil?
|
|
374
374
|
MU.log "Setting idle timeout to #{@config['idle_timeout']} #{lb.dns_name}"
|
|
375
375
|
if @config['classic']
|
|
376
|
-
MU::Cloud::AWS.elb(region: @
|
|
376
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).modify_load_balancer_attributes(
|
|
377
377
|
load_balancer_name: @mu_name,
|
|
378
378
|
load_balancer_attributes: {
|
|
379
379
|
connection_settings: {
|
|
@@ -382,7 +382,7 @@ module MU
|
|
|
382
382
|
}
|
|
383
383
|
)
|
|
384
384
|
else
|
|
385
|
-
MU::Cloud::AWS.elb2(region: @
|
|
385
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).modify_load_balancer_attributes(
|
|
386
386
|
load_balancer_arn: lb.load_balancer_arn,
|
|
387
387
|
attributes: [
|
|
388
388
|
{
|
|
@@ -398,7 +398,7 @@ module MU
|
|
|
398
398
|
if @config['classic']
|
|
399
399
|
if @config['connection_draining_timeout'] >= 0
|
|
400
400
|
MU.log "Setting connection draining timeout to #{@config['connection_draining_timeout']} on #{lb.dns_name}"
|
|
401
|
-
MU::Cloud::AWS.elb(region: @
|
|
401
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).modify_load_balancer_attributes(
|
|
402
402
|
load_balancer_name: @mu_name,
|
|
403
403
|
load_balancer_attributes: {
|
|
404
404
|
connection_draining: {
|
|
@@ -409,7 +409,7 @@ module MU
|
|
|
409
409
|
)
|
|
410
410
|
else
|
|
411
411
|
MU.log "Disabling connection draining on #{lb.dns_name}"
|
|
412
|
-
MU::Cloud::AWS.elb(region: @
|
|
412
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).modify_load_balancer_attributes(
|
|
413
413
|
load_balancer_name: @mu_name,
|
|
414
414
|
load_balancer_attributes: {
|
|
415
415
|
connection_draining: {
|
|
@@ -427,7 +427,7 @@ module MU
|
|
|
427
427
|
MU.log "Disabling connection draining on #{lb.dns_name}"
|
|
428
428
|
end
|
|
429
429
|
@targetgroups.values.each { |tg|
|
|
430
|
-
MU::Cloud::AWS.elb2(region: @
|
|
430
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).modify_target_group_attributes(
|
|
431
431
|
target_group_arn: tg.target_group_arn,
|
|
432
432
|
attributes: [
|
|
433
433
|
{
|
|
@@ -443,7 +443,7 @@ module MU
|
|
|
443
443
|
if !@config['access_log'].nil?
|
|
444
444
|
MU.log "Setting access log params for #{lb.dns_name}", details: @config['access_log']
|
|
445
445
|
if @config['classic']
|
|
446
|
-
MU::Cloud::AWS.elb(region: @
|
|
446
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).modify_load_balancer_attributes(
|
|
447
447
|
load_balancer_name: @mu_name,
|
|
448
448
|
load_balancer_attributes: {
|
|
449
449
|
access_log: {
|
|
@@ -455,7 +455,7 @@ module MU
|
|
|
455
455
|
}
|
|
456
456
|
)
|
|
457
457
|
else
|
|
458
|
-
MU::Cloud::AWS.elb2(region: @
|
|
458
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).modify_load_balancer_attributes(
|
|
459
459
|
load_balancer_arn: lb.load_balancer_arn,
|
|
460
460
|
attributes: [
|
|
461
461
|
{
|
|
@@ -485,7 +485,7 @@ module MU
|
|
|
485
485
|
if !@config['lb_cookie_stickiness_policy']['timeout'].nil?
|
|
486
486
|
cookie_policy[:cookie_expiration_period] = @config['lb_cookie_stickiness_policy']['timeout']
|
|
487
487
|
end
|
|
488
|
-
MU::Cloud::AWS.elb(region: @
|
|
488
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).create_lb_cookie_stickiness_policy(cookie_policy)
|
|
489
489
|
lb_policy_names = Array.new
|
|
490
490
|
lb_policy_names << @config['lb_cookie_stickiness_policy']['name']
|
|
491
491
|
listener_policy = {
|
|
@@ -495,12 +495,12 @@ module MU
|
|
|
495
495
|
lb_options[:listeners].each do |listener|
|
|
496
496
|
if listener[:protocol].upcase == 'HTTP' or listener[:protocol].upcase == 'HTTPS'
|
|
497
497
|
listener_policy[:load_balancer_port] = listener[:load_balancer_port]
|
|
498
|
-
MU::Cloud::AWS.elb(region: @
|
|
498
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).set_load_balancer_policies_of_listener(listener_policy)
|
|
499
499
|
end
|
|
500
500
|
end
|
|
501
501
|
else
|
|
502
502
|
@targetgroups.values.each { |tg|
|
|
503
|
-
MU::Cloud::AWS.elb2(region: @
|
|
503
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).modify_target_group_attributes(
|
|
504
504
|
target_group_arn: tg.target_group_arn,
|
|
505
505
|
attributes: [
|
|
506
506
|
{
|
|
@@ -529,7 +529,7 @@ module MU
|
|
|
529
529
|
policy_name: @config['app_cookie_stickiness_policy']['name'],
|
|
530
530
|
cookie_name: @config['app_cookie_stickiness_policy']['cookie']
|
|
531
531
|
}
|
|
532
|
-
MU::Cloud::AWS.elb(region: @
|
|
532
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).create_app_cookie_stickiness_policy(cookie_policy)
|
|
533
533
|
lb_policy_names = Array.new
|
|
534
534
|
lb_policy_names << @config['app_cookie_stickiness_policy']['name']
|
|
535
535
|
listener_policy = {
|
|
@@ -539,7 +539,7 @@ module MU
|
|
|
539
539
|
lb_options[:listeners].each do |listener|
|
|
540
540
|
if listener[:protocol].upcase == 'HTTP' or listener[:protocol].upcase == 'HTTPS'
|
|
541
541
|
listener_policy[:load_balancer_port] = listener[:load_balancer_port]
|
|
542
|
-
MU::Cloud::AWS.elb(region: @
|
|
542
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).set_load_balancer_policies_of_listener(listener_policy)
|
|
543
543
|
end
|
|
544
544
|
end
|
|
545
545
|
else
|
|
@@ -573,7 +573,7 @@ module MU
|
|
|
573
573
|
# @return [String]
|
|
574
574
|
def arn
|
|
575
575
|
if @config['classic']
|
|
576
|
-
"arn:"+(MU::Cloud::AWS.isGovCloud?(@
|
|
576
|
+
"arn:"+(MU::Cloud::AWS.isGovCloud?(@region) ? "aws-us-gov" : "aws")+":elasticloadbalancing:"+@region+":"+MU::Cloud::AWS.credToAcct(@credentials)+":loadbalancer/"+@cloud_id
|
|
577
577
|
else
|
|
578
578
|
cloud_desc.load_balancer_arn
|
|
579
579
|
end
|
|
@@ -583,22 +583,44 @@ module MU
|
|
|
583
583
|
# Wrapper for cloud_desc method that deals with elb vs. elb2 resources.
|
|
584
584
|
def cloud_desc(use_cache: true)
|
|
585
585
|
return @cloud_desc_cache if @cloud_desc_cache and use_cache
|
|
586
|
+
return nil if !@cloud_id
|
|
586
587
|
if @config['classic']
|
|
587
|
-
@cloud_desc_cache = MU::Cloud::AWS.elb(region: @
|
|
588
|
+
@cloud_desc_cache = MU::Cloud::AWS.elb(region: @region, credentials: @credentials).describe_load_balancers(
|
|
588
589
|
load_balancer_names: [@cloud_id]
|
|
589
590
|
).load_balancer_descriptions.first
|
|
590
591
|
return @cloud_desc_cache
|
|
591
592
|
else
|
|
592
|
-
@cloud_desc_cache = MU::Cloud::AWS.elb2(region: @
|
|
593
|
+
@cloud_desc_cache = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).describe_load_balancers(
|
|
593
594
|
names: [@cloud_id]
|
|
594
595
|
).load_balancers.first
|
|
595
|
-
if @targetgroups.nil?
|
|
596
|
-
@deploy.deployment['loadbalancers'].has_key?(@config['name']) and
|
|
597
|
-
@deploy.deployment['loadbalancers'][@config['name']].has_key?("targetgroups")
|
|
596
|
+
if @targetgroups.nil?
|
|
598
597
|
@targetgroups = {}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
598
|
+
if !@deploy.nil? and
|
|
599
|
+
@deploy.deployment['loadbalancers'] and
|
|
600
|
+
@deploy.deployment['loadbalancers'][@config['name']] and
|
|
601
|
+
@deploy.deployment['loadbalancers'][@config['name']]["targetgroups"]
|
|
602
|
+
@deploy.deployment['loadbalancers'][@config['name']]["targetgroups"].each_pair { |tg_name, tg_arn|
|
|
603
|
+
@targetgroups[tg_name] = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).describe_target_groups(target_group_arns: [tg_arn]).target_groups.first
|
|
604
|
+
}
|
|
605
|
+
else
|
|
606
|
+
pp @config['targetgroups']
|
|
607
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).describe_target_groups(load_balancer_arn: @cloud_desc_cache.load_balancer_arn).target_groups.each { |tg|
|
|
608
|
+
tg_name = tg.target_group_name
|
|
609
|
+
if @config['targetgroups']
|
|
610
|
+
@config['targetgroups'].each { |tg_cfg|
|
|
611
|
+
if tg_name = @deploy.getResourceName(tg_cfg["name"], max_length: 32, disallowed_chars: /[^A-Za-z0-9-]/)
|
|
612
|
+
tg_name = tg_cfg['name']
|
|
613
|
+
break
|
|
614
|
+
end
|
|
615
|
+
}
|
|
616
|
+
end
|
|
617
|
+
@targetgroups[tg_name] = tg
|
|
618
|
+
}
|
|
619
|
+
# @config['targetgroups'].each { |tg|
|
|
620
|
+
# tg_name = @deploy.getResourceName(tg["name"], max_length: 32, disallowed_chars: /[^A-Za-z0-9-]/)
|
|
621
|
+
# @targetgroups[tg_name] = MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).describe_target_groups(target_group_arns: [tg_arn]).target_groups.first
|
|
622
|
+
# }
|
|
623
|
+
end
|
|
602
624
|
end
|
|
603
625
|
|
|
604
626
|
return @cloud_desc_cache
|
|
@@ -627,7 +649,7 @@ module MU
|
|
|
627
649
|
def registerNode(instance_id, targetgroups: nil)
|
|
628
650
|
if @config['classic'] or !@config.has_key?("classic")
|
|
629
651
|
MU.log "Registering #{instance_id} to ELB #{@cloud_id}"
|
|
630
|
-
MU::Cloud::AWS.elb(region: @
|
|
652
|
+
MU::Cloud::AWS.elb(region: @region, credentials: @credentials).register_instances_with_load_balancer(
|
|
631
653
|
load_balancer_name: @cloud_id,
|
|
632
654
|
instances: [
|
|
633
655
|
{instance_id: instance_id}
|
|
@@ -643,7 +665,7 @@ module MU
|
|
|
643
665
|
end
|
|
644
666
|
targetgroups.each { |tg|
|
|
645
667
|
MU.log "Registering #{instance_id} to Target Group #{tg}"
|
|
646
|
-
MU::Cloud::AWS.elb2(region: @
|
|
668
|
+
MU::Cloud::AWS.elb2(region: @region, credentials: @credentials).register_targets(
|
|
647
669
|
target_group_arn: @targetgroups[tg].target_group_arn,
|
|
648
670
|
targets: [
|
|
649
671
|
{id: instance_id}
|
|
@@ -671,8 +693,8 @@ module MU
|
|
|
671
693
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
672
694
|
# @param region [String]: The cloud provider region
|
|
673
695
|
# @return [void]
|
|
674
|
-
def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
675
|
-
if (
|
|
696
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
697
|
+
if (deploy_id.nil? or deploy_id.empty?) and (!flags or !flags["vpc_id"])
|
|
676
698
|
raise MuError, "Can't touch ELBs without MU-ID or vpc_id flag"
|
|
677
699
|
end
|
|
678
700
|
|
|
@@ -682,7 +704,7 @@ module MU
|
|
|
682
704
|
# @param region [String]: The cloud provider region
|
|
683
705
|
# @param ignoremaster [Boolean]: Whether to ignore the MU-MASTER-IP tag
|
|
684
706
|
# @param classic [Boolean]: Whether to look for a classic ELB instead of an ALB (ELB2)
|
|
685
|
-
def self.checkForTagMatch(arn, region, ignoremaster, credentials, classic = false)
|
|
707
|
+
def self.checkForTagMatch(arn, region, ignoremaster, credentials, classic = false, deploy_id: MU.deploy_id)
|
|
686
708
|
tags = []
|
|
687
709
|
if classic
|
|
688
710
|
tags = MU::Cloud::AWS.elb(credentials: credentials, region: region).describe_tags(
|
|
@@ -699,7 +721,7 @@ module MU
|
|
|
699
721
|
if !tags.nil?
|
|
700
722
|
tags.each { |tag|
|
|
701
723
|
saw_tags << tag.key
|
|
702
|
-
muid_match = true if tag.key == "MU-ID" and tag.value ==
|
|
724
|
+
muid_match = true if tag.key == "MU-ID" and tag.value == deploy_id
|
|
703
725
|
mumaster_match = true if tag.key == "MU-MASTER-IP" and tag.value == MU.mu_public_ip
|
|
704
726
|
}
|
|
705
727
|
end
|
|
@@ -725,9 +747,9 @@ module MU
|
|
|
725
747
|
matched = true if lb.vpc_id == flags['vpc_id']
|
|
726
748
|
else
|
|
727
749
|
if classic
|
|
728
|
-
matched = self.checkForTagMatch(lb.load_balancer_name, region, ignoremaster, credentials, classic)
|
|
750
|
+
matched = self.checkForTagMatch(lb.load_balancer_name, region, ignoremaster, credentials, classic, deploy_id: deploy_id)
|
|
729
751
|
else
|
|
730
|
-
matched = self.checkForTagMatch(lb.load_balancer_arn, region, ignoremaster, credentials, classic)
|
|
752
|
+
matched = self.checkForTagMatch(lb.load_balancer_arn, region, ignoremaster, credentials, classic, deploy_id: deploy_id)
|
|
731
753
|
end
|
|
732
754
|
end
|
|
733
755
|
if matched
|
|
@@ -773,7 +795,7 @@ module MU
|
|
|
773
795
|
|
|
774
796
|
|
|
775
797
|
tgs.each { |tg|
|
|
776
|
-
if self.checkForTagMatch(tg.target_group_arn, region, ignoremaster, credentials)
|
|
798
|
+
if self.checkForTagMatch(tg.target_group_arn, region, ignoremaster, credentials, deploy_id: deploy_id)
|
|
777
799
|
MU.log "Removing Load Balancer Target Group #{tg.target_group_name}"
|
|
778
800
|
retries = 0
|
|
779
801
|
begin
|
|
@@ -837,7 +859,7 @@ module MU
|
|
|
837
859
|
(!listener["ssl_certificate_id"].nil? and !listener["ssl_certificate_id"].empty?)
|
|
838
860
|
if lb['cloud'] != "CloudFormation" # XXX or maybe do this anyway?
|
|
839
861
|
begin
|
|
840
|
-
listener["ssl_certificate_id"] = MU::Cloud::AWS.findSSLCertificate(name: listener["ssl_certificate_name"].to_s, id: listener["ssl_certificate_id"].to_s, region: lb['region'])
|
|
862
|
+
listener["ssl_certificate_id"] = MU::Cloud::AWS.findSSLCertificate(name: listener["ssl_certificate_name"].to_s, id: listener["ssl_certificate_id"].to_s, region: lb['region']).first
|
|
841
863
|
rescue MuError
|
|
842
864
|
ok = false
|
|
843
865
|
next
|
|
@@ -30,13 +30,13 @@ module MU
|
|
|
30
30
|
@config["log_group_name"] = @mu_name
|
|
31
31
|
@config["log_stream_name"] =
|
|
32
32
|
if @config["enable_cloudtrail_logging"]
|
|
33
|
-
"#{MU::Cloud::AWS.credToAcct(@
|
|
33
|
+
"#{MU::Cloud::AWS.credToAcct(@credentials)}_CloudTrail_#{@region}"
|
|
34
34
|
else
|
|
35
35
|
@mu_name
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
MU.log "Creating log group #{@mu_name}"
|
|
39
|
-
MU::Cloud::AWS.cloudwatchlogs(region: @
|
|
39
|
+
MU::Cloud::AWS.cloudwatchlogs(region: @region, credentials: @credentials).create_log_group(
|
|
40
40
|
log_group_name: @config["log_group_name"],
|
|
41
41
|
tags: @tags
|
|
42
42
|
)
|
|
@@ -45,7 +45,7 @@ module MU
|
|
|
45
45
|
retries = 0
|
|
46
46
|
max_retries = 5
|
|
47
47
|
begin
|
|
48
|
-
resp = MU::Cloud::AWS::Log.getLogGroupByName(@config["log_group_name"], region: @
|
|
48
|
+
resp = MU::Cloud::AWS::Log.getLogGroupByName(@config["log_group_name"], region: @region)
|
|
49
49
|
if resp.nil?
|
|
50
50
|
if retries >= max_retries
|
|
51
51
|
raise MuError, "Cloudwatch Logs group #{@config["log_group_name"]} creation hasn't succeeded after #{(retries*max_retries).to_s}s"
|
|
@@ -56,19 +56,19 @@ module MU
|
|
|
56
56
|
end
|
|
57
57
|
end while resp.nil?
|
|
58
58
|
|
|
59
|
-
MU::Cloud::AWS.cloudwatchlogs(region: @
|
|
59
|
+
MU::Cloud::AWS.cloudwatchlogs(region: @region, credentials: @credentials).create_log_stream(
|
|
60
60
|
log_group_name: @config["log_group_name"],
|
|
61
61
|
log_stream_name: @config["log_stream_name"]
|
|
62
62
|
)
|
|
63
63
|
|
|
64
|
-
MU::Cloud::AWS.cloudwatchlogs(region: @
|
|
64
|
+
MU::Cloud::AWS.cloudwatchlogs(region: @region, credentials: @credentials).put_retention_policy(
|
|
65
65
|
log_group_name: @config["log_group_name"],
|
|
66
66
|
retention_in_days: @config["retention_period"]
|
|
67
67
|
)
|
|
68
68
|
|
|
69
69
|
if @config["filters"] && !@config["filters"].empty?
|
|
70
70
|
@config["filters"].each{ |filter|
|
|
71
|
-
MU::Cloud::AWS.cloudwatchlogs(region: @
|
|
71
|
+
MU::Cloud::AWS.cloudwatchlogs(region: @region, credentials: @credentials).put_metric_filter(
|
|
72
72
|
log_group_name: @config["log_group_name"],
|
|
73
73
|
filter_name: filter["name"],
|
|
74
74
|
filter_pattern: filter["search_pattern"],
|
|
@@ -82,8 +82,8 @@ module MU
|
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
if @config["enable_cloudtrail_logging"]
|
|
85
|
-
trail_resp = MU::Cloud::AWS.cloudtrail(region: @
|
|
86
|
-
raise MuError, "Can't find a cloudtrail in #{MU::Cloud::AWS.credToAcct(@
|
|
85
|
+
trail_resp = MU::Cloud::AWS.cloudtrail(region: @region, credentials: @credentials).describe_trails.trail_list.first
|
|
86
|
+
raise MuError, "Can't find a cloudtrail in #{MU::Cloud::AWS.credToAcct(@credentials)}/#{@region}. Please create cloudtrail before enabling logging on it" unless trail_resp
|
|
87
87
|
|
|
88
88
|
iam_policy = '{
|
|
89
89
|
"Version": "2012-10-17",
|
|
@@ -96,7 +96,7 @@ module MU
|
|
|
96
96
|
"logs:PutLogEventsBatch",
|
|
97
97
|
"logs:PutLogEvents"
|
|
98
98
|
],
|
|
99
|
-
"Resource": "arn:'+(MU::Cloud::AWS.isGovCloud?(@
|
|
99
|
+
"Resource": "arn:'+(MU::Cloud::AWS.isGovCloud?(@region) ? "aws-us-gov" : "aws")+':logs:'+@region+':'+MU::Cloud::AWS.credToAcct(@credentials)+':log-group:'+@config["log_group_name"]+':log-stream:'+@config["log_stream_name"]+'*"
|
|
100
100
|
}
|
|
101
101
|
]
|
|
102
102
|
}'
|
|
@@ -132,11 +132,11 @@ module MU
|
|
|
132
132
|
policy_document: iam_policy
|
|
133
133
|
)
|
|
134
134
|
|
|
135
|
-
log_group_resp = MU::Cloud::AWS::Log.getLogGroupByName(@config["log_group_name"], region: @
|
|
135
|
+
log_group_resp = MU::Cloud::AWS::Log.getLogGroupByName(@config["log_group_name"], region: @region)
|
|
136
136
|
|
|
137
137
|
retries = 0
|
|
138
138
|
begin
|
|
139
|
-
MU::Cloud::AWS.cloudtrail(region: @
|
|
139
|
+
MU::Cloud::AWS.cloudtrail(region: @region, credentials: @credentials).update_trail(
|
|
140
140
|
name: trail_resp.name,
|
|
141
141
|
cloud_watch_logs_log_group_arn: log_group_resp.arn,
|
|
142
142
|
cloud_watch_logs_role_arn: iam_resp.role.arn
|
|
@@ -202,14 +202,14 @@ module MU
|
|
|
202
202
|
# @param ignoremaster [Boolean]: If true, will remove resources not flagged as originating from this Mu server
|
|
203
203
|
# @param region [String]: The cloud provider region
|
|
204
204
|
# @return [void]
|
|
205
|
-
def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
205
|
+
def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
206
206
|
MU.log "AWS::Log.cleanup: need to support flags['known']", MU::DEBUG, details: flags
|
|
207
207
|
MU.log "Placeholder: AWS Log artifacts do not support tags, so ignoremaster cleanup flag has no effect", MU::DEBUG, details: ignoremaster
|
|
208
208
|
|
|
209
209
|
log_groups = self.find(credentials: credentials, region: region).values
|
|
210
210
|
if !log_groups.empty?
|
|
211
211
|
log_groups.each{ |lg|
|
|
212
|
-
if lg.log_group_name.match(
|
|
212
|
+
if lg.log_group_name.match(deploy_id)
|
|
213
213
|
log_streams = MU::Cloud::AWS.cloudwatchlogs(credentials: credentials, region: region).describe_log_streams(log_group_name: lg.log_group_name).log_streams
|
|
214
214
|
if !log_streams.empty?
|
|
215
215
|
log_streams.each{ |ls|
|
|
@@ -232,7 +232,7 @@ module MU
|
|
|
232
232
|
|
|
233
233
|
# unless noop
|
|
234
234
|
# MU::Cloud::AWS.iam(credentials: credentials).list_roles.roles.each{ |role|
|
|
235
|
-
# match_string = "#{
|
|
235
|
+
# match_string = "#{deploy_id}.*CloudTrail"
|
|
236
236
|
# Maybe we should have a more generic way to delete IAM profiles and policies. The call itself should be moved from MU::Cloud.resourceClass("AWS", "Server").
|
|
237
237
|
# MU::Cloud.resourceClass("AWS", "Server").removeIAMProfile(role.role_name) if role.role_name.match(match_string)
|
|
238
238
|
# }
|
|
@@ -270,9 +270,9 @@ module MU
|
|
|
270
270
|
def toKitten(**_args)
|
|
271
271
|
bok = {
|
|
272
272
|
"cloud" => "AWS",
|
|
273
|
-
"credentials" => @
|
|
273
|
+
"credentials" => @credentials,
|
|
274
274
|
"cloud_id" => @cloud_id,
|
|
275
|
-
"region" => @
|
|
275
|
+
"region" => @region
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
if !cloud_desc
|
|
@@ -283,7 +283,7 @@ module MU
|
|
|
283
283
|
bok['name'] = cloud_desc.log_group_name.sub(/.*?\/([^\/]+)$/, '\1')
|
|
284
284
|
|
|
285
285
|
if cloud_desc.metric_filter_count > 0
|
|
286
|
-
resp = MU::Cloud::AWS.cloudwatchlogs(region: @
|
|
286
|
+
resp = MU::Cloud::AWS.cloudwatchlogs(region: @region, credentials: @credentials).describe_metric_filters(
|
|
287
287
|
log_group_name: @cloud_id
|
|
288
288
|
)
|
|
289
289
|
resp.metric_filters.each { |filter|
|