Class: Aerosol::Deploy
- Inherits:
-
Object
- Object
- Aerosol::Deploy
- Includes:
- Dockly::Util::DSL, Dockly::Util::Logger::Mixin
- Defined in:
- lib/aerosol/deploy.rb
Instance Method Summary collapse
- #do_not_migrate! ⇒ Object
- #generate_ssh_command(instance) ⇒ Object
- #generate_ssh_commands ⇒ Object
- #is_alive?(command = nil, &block) ⇒ Boolean
- #live_check(arg = nil) ⇒ Object
- #live_check_url ⇒ Object
- #local_ssh_ref ⇒ Object
- #migrate? ⇒ Boolean
- #migration(opts = {}) ⇒ Object
- #perform_role_assumption ⇒ Object
- #run_post_deploy ⇒ Object
Instance Method Details
#do_not_migrate! ⇒ Object
50 51 52 |
# File 'lib/aerosol/deploy.rb', line 50 def do_not_migrate! self.instance_variable_set(:@db_config_path, nil) end |
#generate_ssh_command(instance) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/aerosol/deploy.rb', line 88 def generate_ssh_command(instance) ssh_command = "ssh -o 'UserKnownHostsFile=/dev/null' -o 'StrictHostKeyChecking=no' " unless local_ssh_ref.nil? unless local_ssh_ref.jump.nil? || local_ssh_ref.jump.empty? ssh_command << "-o 'ProxyCommand=ssh -W %h:%p " ssh_command << "#{local_ssh_ref.jump[:user]}@" if local_ssh_ref.jump[:user] ssh_command << "#{local_ssh_ref.jump[:host]}' " end ssh_command << "#{local_ssh_ref.user}@" unless local_ssh_ref.user.nil? end ssh_command << "#{instance.address}" end |
#generate_ssh_commands ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/aerosol/deploy.rb', line 101 def generate_ssh_commands group = Aerosol::AutoScaling.latest_for_tag('Deploy', auto_scaling.namespaced_name) raise "Could not find any auto scaling groups for this deploy (#{name})." if group.nil? ssh_commands = [] with_prefix("[#{name}]") do |logger| logger.info "found group: #{group.auto_scaling_group_name}" instances = group.all_instances raise "Could not find any instances for auto scaling group #{group.namespaced_name}" if instances.empty? instances.each do |instance| logger.info "printing ssh command for #{instance.address}" ssh_commands << generate_ssh_command(instance) end end return ssh_commands end |
#is_alive?(command = nil, &block) ⇒ Boolean
39 40 41 42 43 44 |
# File 'lib/aerosol/deploy.rb', line 39 def is_alive?(command = nil, &block) fail 'Command and block specified' if command && block @is_alive = block if block @is_alive = command if command @is_alive end |
#live_check(arg = nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/aerosol/deploy.rb', line 27 def live_check(arg = nil) case when arg.nil? @live_check when arg.start_with?('/') @live_check = arg else @live_check = "/#{arg}" end @live_check end |
#live_check_url ⇒ Object
46 47 48 |
# File 'lib/aerosol/deploy.rb', line 46 def live_check_url [ssl ? 'https' : 'http', '://localhost:', app_port, live_check].join end |
#local_ssh_ref ⇒ Object
62 63 64 |
# File 'lib/aerosol/deploy.rb', line 62 def local_ssh_ref local_ssh || ssh end |
#migrate? ⇒ Boolean
58 59 60 |
# File 'lib/aerosol/deploy.rb', line 58 def migrate? !!db_config_path end |
#migration(opts = {}) ⇒ Object
54 55 56 |
# File 'lib/aerosol/deploy.rb', line 54 def migration(opts = {}) self.db_config_path(opts[:db_config_path]) end |
#perform_role_assumption ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/aerosol/deploy.rb', line 66 def perform_role_assumption return if assume_role.nil? Aws.config.update( credentials: Aws::AssumeRoleCredentials.new( role_arn: assume_role, role_session_name: "aerosol-#{name}", client: Aerosol::AWS.sts ) ) end |
#run_post_deploy ⇒ Object
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/aerosol/deploy.rb', line 77 def run_post_deploy return if post_deploy_command.nil? info "running post deploy: #{post_deploy_command}" if system(post_deploy_command) info "post deploy ran successfully" true else raise "post deploy failed" end end |