... which I followed for setting up a simple Rails App on Opsworks.
- Set up an IAM role for ssh to the instances later
- Set up a Stack
- Set up a Layer RDS instace (used MySQL)
- Set up the RDS' VPC id, endpoint, master user, password
- Create a database for the App and a user to connect to it using the db master user
- Add the RDS details in the database section of the custom JSON (see custom json below)
- Setup the Layer with
Layer Type
Rails App
. - Create an App
- setup github deploy key (generate pub key, put private key on Rails App's Github repo)
- setup set
document root
topublic
- generate
SECRET_KEY_BASE
withbundle exec rake secret
and store in OpsWorks' Environment Variables - register rds as data source using
Database instance
andDatabase name
- Set up Rails App's Git repo.
- Remove the
config/security.conf
from the.gitignore
. Theconfig/security.conf
file containting production entrysecret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
- Create instance
- In
EC2
Actions
Security Groups
assign theVPC default
Security group to the instance (otherwise it won't talk to the RDS) - In Instances, assign App
- Provision and deploy instance
{
"deploy": {
"rails_app_short_name": {
{
"database": {
"username": "...",
"password": "...",
"database": "...",
"host": "dbinstancename.....eu-west-1.rds.amazonaws.com",
"adapter": "mysql"
}
}
}
}
}
In the Rails-App Layer, no recipes are needed other than the ones provided automatically.
Log files for the Passenger/Apache2 setup of the Layer end up in /var/logs/apache2/
. For nginx/Unicorn
they end up in the Rails application's log
directory. The nginx/Unicorn
logs I found to be more verbose and valuable for feedback because the contained stack traces where the others did not. The full custom JSON with all values contained can be found in /var/lib/aws/chef/[time-stamp-of-deployment].json
. This comes in handy if you are in doubt about the values passed into the JSON from OpsWorks.