Module: AwsDeploymentHelper
- Defined in:
- lib/opsworks_ship/aws_deployment_helper.rb
Instance Method Summary collapse
- #deploy_comment ⇒ Object
- #deployed_by ⇒ Object
- #monitor_deployment(deployment_id) ⇒ Object
- #output_per_server_status_descriptions(deployment_id) ⇒ Object
- #start_deployment(command) ⇒ Object
- #syntax ⇒ Object
- #timestamped_puts(str) ⇒ Object
Instance Method Details
#deploy_comment ⇒ Object
53 54 55 |
# File 'lib/opsworks_ship/aws_deployment_helper.rb', line 53 def deploy_comment "--comment \"rev. #{@revision}, deployed by #{deployed_by}\" " end |
#deployed_by ⇒ Object
7 8 9 10 11 |
# File 'lib/opsworks_ship/aws_deployment_helper.rb', line 7 def deployed_by git_user = `git config --global user.name`.chomp git_email = `git config --global user.email`.chomp "#{git_user} (#{git_email})" end |
#monitor_deployment(deployment_id) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/opsworks_ship/aws_deployment_helper.rb', line 19 def monitor_deployment(deployment_id) deployment_finished = false status = "" while !deployment_finished response = describe_deployments(deployment_id) response["Deployments"].each do |deployment| next if deployment["DeploymentId"] != deployment_id status = deployment["Status"] "Status: #{status}" deployment_finished = true if deployment["Status"].downcase != "running" end sleep(15) unless deployment_finished end "Deployment #{status}" output_per_server_status_descriptions(deployment_id) status end |
#output_per_server_status_descriptions(deployment_id) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/opsworks_ship/aws_deployment_helper.rb', line 57 def output_per_server_status_descriptions(deployment_id) per_server_status_descriptions(deployment_id).each do |description| description puts '' end end |
#start_deployment(command) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/opsworks_ship/aws_deployment_helper.rb', line 37 def start_deployment(command) app_id = app_id(stack_id) cmd = "aws opsworks create-deployment --app-id #{app_id} " + "--stack-id #{stack_id} " + "--command \"#{command}\" " + "--instance-ids #{relevant_instance_ids(stack_id).join(' ')} " + deploy_comment "Running command... #{command}" cmd response = JSON.parse(`#{cmd}`) response["DeploymentId"] end |
#syntax ⇒ Object
13 14 15 16 17 |
# File 'lib/opsworks_ship/aws_deployment_helper.rb', line 13 def syntax puts "Arguments: #{method(:initialize).parameters.map{|p| "#{p.last} (#{p.first})"}.join(' ')}" puts "\n" puts "Valid stacks: #{all_stack_names}}" end |
#timestamped_puts(str) ⇒ Object
3 4 5 |
# File 'lib/opsworks_ship/aws_deployment_helper.rb', line 3 def (str) puts "#{Time.now} #{str}" end |