forked from harvard-dce/mh-opsworks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
97 lines (78 loc) · 3 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
require './lib/cluster'
Dir['./lib/tasks/*.rake'].each { |file| load file }
namespace :admin do
namespace :cluster do
desc Cluster::RakeDocs.new('admin:cluster:init').desc
task init: ['cluster:configtest', 'cluster:config_sync_check'] do
stack = Cluster::Stack.find_or_create
if Cluster::Base.is_using_efs_storage?
remote_config = Cluster::RemoteConfig.new
remote_config.update_efs_server_hostname(Cluster::Filesystem.primary_efs_ip_address)
remote_config.sync
Cluster::Stack.update
end
puts %Q|Stack "#{stack.name}" initialized, id: #{stack.stack_id}|
layers = Cluster::Layers.find_or_create
Cluster::Instances.find_or_create
Cluster::App.find_or_create
layers.each do |layer|
puts %Q|Layer: "#{layer.name}" => #{layer.layer_id}|
Cluster::Instances.find_in_layer(layer).each do |instance|
puts %Q| Instance: #{instance.hostname} => status: #{instance.status}, ec2_instance_id: #{instance.ec2_instance_id}|
end
end
puts
puts %Q|Initializing the cluster does not start instances. To start them, use "./bin/rake stack:instances:start"|
end
desc Cluster::RakeDocs.new('admin:cluster:delete').desc
task delete: ['cluster:configtest', 'cluster:config_sync_check', 'cluster:production_failsafe'] do
puts 'deleting app'
Cluster::App.delete
puts 'deleting sns topic and subscriptions'
Cluster::SNS.delete
puts 'deleting instances'
Cluster::Instances.delete
puts 'deleting stack'
Cluster::Stack.delete
puts 'deleting instance profile'
Cluster::InstanceProfile.delete
puts 'deleting service role'
Cluster::ServiceRole.delete
puts 'deleting VPC'
Cluster::VPC.delete
puts 'deleting configuration files'
Cluster::RemoteConfig.new.delete
end
end
namespace :users do
desc Cluster::RakeDocs.new('admin:users:list').desc
task list: ['cluster:configtest', 'cluster:config_sync_check'] do
Cluster::IAMUser.all.each do |user|
puts %Q|#{user.user_name} => #{user.arn}|
end
end
end
desc Cluster::RakeDocs.new('admin:republish_maven_cache').desc
task republish_maven_cache: ['cluster:configtest', 'cluster:config_sync_check'] do
asset_bucket_name = Cluster::Base.shared_asset_bucket_name
a_public_host = Cluster::Instances.online.find do |instance|
(instance.public_dns != nil) && instance.hostname.match(/admin/)
end
system %Q|ssh -C #{a_public_host.public_dns} 'sudo bash -c "cd /root && tar cvfz - .m2/"' > maven_cache.tgz|
puts %Q|Uploading maven_cache.tgz to #{asset_bucket_name}|
Cluster::Assets.publish_support_asset_to(
bucket: asset_bucket_name,
file_name: 'maven_cache.tgz',
permissions: 'public'
)
puts 'done.'
File.unlink('maven_cache.tgz')
end
end
task :default do
Rake.application.tasks.each do |task|
puts "./bin/rake #{task.name}"
end
puts
puts 'Run "./bin/rake -T" for full task output'
end