Generic capistrano recipes. Some Rails-specific, most - not.
Ruby HTML Shell
Pull request Compare This branch is 260 commits ahead of mdespuits:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
chefsolo
lib
templates
.gitignore
.yardopts
ASSETS_PRECOMPILE.md
README.md
apache_unicorn.rb
application_yml_file.rb
assets_precompile.rb
assets_precompile_conditional.rb
assets_precompile_local.rb
aws.rb
base.rb
bower.rb
check.rb
chefsolo.rb
clockwork.rb
couchdb_database_yml.rb
crontab.rb
database.rb
ensure_capiche_code_tagged.rb
fast.rb
ghost.rb
grunt.rb
hostname.rb
htpasswd.rb
http_proxy.rb
logs.rb
memcached.rb
middleman.rb
mysql.rb
mysql_dump.rb
nginx.rb
nginx_monit.rb
nodejs.rb
notify_slack.rb
npm.rb
paperclip.rb
postgresql.rb
postgresql_backup.rb
puma.rb
puppet.rb
rbenv.rb
setup.rb
skip_bundler.rb
sudo.rb
talks.rb
unicorn.rb
unicorn_monit.rb

README.md

Capistrano recipes

This directory contains recipes to be used together with Capistrano. To use recipe in the deployment require needed file(s) from your deploy.rb file.

Note: Do not automatically require all files. Some recipes implement same functionally differently depending on your requirements.

Description

Many cookbooks here are heavily modified after forking from original author. Main idea for new functionality is to provide means of integrating Capistrano with Chef-solo, where Capistrano is used for application deployment, and Chef is used for all infrastructure related tasks: bootstraping servers, installing software, etc.

This repository is closely related to another one (dmytro/chef-solo) and tested with it.

Integration with chef-solo

Boostraping server

TBD

Chef-solo roles and Capistrano roles

TBD

Custom chef-solo setup

TBD

Using Chef databags

It is possible to use Chef databags in Capistrano recipes. Databags are loaded from either custom Chef-solo path or from standard one. If custom path is defined (variable :custom_chef_solo defined when recipe custom_chef_solo is loaded), then custom path is used.

  • Example (see recipe mysql.rb):
    root_password = get_data_bag(:users, "mysql")["root_password"]
    set :database, get_data_bag(:application, "database")
  • Limitations
    • Databags are loaded on the local server, which means that node attributes are not known.
    • No search functionality, only load

Recipes

Base

  • base.rb - this file is required. It sets some common methods used in other recipes.

Capistrano DSL extensions

File base.rb contains several extensions that can be useful with Capistrano deployments (and also used in this recipes collection).

recipe

Load file with recipe by it's name. Just a helper.

upload_dir

Same as upload in Capistrano but for whole directory by tarring it locally and untarring remotely.

surun

Ask for root password and execute command remotely via su -. Fallback for the situations when sudo is not installed.

template

Helper to parse and upload to remote ERB template.

set_default

Set variable conditionally.


Infrastructure and setup

Setup

  • rbenv.rb - TODO
  • setup.rb - Change ownership of the created directories at the setup stage
    • :deploy:chown_dirs
  • ensure_tagged_release - if this recipe is included, before deployment it will check that current checked out deployment code (not application) is tagged. This is to ensure that production setups are released only using stable code. Relase tag should be formatted acordingly to Semantic versioningn (vA.B.C).

Remote logs

  • logs.rb - Manage log/production.log file: tail and truncate

Sudo

  • sudo.rb - Install sudo on the remote server. Do nothing if sudo installed.

Chef

  • chef_solo.rb - 2 tasks
    • chefsolo:deploy - Run chef-solo deploy on the remote server (bootstrap server)
    • chefsolo:run_remote - deploy single JSON chef-solo file
  • chef_solo_roles.rb
    • chefsolo:roles chef_solo_roles.rb - Deploy JSON file corresponding to role (uses chefsolo:run_remote)

Puppet

  • puppet.rb

Similar to chef-solo above. Bootstraps puppet and provide task to execute manifest remotely. Puppet recipe requires chef-solo bootstrap.

HTTP Proxy

  • File: http_proxy.rb

Setup HTTP proxy to access network via gateway server. HTTP server must have role :proxy, all other hosts configured as proxy clients.


Web-servers and app.servers

nginx.rb

TODO: refactor install to use Chef

  • Template
    • templates/nginx.conf.erb

nginx_monit.rb

Recipe to restart Nginx on systems with Monit

apache_unicorn.rb - Create virtual host for Apache with Unicorn

  • Templates
    • templates/apache_unicorn_modules.json.erb
    • templates/apache_unicorn_virtual_host.conf.erb

unicorn.rb - Unicorn configuration for Nginx or Apache

  • Template
    • templates/unicorn.rb.erb

puma.rb - TODO


Databases

Generic (Sqlite)

  • database.rb: Manage DB yaml config for Rails
    • database:setup Generate the database.yml configuration file.
    • database:symlink
    • Template
      • templates/database.yml.erb

Postgres

  • postgresql.rb - Manage Postgres for Rails (namespace :postgresql)
    • :install - TODO: refactor install to use Chef
    • :drop_database
    • :create_database
    • :setup
    • :symlink
    • Template
      • templates/postgresql.yml.erb
  • postgresql_backup.rb - Backup remote PostgreSQL server. Automatically create pre/post backups on deploy. Namespace :postrgresql.
    • :setup
    • :production
    • :production_pre
    • :production_post

Memcached

  • memcached.rb - TODO refactor to use Chef
    • Template
      • templates/memcached.erb

Rails configuration

  • application_yml_file.rb - Manage config/application.yml file: concatenate example and secrets files

Rails assets

  • Asset Precompile recipes - see {file:ASSETS_PRECOMPILE.md} for details
    • assets_precompile.rb
    • assets_precompile_conditional.rb
    • assets_precompile_local.rb

Others and deprecated

  • check.rb - deprecated
  • fast.rb
  • nodejs.rb - TODO: refactor install to use Chef
  • talks.rb - TODO