Project

ops_deploy

0.0
No commit activity in last 3 years
No release in over 3 years
Perform deployment & checks on AWS OpsWorks. You can deploy, wait for deployments to finish, and check on the instances responses for a successful deployment flow. Also implements Slack notifications for each step.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 2.1
~> 0.7
~> 0.13
~> 4.3
~> 0.14
 Project Readme

OpsDeploy

A simple gem to perform deployment & checks on AWS OpsWorks. You can deploy, wait for deployments to finish, and check on the instances responses for a successful deployment flow. Also implements Slack notifications for each step.

Usage

gem install ops_deploy

In your code:

require 'ops_deploy'
ops = OpsDeploy.new(aws_config)

# Start deployment (sync)
success = ops.start_deployment(stack_id, app_id, migrate)

# Wait for deployments (async)
ops.deployments_callback = Proc.new {
  |aws_deployment_obj|
  # whatever
}
a_thread = ops.wait_for_deployments(stack_id)
a_thread.join

# Check instances (async)
ops.instances_check_callback = Proc.new {
  |aws_instance_obj, http_response, exception|
  # whatever
}
a_thread = ops.check_instances(stack_id)
a_thread.join

or using the CLI:

opsdeploy <tasks> --aws-region=<aws_region> --aws-profile=<...> --stack=<stack_name_or_id> --slack-webhook-url=<...> --slack-username=<...> --slack-channel=<...>

The tasks are:

  • deploy (starts a deployment)
  • migrate (will also migrate during the deployment [for Rails apps])
  • wait (waits for the deployments)
  • check (checks the instances)

Example:

opsdeploy deploy wait check --stack="Example" --aws-region="us-east-1"

Output:

-> Getting stack 'Example'...
-> Found stack 'Example' (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
-> Starting deployment on stack 'Example'...
✓ Deployment started on stack 'Example'
-> Checking deployments...
-> Waiting for deployments to finish...
..............................................................
✓ Deployment OK (58s)
// Deployments finished
-> Checking instances' HTTP response...
.
✓ Response from rails-app1: 200 OK
// Response check finished

If you want to post info about the latest commit to slack: WARNING: This posts the latest commit in the current local git branch, not the latest one on github

opsdeploy deploy wait check --stack="Example" --aws-region="us-east-1" --post-latest-commit=true

Output:

-> Getting stack 'Example'...
-> Found stack 'Example' (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
-> Latest commit:  commit b5fed5c32df0613df06a8e1452d194cafabc22bc
Author: Martin Morava <martin.morava@example.com>
Date:   Tue Aug 9 11:49:56 2016 +0200

    Enable Slack notifications about the latest commit
-> Starting deployment on stack 'Example'...
✓ Deployment started on stack 'Example'
-> Checking deployments...
-> Waiting for deployments to finish...
..............................................................
✓ Deployment OK (58s)
// Deployments finished
-> Checking instances' HTTP response...
.
✓ Response from rails-app1: 200 OK
// Response check finished