cloud-mu 3.1.3 → 3.1.4
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 +10 -2
- data/bin/mu-adopt +5 -1
- data/bin/mu-load-config.rb +2 -3
- data/bin/mu-run-tests +112 -27
- data/cloud-mu.gemspec +20 -20
- data/cookbooks/mu-tools/libraries/helper.rb +2 -1
- data/cookbooks/mu-tools/libraries/monkey.rb +35 -0
- data/cookbooks/mu-tools/recipes/google_api.rb +2 -2
- data/cookbooks/mu-tools/resources/disk.rb +1 -1
- data/extras/image-generators/Google/centos6.yaml +1 -0
- data/extras/image-generators/Google/centos7.yaml +1 -1
- data/modules/mommacat.ru +5 -15
- data/modules/mu.rb +10 -14
- data/modules/mu/adoption.rb +20 -14
- data/modules/mu/cleanup.rb +13 -9
- data/modules/mu/cloud.rb +26 -26
- data/modules/mu/clouds/aws.rb +100 -59
- data/modules/mu/clouds/aws/alarm.rb +4 -2
- data/modules/mu/clouds/aws/bucket.rb +25 -21
- data/modules/mu/clouds/aws/cache_cluster.rb +25 -23
- data/modules/mu/clouds/aws/collection.rb +21 -20
- data/modules/mu/clouds/aws/container_cluster.rb +47 -26
- data/modules/mu/clouds/aws/database.rb +57 -68
- data/modules/mu/clouds/aws/dnszone.rb +14 -14
- data/modules/mu/clouds/aws/endpoint.rb +20 -16
- data/modules/mu/clouds/aws/firewall_rule.rb +19 -16
- data/modules/mu/clouds/aws/folder.rb +7 -7
- data/modules/mu/clouds/aws/function.rb +15 -12
- data/modules/mu/clouds/aws/group.rb +14 -10
- data/modules/mu/clouds/aws/habitat.rb +16 -13
- data/modules/mu/clouds/aws/loadbalancer.rb +16 -15
- data/modules/mu/clouds/aws/log.rb +13 -10
- data/modules/mu/clouds/aws/msg_queue.rb +15 -8
- data/modules/mu/clouds/aws/nosqldb.rb +18 -11
- data/modules/mu/clouds/aws/notifier.rb +11 -6
- data/modules/mu/clouds/aws/role.rb +87 -70
- data/modules/mu/clouds/aws/search_domain.rb +30 -19
- data/modules/mu/clouds/aws/server.rb +102 -72
- data/modules/mu/clouds/aws/server_pool.rb +47 -28
- data/modules/mu/clouds/aws/storage_pool.rb +5 -6
- data/modules/mu/clouds/aws/user.rb +13 -10
- data/modules/mu/clouds/aws/vpc.rb +135 -121
- data/modules/mu/clouds/azure.rb +16 -9
- data/modules/mu/clouds/azure/container_cluster.rb +2 -3
- data/modules/mu/clouds/azure/firewall_rule.rb +10 -10
- data/modules/mu/clouds/azure/habitat.rb +8 -6
- data/modules/mu/clouds/azure/loadbalancer.rb +5 -5
- data/modules/mu/clouds/azure/role.rb +8 -10
- data/modules/mu/clouds/azure/server.rb +65 -25
- data/modules/mu/clouds/azure/user.rb +5 -7
- data/modules/mu/clouds/azure/vpc.rb +12 -15
- data/modules/mu/clouds/cloudformation.rb +8 -7
- data/modules/mu/clouds/cloudformation/vpc.rb +2 -4
- data/modules/mu/clouds/google.rb +39 -24
- data/modules/mu/clouds/google/bucket.rb +9 -11
- data/modules/mu/clouds/google/container_cluster.rb +27 -42
- data/modules/mu/clouds/google/database.rb +6 -9
- data/modules/mu/clouds/google/firewall_rule.rb +11 -10
- data/modules/mu/clouds/google/folder.rb +16 -9
- data/modules/mu/clouds/google/function.rb +127 -161
- data/modules/mu/clouds/google/group.rb +21 -18
- data/modules/mu/clouds/google/habitat.rb +18 -15
- data/modules/mu/clouds/google/loadbalancer.rb +14 -16
- data/modules/mu/clouds/google/role.rb +48 -31
- data/modules/mu/clouds/google/server.rb +105 -105
- data/modules/mu/clouds/google/server_pool.rb +12 -31
- data/modules/mu/clouds/google/user.rb +67 -13
- data/modules/mu/clouds/google/vpc.rb +58 -65
- data/modules/mu/config.rb +89 -1738
- data/modules/mu/config/bucket.rb +3 -3
- data/modules/mu/config/collection.rb +3 -3
- data/modules/mu/config/container_cluster.rb +2 -2
- data/modules/mu/config/dnszone.rb +5 -5
- data/modules/mu/config/doc_helpers.rb +517 -0
- data/modules/mu/config/endpoint.rb +3 -3
- data/modules/mu/config/firewall_rule.rb +118 -3
- data/modules/mu/config/folder.rb +3 -3
- data/modules/mu/config/function.rb +2 -2
- data/modules/mu/config/group.rb +3 -3
- data/modules/mu/config/habitat.rb +3 -3
- data/modules/mu/config/loadbalancer.rb +3 -3
- data/modules/mu/config/log.rb +3 -3
- data/modules/mu/config/msg_queue.rb +3 -3
- data/modules/mu/config/nosqldb.rb +3 -3
- data/modules/mu/config/notifier.rb +2 -2
- data/modules/mu/config/ref.rb +333 -0
- data/modules/mu/config/role.rb +3 -3
- data/modules/mu/config/schema_helpers.rb +508 -0
- data/modules/mu/config/search_domain.rb +3 -3
- data/modules/mu/config/server.rb +86 -58
- data/modules/mu/config/server_pool.rb +2 -2
- data/modules/mu/config/tail.rb +189 -0
- data/modules/mu/config/user.rb +3 -3
- data/modules/mu/config/vpc.rb +44 -4
- data/modules/mu/defaults/Google.yaml +2 -2
- data/modules/mu/deploy.rb +13 -10
- data/modules/mu/groomer.rb +1 -1
- data/modules/mu/groomers/ansible.rb +69 -24
- data/modules/mu/groomers/chef.rb +52 -44
- data/modules/mu/logger.rb +17 -14
- data/modules/mu/master.rb +317 -2
- data/modules/mu/master/chef.rb +3 -4
- data/modules/mu/master/ldap.rb +3 -3
- data/modules/mu/master/ssl.rb +12 -2
- data/modules/mu/mommacat.rb +85 -1766
- data/modules/mu/mommacat/daemon.rb +394 -0
- data/modules/mu/mommacat/naming.rb +366 -0
- data/modules/mu/mommacat/storage.rb +689 -0
- data/modules/tests/bucket.yml +4 -0
- data/modules/tests/{win2k12.yaml → needwork/win2k12.yaml} +0 -0
- data/modules/tests/regrooms/aws-iam.yaml +201 -0
- data/modules/tests/regrooms/bucket.yml +19 -0
- metadata +112 -102
|
@@ -125,6 +125,8 @@ module MU
|
|
|
125
125
|
# @param region [String]: The cloud provider region
|
|
126
126
|
# @return [void]
|
|
127
127
|
def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
128
|
+
MU.log "AWS::Alarm.cleanup: need to support flags['known']", MU::DEBUG, details: flags
|
|
129
|
+
MU.log "Placeholder: AWS Alarm artifacts do not support tags, so ignoremaster cleanup flag has no effect", MU::DEBUG, details: ignoremaster
|
|
128
130
|
alarms = []
|
|
129
131
|
# We don't have a way to tag alarms, so we try to delete them by the deploy ID.
|
|
130
132
|
# This can miss alarms in some cases (eg. cache_cluster) so we might want to delete alarms from each API as well.
|
|
@@ -252,9 +254,9 @@ module MU
|
|
|
252
254
|
end
|
|
253
255
|
|
|
254
256
|
# Cloud-specific configuration properties.
|
|
255
|
-
# @param
|
|
257
|
+
# @param _config [MU::Config]: The calling MU::Config object
|
|
256
258
|
# @return [Array<Array,Hash>]: List of required fields, and json-schema Hash of cloud-specific configuration parameters for this resource
|
|
257
|
-
def self.schema(
|
|
259
|
+
def self.schema(_config)
|
|
258
260
|
toplevel_required = []
|
|
259
261
|
schema = {}
|
|
260
262
|
[toplevel_required, schema]
|
|
@@ -33,7 +33,7 @@ module MU
|
|
|
33
33
|
bucket_name = @deploy.getResourceName(@config["name"], max_length: 63).downcase
|
|
34
34
|
|
|
35
35
|
MU.log "Creating S3 bucket #{bucket_name}"
|
|
36
|
-
|
|
36
|
+
MU::Cloud::AWS.s3(credentials: @config['credentials'], region: @config['region']).create_bucket(
|
|
37
37
|
acl: @config['acl'],
|
|
38
38
|
bucket: bucket_name
|
|
39
39
|
)
|
|
@@ -90,7 +90,6 @@ module MU
|
|
|
90
90
|
tagBucket if !@config['scrub_mu_isms']
|
|
91
91
|
|
|
92
92
|
current = cloud_desc
|
|
93
|
-
|
|
94
93
|
if @config['policies']
|
|
95
94
|
@config['policies'].each { |pol|
|
|
96
95
|
pol['grant_to'] ||= [
|
|
@@ -98,9 +97,9 @@ module MU
|
|
|
98
97
|
]
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
policy_docs = MU::Cloud::AWS::Role.genPolicyDocument(@config['policies'], deploy_obj: @deploy)
|
|
100
|
+
policy_docs = MU::Cloud::AWS::Role.genPolicyDocument(@config['policies'], deploy_obj: @deploy, bucket_style: true)
|
|
102
101
|
policy_docs.each { |doc|
|
|
103
|
-
MU.log "Applying S3 bucket policy #{doc.keys.first} to bucket #{@cloud_id}", MU::NOTICE, details: doc.values.first
|
|
102
|
+
MU.log "Applying S3 bucket policy #{doc.keys.first} to bucket #{@cloud_id}", MU::NOTICE, details: JSON.pretty_generate(doc.values.first)
|
|
104
103
|
MU::Cloud::AWS.s3(credentials: @config['credentials'], region: @config['region']).put_bucket_policy(
|
|
105
104
|
bucket: @cloud_id,
|
|
106
105
|
policy: JSON.generate(doc.values.first)
|
|
@@ -177,10 +176,6 @@ module MU
|
|
|
177
176
|
end
|
|
178
177
|
|
|
179
178
|
begin
|
|
180
|
-
puts data
|
|
181
|
-
puts acl
|
|
182
|
-
puts bucket
|
|
183
|
-
puts path
|
|
184
179
|
MU.log "Writing #{path} to S3 bucket #{bucket}"
|
|
185
180
|
MU::Cloud::AWS.s3(region: region, credentials: credentials).put_object(
|
|
186
181
|
acl: acl,
|
|
@@ -213,6 +208,7 @@ puts path
|
|
|
213
208
|
# @param region [String]: The cloud provider region
|
|
214
209
|
# @return [void]
|
|
215
210
|
def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
|
|
211
|
+
MU.log "AWS::Bucket.cleanup: need to support flags['known']", MU::DEBUG, details: flags
|
|
216
212
|
|
|
217
213
|
resp = MU::Cloud::AWS.s3(credentials: credentials, region: region).list_buckets
|
|
218
214
|
if resp and resp.buckets
|
|
@@ -243,15 +239,21 @@ puts path
|
|
|
243
239
|
|
|
244
240
|
begin
|
|
245
241
|
tags = MU::Cloud::AWS.s3(credentials: credentials, region: region).get_bucket_tagging(bucket: bucket.name).tag_set
|
|
242
|
+
deploy_match = false
|
|
243
|
+
master_match = false
|
|
246
244
|
tags.each { |tag|
|
|
247
245
|
if tag.key == "MU-ID" and tag.value == MU.deploy_id
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
end
|
|
252
|
-
break
|
|
246
|
+
deploy_match = true
|
|
247
|
+
elsif tag.key == "MU-MASTER-IP" and tag.value == MU.mu_public_ip
|
|
248
|
+
master_match = true
|
|
253
249
|
end
|
|
254
250
|
}
|
|
251
|
+
if deploy_match and (ignoremaster or master_match)
|
|
252
|
+
MU.log "Deleting S3 Bucket #{bucket.name}"
|
|
253
|
+
if !noop
|
|
254
|
+
MU::Cloud::AWS.s3(credentials: credentials, region: region).delete_bucket(bucket: bucket.name)
|
|
255
|
+
end
|
|
256
|
+
end
|
|
255
257
|
rescue Aws::S3::Errors::NoSuchTagSet, Aws::S3::Errors::PermanentRedirect
|
|
256
258
|
next
|
|
257
259
|
end
|
|
@@ -302,9 +304,9 @@ puts path
|
|
|
302
304
|
end
|
|
303
305
|
|
|
304
306
|
# Cloud-specific configuration properties.
|
|
305
|
-
# @param
|
|
307
|
+
# @param _config [MU::Config]: The calling MU::Config object
|
|
306
308
|
# @return [Array<Array,Hash>]: List of required fields, and json-schema Hash of cloud-specific configuration parameters for this resource
|
|
307
|
-
def self.schema(
|
|
309
|
+
def self.schema(_config)
|
|
308
310
|
toplevel_required = []
|
|
309
311
|
schema = {
|
|
310
312
|
"policies" => MU::Cloud::AWS::Role.condition_schema,
|
|
@@ -325,15 +327,15 @@ puts path
|
|
|
325
327
|
# Cloud-specific pre-processing of {MU::Config::BasketofKittens::bucket}, bare and unvalidated.
|
|
326
328
|
|
|
327
329
|
# @param bucket [Hash]: The resource to process and validate
|
|
328
|
-
# @param
|
|
330
|
+
# @param _configurator [MU::Config]: The overall deployment configurator of which this resource is a member
|
|
329
331
|
# @return [Boolean]: True if validation succeeded, False otherwise
|
|
330
|
-
def self.validateConfig(bucket,
|
|
332
|
+
def self.validateConfig(bucket, _configurator)
|
|
331
333
|
ok = true
|
|
332
334
|
|
|
333
335
|
if bucket['policies']
|
|
334
336
|
bucket['policies'].each { |pol|
|
|
335
337
|
if !pol['permissions'] or pol['permissions'].empty?
|
|
336
|
-
pol['permissions'] = ["s3:GetObject"]
|
|
338
|
+
pol['permissions'] = ["s3:GetObject", "s3:ListBucket"]
|
|
337
339
|
end
|
|
338
340
|
}
|
|
339
341
|
end
|
|
@@ -341,11 +343,13 @@ puts path
|
|
|
341
343
|
ok
|
|
342
344
|
end
|
|
343
345
|
|
|
344
|
-
private
|
|
345
|
-
|
|
346
346
|
# AWS doesn't really implement a useful describe_ method for S3 buckets;
|
|
347
347
|
# instead we run the million little individual API calls to construct
|
|
348
348
|
# an approximation for our uses
|
|
349
|
+
# @param bucket [String]:
|
|
350
|
+
# @param minimal [Boolean]:
|
|
351
|
+
# @param credentials [String]:
|
|
352
|
+
# @param region [String]:
|
|
349
353
|
def self.describe_bucket(bucket, minimal: false, credentials: nil, region: nil)
|
|
350
354
|
@@region_cache = {}
|
|
351
355
|
@@region_cache_semaphore = Mutex.new
|
|
@@ -372,7 +376,7 @@ puts path
|
|
|
372
376
|
}
|
|
373
377
|
end
|
|
374
378
|
|
|
375
|
-
rescue Aws::S3::Errors::NoSuchCORSConfiguration, Aws::S3::Errors::ServerSideEncryptionConfigurationNotFoundError, Aws::S3::Errors::NoSuchLifecycleConfiguration, Aws::S3::Errors::NoSuchBucketPolicy, Aws::S3::Errors::ReplicationConfigurationNotFoundError, Aws::S3::Errors::NoSuchTagSet, Aws::S3::Errors::NoSuchWebsiteConfiguration
|
|
379
|
+
rescue Aws::S3::Errors::NoSuchCORSConfiguration, Aws::S3::Errors::ServerSideEncryptionConfigurationNotFoundError, Aws::S3::Errors::NoSuchLifecycleConfiguration, Aws::S3::Errors::NoSuchBucketPolicy, Aws::S3::Errors::ReplicationConfigurationNotFoundError, Aws::S3::Errors::NoSuchTagSet, Aws::S3::Errors::NoSuchWebsiteConfiguration
|
|
376
380
|
desc[method] = nil
|
|
377
381
|
next
|
|
378
382
|
end
|
|
@@ -170,7 +170,7 @@ module MU
|
|
|
170
170
|
# config_struct[:preferred_cache_cluster_a_zs] = @config["preferred_cache_cluster_azs"]
|
|
171
171
|
|
|
172
172
|
MU.log "Creating cache replication group #{@config['identifier']}"
|
|
173
|
-
|
|
173
|
+
MU::Cloud::AWS.elasticache(region: @config['region'], credentials: @config['credentials']).create_replication_group(config_struct).replication_group
|
|
174
174
|
|
|
175
175
|
wait_start_time = Time.now
|
|
176
176
|
retries = 0
|
|
@@ -180,7 +180,7 @@ module MU
|
|
|
180
180
|
waiter.before_attempt do |attempts|
|
|
181
181
|
MU.log "Waiting for cache replication group #{@config['identifier']} to become available", MU::NOTICE if attempts % 5 == 0
|
|
182
182
|
end
|
|
183
|
-
waiter.before_wait do |
|
|
183
|
+
waiter.before_wait do |_attempts, r|
|
|
184
184
|
throw :success if r.replication_groups.first.status == "available"
|
|
185
185
|
throw :failure if Time.now - wait_start_time > 1800
|
|
186
186
|
end
|
|
@@ -228,7 +228,7 @@ module MU
|
|
|
228
228
|
|
|
229
229
|
MU.log "Creating cache cluster #{@config['identifier']}"
|
|
230
230
|
begin
|
|
231
|
-
|
|
231
|
+
MU::Cloud::AWS.elasticache(region: @config['region'], credentials: @config['credentials']).create_cache_cluster(config_struct).cache_cluster
|
|
232
232
|
rescue ::Aws::ElastiCache::Errors::InvalidParameterValue => e
|
|
233
233
|
if e.message.match(/security group (sg-[^\s]+)/)
|
|
234
234
|
bad_sg = Regexp.last_match[1]
|
|
@@ -248,7 +248,7 @@ module MU
|
|
|
248
248
|
waiter.before_attempt do |attempts|
|
|
249
249
|
MU.log "Waiting for cache cluster #{@config['identifier']} to become available", MU::NOTICE if attempts % 5 == 0
|
|
250
250
|
end
|
|
251
|
-
waiter.before_wait do |
|
|
251
|
+
waiter.before_wait do |_attempts, r|
|
|
252
252
|
throw :success if r.cache_clusters.first.cache_cluster_status == "available"
|
|
253
253
|
throw :failure if Time.now - wait_start_time > 1800
|
|
254
254
|
end
|
|
@@ -317,7 +317,7 @@ module MU
|
|
|
317
317
|
"vpc_id" => vpc_id,
|
|
318
318
|
"subnets" => mu_subnets
|
|
319
319
|
}
|
|
320
|
-
|
|
320
|
+
|
|
321
321
|
MU.log "Using default VPC for cache cluster #{@config['identifier']}"
|
|
322
322
|
end
|
|
323
323
|
end
|
|
@@ -327,7 +327,7 @@ module MU
|
|
|
327
327
|
else
|
|
328
328
|
MU.log "Creating subnet group #{@config["subnet_group_name"]} for cache cluster #{@config['identifier']}"
|
|
329
329
|
|
|
330
|
-
|
|
330
|
+
MU::Cloud::AWS.elasticache(region: @config['region'], credentials: @config['credentials']).create_cache_subnet_group(
|
|
331
331
|
cache_subnet_group_name: @config["subnet_group_name"],
|
|
332
332
|
cache_subnet_group_description: @config["subnet_group_name"],
|
|
333
333
|
subnet_ids: subnet_ids
|
|
@@ -340,8 +340,8 @@ module MU
|
|
|
340
340
|
if nat.is_a?(Struct) && nat.nat_gateway_id && nat.nat_gateway_id.start_with?("nat-")
|
|
341
341
|
MU.log "Using NAT Gateway, not modifying security groups"
|
|
342
342
|
else
|
|
343
|
-
|
|
344
|
-
@deploy.kittens['firewall_rules'].
|
|
343
|
+
_nat_name, _nat_conf, nat_deploydata = @nat.describe
|
|
344
|
+
@deploy.kittens['firewall_rules'].values.each { |acl|
|
|
345
345
|
# XXX if a user doesn't set up dependencies correctly, this can die horribly on a NAT that's still in mid-creation. Fix this... possibly in the config parser.
|
|
346
346
|
if acl.config["admin"]
|
|
347
347
|
acl.addRule([nat_deploydata["private_ip_address"]], proto: "tcp")
|
|
@@ -364,7 +364,7 @@ module MU
|
|
|
364
364
|
# Create a Cache Cluster parameter group.
|
|
365
365
|
def createParameterGroup
|
|
366
366
|
MU.log "Creating a cache cluster parameter group #{@config["parameter_group_name"]}"
|
|
367
|
-
|
|
367
|
+
MU::Cloud::AWS.elasticache(region: @config['region'], credentials: @config['credentials']).create_cache_parameter_group(
|
|
368
368
|
cache_parameter_group_name: @config["parameter_group_name"],
|
|
369
369
|
cache_parameter_group_family: @config["parameter_group_family"],
|
|
370
370
|
description: "Parameter group for #{@config["parameter_group_family"]}"
|
|
@@ -404,7 +404,7 @@ module MU
|
|
|
404
404
|
def self.getCacheClusterById(cc_id, region: MU.curRegion, credentials: nil)
|
|
405
405
|
begin
|
|
406
406
|
MU::Cloud::AWS.elasticache(region: region, credentials: credentials).describe_cache_clusters(cache_cluster_id: cc_id).cache_clusters.first
|
|
407
|
-
rescue Aws::ElastiCache::Errors::CacheClusterNotFound
|
|
407
|
+
rescue Aws::ElastiCache::Errors::CacheClusterNotFound
|
|
408
408
|
nil
|
|
409
409
|
end
|
|
410
410
|
end
|
|
@@ -532,7 +532,7 @@ module MU
|
|
|
532
532
|
|
|
533
533
|
attempts = 0
|
|
534
534
|
begin
|
|
535
|
-
|
|
535
|
+
MU::Cloud::AWS.elasticache(region: @config['region'], credentials: @config['credentials']).create_snapshot(
|
|
536
536
|
cache_cluster_id: @config["identifier"],
|
|
537
537
|
snapshot_name: snap_id
|
|
538
538
|
)
|
|
@@ -669,7 +669,7 @@ module MU
|
|
|
669
669
|
threads << Thread.new(replication_group) { |myrepl_group|
|
|
670
670
|
MU.dupGlobals(parent_thread_id)
|
|
671
671
|
Thread.abort_on_exception = true
|
|
672
|
-
|
|
672
|
+
terminate_replication_group(myrepl_group, noop: noop, skipsnapshots: skipsnapshots, region: region, credentials: credentials)
|
|
673
673
|
}
|
|
674
674
|
}
|
|
675
675
|
end
|
|
@@ -681,7 +681,7 @@ module MU
|
|
|
681
681
|
threads << Thread.new(cluster) { |mycluster|
|
|
682
682
|
MU.dupGlobals(parent_thread_id)
|
|
683
683
|
Thread.abort_on_exception = true
|
|
684
|
-
|
|
684
|
+
terminate_cache_cluster(mycluster, noop: noop, skipsnapshots: skipsnapshots, region: region, credentials: credentials)
|
|
685
685
|
}
|
|
686
686
|
}
|
|
687
687
|
end
|
|
@@ -694,9 +694,9 @@ module MU
|
|
|
694
694
|
end
|
|
695
695
|
|
|
696
696
|
# Cloud-specific configuration properties.
|
|
697
|
-
# @param
|
|
697
|
+
# @param _config [MU::Config]: The calling MU::Config object
|
|
698
698
|
# @return [Array<Array,Hash>]: List of required fields, and json-schema Hash of cloud-specific configuration parameters for this resource
|
|
699
|
-
def self.schema(
|
|
699
|
+
def self.schema(_config)
|
|
700
700
|
toplevel_required = []
|
|
701
701
|
schema = {
|
|
702
702
|
"create_replication_group" => {
|
|
@@ -804,9 +804,8 @@ module MU
|
|
|
804
804
|
# @param noop [Boolean]: If true, will only print what would be done.
|
|
805
805
|
# @param skipsnapshots [Boolean]: If true, will not create a last snapshot before terminating the Cache Cluster.
|
|
806
806
|
# @param region [String]: The cloud provider's region in which to operate.
|
|
807
|
-
# @param cloud_id [String]: The cloud provider's identifier for this resource.
|
|
808
807
|
# @return [void]
|
|
809
|
-
def self.terminate_cache_cluster(cluster, noop: false, skipsnapshots: false, region: MU.curRegion,
|
|
808
|
+
def self.terminate_cache_cluster(cluster, noop: false, skipsnapshots: false, region: MU.curRegion, credentials: nil)
|
|
810
809
|
raise MuError, "terminate_cache_cluster requires a non-nil cache cluster descriptor" if cluster.nil? || cluster.empty?
|
|
811
810
|
|
|
812
811
|
cluster_id = cluster.cache_cluster_id
|
|
@@ -874,7 +873,7 @@ module MU
|
|
|
874
873
|
waiter.before_attempt do |attempts|
|
|
875
874
|
MU.log "Waiting for cache cluster #{cluster_id} to delete..", MU::NOTICE if attempts % 10 == 0
|
|
876
875
|
end
|
|
877
|
-
waiter.before_wait do |
|
|
876
|
+
waiter.before_wait do |_attempts, resp|
|
|
878
877
|
throw :success if resp.cache_clusters.first.cache_cluster_status == "deleted"
|
|
879
878
|
throw :failure if Time.now - wait_start_time > 1800
|
|
880
879
|
end
|
|
@@ -893,19 +892,19 @@ module MU
|
|
|
893
892
|
MU.log "#{cluster_id} has been terminated"
|
|
894
893
|
|
|
895
894
|
unless noop
|
|
896
|
-
|
|
897
|
-
|
|
895
|
+
delete_subnet_group(subnet_group, region: region, credentials: credentials) if subnet_group
|
|
896
|
+
delete_parameter_group(parameter_group, region: region, credentials: credentials) if parameter_group && !parameter_group.start_with?("default")
|
|
898
897
|
end
|
|
899
898
|
end
|
|
899
|
+
private_class_method :terminate_cache_cluster
|
|
900
900
|
|
|
901
901
|
# Remove a Cache Cluster Replication Group and associated artifacts
|
|
902
902
|
# @param repl_group [OpenStruct]: The cloud provider's description of the Cache Cluster artifact.
|
|
903
903
|
# @param noop [Boolean]: If true, will only print what would be done.
|
|
904
904
|
# @param skipsnapshots [Boolean]: If true, will not create a last snapshot before terminating the Cache Cluster.
|
|
905
905
|
# @param region [String]: The cloud provider's region in which to operate.
|
|
906
|
-
# @param cloud_id [String]: The cloud provider's identifier for this resource.
|
|
907
906
|
# @return [void]
|
|
908
|
-
def self.terminate_replication_group(repl_group, noop: false, skipsnapshots: false, region: MU.curRegion,
|
|
907
|
+
def self.terminate_replication_group(repl_group, noop: false, skipsnapshots: false, region: MU.curRegion, credentials: nil)
|
|
909
908
|
raise MuError, "terminate_replication_group requires a non-nil cache replication group descriptor" if repl_group.nil? || repl_group.empty?
|
|
910
909
|
|
|
911
910
|
repl_group_id = repl_group.replication_group_id
|
|
@@ -983,7 +982,7 @@ module MU
|
|
|
983
982
|
waiter.before_attempt do |attempts|
|
|
984
983
|
MU.log "Waiting for #{repl_group_id} to delete..", MU::NOTICE if attempts % 10 == 0
|
|
985
984
|
end
|
|
986
|
-
waiter.before_wait do |
|
|
985
|
+
waiter.before_wait do |_attempts, resp|
|
|
987
986
|
throw :success if resp.replication_groups.first.status == "deleted"
|
|
988
987
|
throw :failure if Time.now - wait_start_time > 1800
|
|
989
988
|
end
|
|
@@ -1005,6 +1004,7 @@ module MU
|
|
|
1005
1004
|
MU::Cloud::AWS::CacheCluster.delete_parameter_group(parameter_group, region: region) if parameter_group && !parameter_group.start_with?("default")
|
|
1006
1005
|
end
|
|
1007
1006
|
end
|
|
1007
|
+
private_class_method :terminate_replication_group
|
|
1008
1008
|
|
|
1009
1009
|
# Remove a Cache Cluster Subnet Group.
|
|
1010
1010
|
# @param subnet_group_id [string]: The cloud provider's ID of the cache cluster subnet group.
|
|
@@ -1026,6 +1026,7 @@ module MU
|
|
|
1026
1026
|
MU.log "Subnet group #{subnet_group_id} is not in a removable state after several retries, giving up. #{e.inspect}", MU::ERR
|
|
1027
1027
|
end
|
|
1028
1028
|
end
|
|
1029
|
+
private_class_method :delete_subnet_group
|
|
1029
1030
|
|
|
1030
1031
|
# Remove a Cache Cluster Parameter Group.
|
|
1031
1032
|
# @param parameter_group_id [string]: The cloud provider's ID of the cache cluster parameter group.
|
|
@@ -1049,6 +1050,7 @@ module MU
|
|
|
1049
1050
|
MU.log "Parameter group #{parameter_group_id} is not in a removable state after several retries, giving up. #{e.inspect}", MU::ERR
|
|
1050
1051
|
end
|
|
1051
1052
|
end
|
|
1053
|
+
private_class_method :delete_parameter_group
|
|
1052
1054
|
end
|
|
1053
1055
|
end
|
|
1054
1056
|
end
|
|
@@ -61,7 +61,7 @@ module MU
|
|
|
61
61
|
]
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
keypairname,
|
|
64
|
+
keypairname, _ssh_private_key, _ssh_public_key = @deploy.SSHKey
|
|
65
65
|
|
|
66
66
|
parameters = Array.new
|
|
67
67
|
if !@config["parameters"].nil?
|
|
@@ -108,7 +108,7 @@ module MU
|
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
MU.log "Creating CloudFormation stack '#{@config['name']}'", details: stack_descriptor
|
|
111
|
-
|
|
111
|
+
MU::Cloud::AWS.cloudformation(region: region, credentials: @config['credentials']).create_stack(stack_descriptor);
|
|
112
112
|
|
|
113
113
|
sleep(10);
|
|
114
114
|
stack_response = MU::Cloud::AWS.cloudformation(region: region, credentials: @config['credentials']).describe_stacks({:stack_name => stack_name}).stacks.first
|
|
@@ -135,7 +135,7 @@ module MU
|
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
if flag == "FAIL" then
|
|
138
|
-
|
|
138
|
+
MU::Cloud::AWS.cloudformation(region: region, credentials: @config['credentials']).delete_stack({:stack_name => stack_name})
|
|
139
139
|
exit 1
|
|
140
140
|
end
|
|
141
141
|
|
|
@@ -150,14 +150,14 @@ module MU
|
|
|
150
150
|
when "AWS::EC2::Instance"
|
|
151
151
|
MU::Cloud::AWS.createStandardTags(resource.physical_resource_id)
|
|
152
152
|
instance_name = MU.deploy_id+"-"+@config['name']+"-"+resource.logical_resource_id
|
|
153
|
-
MU::
|
|
153
|
+
MU::Cloud::AWS.createTag(resource.physical_resource_id, "Name", instance_name, credentials: @config['credentials'])
|
|
154
154
|
|
|
155
155
|
instance = MU::Cloud::AWS::Server.notifyDeploy(
|
|
156
156
|
@config['name']+"-"+resource.logical_resource_id,
|
|
157
157
|
resource.physical_resource_id
|
|
158
158
|
)
|
|
159
159
|
|
|
160
|
-
MU::
|
|
160
|
+
MU::Master.addHostToSSHConfig(
|
|
161
161
|
instance_name,
|
|
162
162
|
instance["private_ip_address"],
|
|
163
163
|
instance["private_dns_name"],
|
|
@@ -168,23 +168,23 @@ module MU
|
|
|
168
168
|
key_name: instance["key_name"]
|
|
169
169
|
)
|
|
170
170
|
|
|
171
|
-
mu_zone,
|
|
171
|
+
mu_zone, _junk = MU::Cloud::DNSZone.find(name: "mu")
|
|
172
172
|
if !mu_zone.nil?
|
|
173
173
|
MU::Cloud::AWS::DNSZone.genericMuDNSEntry(instance_name, instance["private_ip_address"], MU::Cloud::Server)
|
|
174
174
|
else
|
|
175
|
-
MU::
|
|
175
|
+
MU::Master.addInstanceToEtcHosts(instance["public_ip_address"], instance_name)
|
|
176
176
|
end
|
|
177
177
|
|
|
178
178
|
when "AWS::EC2::SecurityGroup"
|
|
179
179
|
MU::Cloud::AWS.createStandardTags(resource.physical_resource_id)
|
|
180
|
-
MU::
|
|
180
|
+
MU::Cloud::AWS.createTag(resource.physical_resource_id, "Name", MU.deploy_id+"-"+@config['name']+'-'+resource.logical_resource_id, credentials: @config['credentials'])
|
|
181
181
|
MU::Cloud::AWS::FirewallRule.notifyDeploy(
|
|
182
182
|
@config['name']+"-"+resource.logical_resource_id,
|
|
183
183
|
resource.physical_resource_id
|
|
184
184
|
)
|
|
185
185
|
when "AWS::EC2::Subnet"
|
|
186
186
|
MU::Cloud::AWS.createStandardTags(resource.physical_resource_id)
|
|
187
|
-
MU::
|
|
187
|
+
MU::Cloud::AWS.createTag(resource.physical_resource_id, "Name", MU.deploy_id+"-"+@config['name']+'-'+resource.logical_resource_id, credentials: @config['credentials'])
|
|
188
188
|
data = {
|
|
189
189
|
"collection" => @config["name"],
|
|
190
190
|
"subnet_id" => resource.physical_resource_id,
|
|
@@ -192,7 +192,7 @@ module MU
|
|
|
192
192
|
@deploy.notify("subnets", @config['name']+"-"+resource.logical_resource_id, data)
|
|
193
193
|
when "AWS::EC2::VPC"
|
|
194
194
|
MU::Cloud::AWS.createStandardTags(resource.physical_resource_id)
|
|
195
|
-
MU::
|
|
195
|
+
MU::Cloud::AWS.createTag(resource.physical_resource_id, "Name", MU.deploy_id+"-"+@config['name']+'-'+resource.logical_resource_id, credentials: @config['credentials'])
|
|
196
196
|
data = {
|
|
197
197
|
"collection" => @config["name"],
|
|
198
198
|
"vpc_id" => resource.physical_resource_id,
|
|
@@ -200,10 +200,10 @@ module MU
|
|
|
200
200
|
@deploy.notify("vpcs", @config['name']+"-"+resource.logical_resource_id, data)
|
|
201
201
|
when "AWS::EC2::InternetGateway"
|
|
202
202
|
MU::Cloud::AWS.createStandardTags(resource.physical_resource_id)
|
|
203
|
-
MU::
|
|
203
|
+
MU::Cloud::AWS.createTag(resource.physical_resource_id, "Name", MU.deploy_id+"-"+@config['name']+'-'+resource.logical_resource_id, credentials: @config['credentials'])
|
|
204
204
|
when "AWS::EC2::RouteTable"
|
|
205
205
|
MU::Cloud::AWS.createStandardTags(resource.physical_resource_id)
|
|
206
|
-
MU::
|
|
206
|
+
MU::Cloud::AWS.createTag(resource.physical_resource_id, "Name", MU.deploy_id+"-"+@config['name']+'-'+resource.logical_resource_id, credentials: @config['credentials'])
|
|
207
207
|
|
|
208
208
|
# The rest of these aren't anything we act on
|
|
209
209
|
when "AWS::EC2::Route"
|
|
@@ -243,6 +243,9 @@ module MU
|
|
|
243
243
|
# @param wait [Boolean]: Block on the removal of this stack; AWS deletion will continue in the background otherwise if false.
|
|
244
244
|
# @return [void]
|
|
245
245
|
def self.cleanup(noop: false, ignoremaster: false, region: MU.curRegion, wait: false, credentials: nil, flags: {})
|
|
246
|
+
MU.log "AWS::Collection.cleanup: need to support flags['known']", MU::DEBUG, details: flags
|
|
247
|
+
MU.log "Placeholder: AWS Collection artifacts do not support tags, so ignoremaster cleanup flag has no effect", MU::DEBUG, details: ignoremaster
|
|
248
|
+
|
|
246
249
|
# XXX needs to check tags instead of name- possible?
|
|
247
250
|
resp = MU::Cloud::AWS.cloudformation(credentials: credentials, region: region).describe_stacks
|
|
248
251
|
resp.stacks.each { |stack|
|
|
@@ -257,7 +260,6 @@ module MU
|
|
|
257
260
|
MU::Cloud::AWS.cloudformation(credentials: credentials, region: region).delete_stack(stack_name: stack.stack_name)
|
|
258
261
|
end
|
|
259
262
|
if wait
|
|
260
|
-
last_status = ""
|
|
261
263
|
max_retries = 10
|
|
262
264
|
retries = 0
|
|
263
265
|
mystack = nil
|
|
@@ -272,10 +274,9 @@ module MU
|
|
|
272
274
|
MU.log "Couldn't delete CloudFormation stack #{stack.stack_name}", MU::ERR, details: mystack.stack_status_reason
|
|
273
275
|
return
|
|
274
276
|
end
|
|
275
|
-
last_status = mystack.stack_status_reason
|
|
276
277
|
MU.log "Waiting for CloudFormation stack #{stack.stack_name} to delete (#{stack.stack_status})...", MU::NOTICE
|
|
277
278
|
end
|
|
278
|
-
rescue Aws::CloudFormation::Errors::ValidationError
|
|
279
|
+
rescue Aws::CloudFormation::Errors::ValidationError
|
|
279
280
|
# this is ok, it means deletion finally succeeded
|
|
280
281
|
|
|
281
282
|
end while !desc.nil? and desc.size > 0 and retries < max_retries
|
|
@@ -317,19 +318,19 @@ module MU
|
|
|
317
318
|
end
|
|
318
319
|
|
|
319
320
|
# Cloud-specific configuration properties.
|
|
320
|
-
# @param
|
|
321
|
+
# @param _config [MU::Config]: The calling MU::Config object
|
|
321
322
|
# @return [Array<Array,Hash>]: List of required fields, and json-schema Hash of cloud-specific configuration parameters for this resource
|
|
322
|
-
def self.schema(
|
|
323
|
+
def self.schema(_config)
|
|
323
324
|
toplevel_required = []
|
|
324
325
|
schema = {}
|
|
325
326
|
[toplevel_required, schema]
|
|
326
327
|
end
|
|
327
328
|
|
|
328
329
|
# Cloud-specific pre-processing of {MU::Config::BasketofKittens::collections}, bare and unvalidated.
|
|
329
|
-
# @param
|
|
330
|
-
# @param
|
|
330
|
+
# @param _stack [Hash]: The resource to process and validate
|
|
331
|
+
# @param _configurator [MU::Config]: The overall deployment configurator of which this resource is a member
|
|
331
332
|
# @return [Boolean]: True if validation succeeded, False otherwise
|
|
332
|
-
def self.validateConfig(
|
|
333
|
+
def self.validateConfig(_stack, _configurator)
|
|
333
334
|
true
|
|
334
335
|
end
|
|
335
336
|
|