ruk·si

🦦 Otto

Updated at 2015-09-29 02:55

Otto is a high-level toolbox for web application development and deployment. It uses Vagrant, VirtualBox, Terraform, Packer, Consul and the server provider of your choosing to launch a cluster of web services while trying to keep the process as simple as possible, but open for customization.

# Create IAM user for the app, attach AmazonEC2FullAccess policy.
# Create SSH key for the app.
ssh-keygen -t rsa -C "me@ruk.si"
# Download `otto` and save it to `/usr/bin/otto`
rails new ottorails
cd ottorails
otto compile        # Load Appfile, auto-inspect environment and load deps
otto dev            # Start development virtual machine (Vagrant)
otto dev ssh        # Access development virtual machine
bundle && rackup --host 0.0.0.0 # does it startup up?

otto dev address    # Get development virtual machine address
# => navigate to <IP>:9292

otto status         # Check dev, infra, build and deploy status

otto infra          # Initialize support services on the cloud (Terraform)

# before building, you must define git for repository for the app
git init
git add -A
git commit -m "Init commit"

otto build       # Build deployable app package, for AWS, it's an image (Packer)
otto deploy      # Send app to the clouds (Consul for binding services)
otto deploy info # Extra info about the deployment

Otto is codification of software development flow. You define development environment, deployment strategy, dependency services and production environment; all in one place with as little markup as possible.

Appfile is optional customization for your cluster. Appfile is the source code for Otto configuration, not the configuration itself. It will be merged with detected defaults on otto compile. The final configuration is saved to .otto directory, and it should not be edited directly or saved to version control. .ottoid is also generated which is a unique identifier for the app and should be stored in the version control.

# `Appfile`

# optional configuration import
# import "github.com/myorg/otto-shared/ruby" {}
# import "./folder" {}

application {
  name = "ottorails"        # used for Consul service discovery
  type = "ruby"             # how to dev and deploy
  dependency {
    # Consul generated endpoint will be: mongodb.service.consul
    source = "github.com/hashicorp/otto/examples/mongodb"
    # source = "git::https://hashicorp.com/repo.git?ref=master"
  }
}

project {
  name = "ottorails"            # unique in infrastructure
  infrastructure = "ottorails"  # linked infra
}

infrastructure "ottorails" {
  type = "aws"                  # provider
  flavor = "simple"             # single server, no load balancer
}

customization "ruby" {
  ruby_version = "2.1"
}
# Recompile after Appfile changes
otto compile
otto dev destroy
otto dev

How to remove all resources.

otto deploy destroy     # Destroy running apps in the cloud
otto infra destroy      # Destroy supporting services in the cloud
otto dev destroy        # Destroy local development virtual machine