webapp/._CHANGELOG.md 000644 000765 000024 00000000430 12263165751 014311 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/CHANGELOG.md 000644 000765 000024 00000000706 12263165751 014102 0 ustar 00drj staff 000000 000000 webapp CHANGELOG
================
This file is used to list changes made in each version of the webapp cookbook.
0.1.0
-----
- Daniel Jabbour - Initial release of webapp
- - -
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
webapp/._LICENSE 000644 000765 000024 00000000430 12263165751 013505 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/LICENSE 000644 000765 000024 00000002101 12263165751 013265 0 ustar 00drj staff 000000 000000 The MIT License (MIT)
Copyright (c) 2013 Amoeba Consulting, LLC
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
webapp/._README.md 000644 000765 000024 00000000430 12263165751 013757 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/README.md 000644 000765 000024 00000003462 12263165751 013552 0 ustar 00drj staff 000000 000000 Webapp Cookbook
===============
This cookbook is a set of best practices for deploying web applications. Currently this is mainly focused around Ruby on Rails, but with limited support in the works for Node. We assume that code will be deployed and managed with Capistrano.
Part of the Amoeba Deploy Tools, this cookbook is used to rapidly build out a Ruby on Rails deployment in minutes. See Amoeba Deploy Tools for more information: http://github.com/AmoebaConsulting/amoeba-deploy-tools
Requirements
------------
Currently this is tested and works on Ubuntu 12.04 Server.
You must add the following to your Cookbooks manager. For Librarian Chef you can add the following
to your `Cheffile`:
```
cookbook 'rvm', github: 'fnichol/chef-rvm'
cookbook 'monit', github: 'phlipper/chef-monit'
cookbook 'nginx', github: ''
```
Attributes
----------
TODO: List you cookbook attributes here.
e.g.
#### webapp::default
Key |
Type |
Description |
Default |
['webapp']['bacon'] |
Boolean |
whether to include bacon |
true |
Usage
-----
#### webapp::default
TODO: Write usage instructions for each cookbook.
e.g.
Just include `webapp` in your node's `run_list`:
```json
{
"name":"my_node",
"run_list": [
"recipe[webapp]"
]
}
```
Contributing
------------
We welcome contributions to the repo. Please follow a Github friendly process:
1. Fork the repository on Github
2. Create a named feature branch (like `add_component_x`)
3. Write your change
4. Write tests for your change (if applicable)
5. Run the tests, ensuring they all pass
6. Submit a Pull Request using Github
License and Authors
-------------------
Authors:
* Daniel Jabbour [Amoeba Labs](http://amoe.ba) webapp/._attributes 000755 000765 000024 00000000467 12263165751 014626 0 ustar 00drj staff 000000 000000 Mac OS X 2 7 ATTR 7 ˜ Ÿ ˜ Ÿ com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited,file_inherit,directory_inherit:read,execute,readattr,readextattr,readsecurity
webapp/attributes/ 000755 000765 000024 00000000000 12263165751 014454 5 ustar 00drj staff 000000 000000 webapp/attributes/._cron.rb 000644 000765 000024 00000000430 12263165751 016154 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/attributes/cron.rb 000644 000765 000024 00000000025 12263165751 015737 0 ustar 00drj staff 000000 000000 appdefs.crontab = []
webapp/attributes/._db.rb 000644 000765 000024 00000000430 12263165751 015600 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/attributes/db.rb 000644 000765 000024 00000001767 12263165751 015401 0 ustar 00drj staff 000000 000000 def db; appdefs.database end
db.host = "localhost"
db.name = app.name.gsub('-', '_')
db.username = app.user.name
db.password = ""
db.encoding = "utf8"
#if URI.parse(app.database.host).scheme == 'node'
# search :node, "name:#{app.database.host}" do |host|
# override.database.host = host.name
# end
#end
db.adapter = case app.database[:type]
when /^postgres/
default.postgresql.pg_hba = [
{
user: app.user.name,
type: "local",
db: app.database.name,
addr: nil,
method: "peer"
}
]
"postgresql"
when /^mysql/ then "mysql2"
when /^sqlite/ then "sqlite3"
end
db.environments[app.environment] = {}
default[:webapp][:postgresql][:monit][:restart_cycles] = 5
# Override PSQL stuffs
override[:postgresql][:password][:postgres] = false
webapp/attributes/._default.rb 000644 000765 000024 00000000430 12263165751 016637 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/attributes/default.rb 000644 000765 000024 00000002467 12263165751 016436 0 ustar 00drj staff 000000 000000 # node[:application][:environment] must be defined (no default)
appdefs.user.name = app.name
appdefs.user.group = app.user.name
appdefs.user.home = "/home/#{app.user.name}"
appdefs.path = app.user.home
appdefs.current_path = "#{app.path}/current"
appdefs.shared_path = "#{app.path}/shared"
appdefs.releases_path = "#{app.path}/releases"
appdefs.static_path = "#{app.current_path}/public"
appdefs.config_path = "#{app.shared_path}/config"
appdefs.system_path = "#{app.shared_path}/system"
appdefs.run_path = "#{app.shared_path}/run"
appdefs.log_path = "#{app.shared_path}/log"
appdefs.init_path = "#{app.shared_path}/init"
appdefs.init_script = "#{app.init_path}/#{app.name}"
appdefs.capfile = "#{app.config_path}/Capfile"
appdefs.procfile = "#{app.config_path}/Procfile"
# Note that passenger and unicorn are mutually exclusive. Defaults to passenger.
# Type is mandatory and you must pick one and only one
# TODO Future unicorn & nodejs support
appdefs.type = 'passenger'
repo, branch = app.repository.match(/(^.*?)(?:#([^#]+))?$/)[1..2]
appdefs.repo = repo
appdefs.branch = branch || 'master'
appdefs.ci = nil
appdefs.env_vars = {
'RAILS_ENV' => app.environment,
'DEFAULT_HOST' => app.url
}
webapp/attributes/._javascript.rb 000644 000765 000024 00000000430 12263165751 017361 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/attributes/javascript.rb 000644 000765 000024 00000000053 12263165751 017145 0 ustar 00drj staff 000000 000000 override.nodejs.install_method = 'package'
webapp/attributes/._nginx.rb 000644 000765 000024 00000000430 12263165751 016336 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/attributes/nginx.rb 000644 000765 000024 00000006342 12263165751 016131 0 ustar 00drj staff 000000 000000 appdefs[:ssl][:enabled] = node[:application][:ssl][:cert_name] ? true : false
appdefs[:ssl][:force] = false
appdefs[:ssl][:cert_name] = nil
if app[:http_auth]
appdefs.http_auth.realm = "/"
appdefs.http_auth.exclude = []
end
appdefs.redirect_urls = []
appdefs.alias_urls = []
appdefs.url = node.fqdn
appdefs[:nginx][:keepalive_timeout] = 65
appdefs[:nginx][:enabled] = true
default[:webapp][:nginx][:user] = 'nobody'
default[:webapp][:nginx][:group] = 'nogroup'
default[:webapp][:nginx][:prefix] = '/usr/local'
default[:webapp][:nginx][:dir] = '/etc/nginx'
default[:webapp][:nginx][:log_dir] = '/var/log/nginx'
default[:webapp][:nginx][:version] = '1.4.4'
# You'll want to set this to avoid re-downloading files (this is correct for version above):
default[:webapp][:nginx][:checksum] = '7c989a58e540'
default[:webapp][:nginx][:configure_flags] = []
default[:webapp][:nginx][:monit][:max_children] = 250
default[:webapp][:nginx][:monit][:restart_cycles] = 5
# Override these attributes in the nginx cookbook (override in your node via node[:webapp])
override['nginx']['user'] = node[:webapp][:nginx][:user]
override['nginx']['group'] = node[:webapp][:nginx][:group]
override['nginx']['source']['use_existing_user'] = true # Don't create this user
override['nginx']['version'] = node[:webapp][:nginx][:version]
override['nginx']['configure_flags'] = node[:webapp][:nginx][:configure_flags]
override['nginx']['init_style'] = 'upstart'
# Directory prefixes and locations
override['nginx']['source']['prefix'] = node[:webapp][:nginx][:prefix]
override['nginx']['dir'] = node[:webapp][:nginx][:dir]
override['nginx']['log_dir'] = node[:webapp][:nginx][:log_dir]
override['nginx']['binary'] = node[:webapp][:nginx][:prefix] + '/sbin/nginx'
# HTTP modules (must be prefixed by nginx::)
override['nginx']['source']['modules'] = [
'nginx::http_stub_status_module',
'nginx::http_ssl_module',
'nginx::http_gzip_static_module'
]
# Override the source values, as they're going to be calculated wrong (copied from nginx::source attributes file)
override['nginx']['source']['version'] = node['nginx']['version']
override['nginx']['source']['conf_path'] = "#{node['nginx']['dir']}/nginx.conf"
override['nginx']['source']['sbin_path'] = "#{node['nginx']['source']['prefix']}/sbin/nginx"
override['nginx']['source']['default_configure_flags'] = %W[
--prefix=#{node['nginx']['source']['prefix']}
--conf-path=#{node['nginx']['dir']}/nginx.conf
--sbin-path=#{node['nginx']['source']['sbin_path']}
]
override['nginx']['source']['version'] = node['nginx']['version']
override['nginx']['source']['url'] = "http://nginx.org/download/nginx-#{node['nginx']['source']['version']}.tar.gz"
override['nginx']['source']['checksum'] = node[:webapp][:nginx][:checksum]
override['ssl_certs'] = [ node[:application][:ssl][:cert_name] ] if node[:application][:ssl][:cert_name]
# We will include the passenger attributes next, so that if we compile nginx it can
# include overrides set by passenger.
if node.recipes.include?('webapp::passenger')
include_attribute 'webapp::passenger'
end webapp/attributes/._passenger.rb 000644 000765 000024 00000000430 12263165751 017202 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/attributes/passenger.rb 000644 000765 000024 00000004153 12263165751 016773 0 ustar 00drj staff 000000 000000 include_attribute 'webapp::rvm' # RVM must be included before this... for ruby version
include_attribute 'webapp::nginx' # Need nginx attributes to set configure flags
# We're going to install passenger into the default / system ruby
default[:webapp][:passenger][:ruby] = node[:global_ruby_version]
default[:webapp][:passenger][:common_pkgs] = %w( libssl-dev zlib1g-dev libcurl4-openssl-dev )
default[:webapp][:passenger][:version] = '4.0.29'
default[:webapp][:passenger][:root_path] = "/usr/local/rvm/gems/#{node[:webapp][:passenger][:ruby]}/gems/passenger-#{node[:webapp][:passenger][:version]}"
default[:webapp][:passenger][:ruby_wrapper] = "/usr/local/rvm/gems/#{node[:webapp][:passenger][:ruby]}/bin/ruby"
# nginx config value defaults
default[:webapp][:passenger][:max_pool_size] = 6
default[:webapp][:passenger][:spawn_method] = 'smart'
default[:webapp][:passenger][:buffer_response] = 'off'
default[:webapp][:passenger][:min_instances] = 1
default[:webapp][:passenger][:max_instances_per_app] = 0
default[:webapp][:passenger][:pool_idle_time] = 300
default[:webapp][:passenger][:max_requests] = 0
# Add passenger config flag
override['nginx']['configure_flags'] = node.override['nginx']['configure_flags'] |
["--add-module=#{node[:webapp][:passenger][:root_path]}/ext/nginx"]
# Override values for nginx passenger.conf
override['nginx']['passenger']['root'] = node[:webapp][:passenger][:root_path]
override['nginx']['passenger']['ruby'] = node[:webapp][:passenger][:ruby_wrapper]
override['nginx']['passenger']['max_pool_size'] = node[:webapp][:passenger][:max_pool_size]
override['nginx']['passenger']['spawn_method'] = node[:webapp][:passenger][:spawn_method]
override['nginx']['passenger']['buffer_response'] = node[:webapp][:passenger][:buffer_response]
override['nginx']['passenger']['min_instances'] = node[:webapp][:passenger][:min_instances]
override['nginx']['passenger']['max_instances_per_app'] = node[:webapp][:passenger][:max_instances_per_app]
override['nginx']['passenger']['pool_idle_time'] = node[:webapp][:passenger][:pool_idle_time]
override['nginx']['passenger']['max_requests'] = node[:webapp][:passenger][:max_requests] webapp/attributes/._redis.rb 000644 000765 000024 00000000430 12263165751 016321 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/attributes/redis.rb 000644 000765 000024 00000002151 12263165751 016106 0 ustar 00drj staff 000000 000000 appdefs.redis.user = "redis_#{app.user.name}"
appdefs.redis.group = app.redis.user
redis_dir = "/var/run/redis/#{app.name}/redis_#{app.name}"
appdefs.redis.socket = "#{redis_dir}.sock"
appdefs.redis.port = 6379
appdefs.redis.pidfile = "#{redis_dir}.pid"
appdefs.redis.logfile = "/var/log/redis/redis_#{app.name}.log" # Set to nil to use syslog
appdefs.redis.syslogenabled = node[:application][:redis][:logfile] ? 'no' : 'yes'
appdefs.redis.monit.restart_cycles = 5
## Now, override redisio things with the attributes:
override['redisio']['version'] = app[:redis][:version] || '2.6.16'
override['redisio']['mirror'] = app[:redis][:mirror] || 'http://download.redis.io/releases'
override['redisio']['servers'] = [{
name: app.name,
user: app.redis.user,
group: app.redis.group,
homedir: "/var/lib/redis/#{app.name}",
datadir: "/var/lib/redis/#{app.name}/data",
logfile: app.redis.logfile,
syslogenabled: app.redis.syslogenabled,
port: app.redis.port, # TCP port and Unix socket are used
unixsocket: app.redis.socket,
unixsocketperm: '770'
}]
webapp/attributes/._rvm.rb 000644 000765 000024 00000000430 12263165751 016017 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/attributes/rvm.rb 000644 000765 000024 00000001160 12263165751 015603 0 ustar 00drj staff 000000 000000 # This is the app ruby version
appdefs[:ruby_version] = 'ruby-1.9.3-p484'
# These are the app's gems. Append by setting to node.default
appdefs[:gems] = %w( bundler rake )
# And finally, some overall (not per-app) RVM settings:
default[:webapp][:rvm][:common_pkgs] = %w( qt4-qmake libqt4-dev )
# This is the system-level (global) ruby. Each app can have its own as well.
default[:global_ruby_version] = 'ruby-2.0.0-p353'
### End of defaults for webapp::rvm. Overrides and such below:
override[:rvm][:default_ruby] = node[:global_ruby_version]
override[:rvm][:global_gems] = [
{ name: 'bundler' },
{ name: 'rake' }
]
webapp/attributes/._unicorn.rb 000644 000765 000024 00000000430 12263165751 016670 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/attributes/unicorn.rb 000644 000765 000024 00000000342 12263165751 016455 0 ustar 00drj staff 000000 000000 # NOTE: Cannot set to 'false' if you try to use any app stuff in unicorn.rb
appdefs.unicorn.preload = true
# Set the socket for unicorn app server
appdefs.unicorn.socket = "#{app.run_path}/#{app.name}.socket" webapp/._definitions 000755 000765 000024 00000000467 12263165751 014753 0 ustar 00drj staff 000000 000000 Mac OS X 2 7 ATTR 7 ˜ Ÿ ˜ Ÿ com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited,file_inherit,directory_inherit:read,execute,readattr,readextattr,readsecurity
webapp/definitions/ 000755 000765 000024 00000000000 12263165751 014601 5 ustar 00drj staff 000000 000000 webapp/definitions/._ensure_line.rb 000644 000765 000024 00000000430 12263165751 017650 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/definitions/ensure_line.rb 000644 000765 000024 00000000532 12263165751 017436 0 ustar 00drj staff 000000 000000 define :ensure_line, :content => nil do
filename = params[:name]
return unless params[:content] and params[:content].count("\n") == 0
safe_content = params[:content].sub("'", "\'")
bash "ensuring line in file '#{filename}'" do
code "echo '#{safe_content}' >> #{filename}"
not_if "grep '#{safe_content}' #{filename}"
end
end
webapp/definitions/._psql.rb 000644 000765 000024 00000000430 12263165751 016317 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/definitions/psql.rb 000644 000765 000024 00000001377 12263165751 016115 0 ustar 00drj staff 000000 000000 define :psql_create_user do
username = params[:name]
user_check = psql_query "select count(*) from pg_roles where rolname='#{username}'"
execute "create psql user '#{username}'" do
command "createuser -d -R -S #{username}"
only_if "test 0 -eq `#{ user_check }`", :user => 'postgres'
user "postgres"
end
end
define :psql_create_database, :owner => nil, :encoding => 'utf8' do
dbname = params[:name]
owner = params[:owner] or dbname
db_check = psql_query "select count(*) from pg_database where datname='#{dbname}'"
execute "create psql database '#{dbname}'" do
command "createdb -E #{params[:encoding]} -O #{owner} #{dbname}"
only_if "test 0 -eq `#{db_check}`", :user => 'postgres'
user "postgres"
end
end
webapp/._files 000755 000765 000024 00000000467 12263165751 013542 0 ustar 00drj staff 000000 000000 Mac OS X 2 7 ATTR 7 ˜ Ÿ ˜ Ÿ com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited,file_inherit,directory_inherit:read,execute,readattr,readextattr,readsecurity
webapp/files/ 000755 000765 000024 00000000000 12263165751 013370 5 ustar 00drj staff 000000 000000 webapp/files/._default 000755 000765 000024 00000000467 12263165751 015166 0 ustar 00drj staff 000000 000000 Mac OS X 2 7 ATTR 7 ˜ Ÿ ˜ Ÿ com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited,file_inherit,directory_inherit:read,execute,readattr,readextattr,readsecurity
webapp/files/default/ 000755 000765 000024 00000000000 12263165751 015014 5 ustar 00drj staff 000000 000000 webapp/files/default/._mime.conf 000644 000765 000024 00000000430 12263165751 017024 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/files/default/mime.conf 000644 000765 000024 00000000111 12263165751 016603 0 ustar 00drj staff 000000 000000 include mime.types;
default_type application/octet-stream; webapp/files/default/._mime.types 000644 000765 000024 00000000430 12263165751 017243 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/files/default/mime.types 000644 000765 000024 00000007245 12263165751 017041 0 ustar 00drj staff 000000 000000 ## NOTE: THIS FILE IS MANAGED BY CHEF. CHANGES TO THIS FILE WILL BE REMOVED THE NEXT CHEF RUN. IF
# YOU WISH TO MAKE A MODIFICATION, YOU SHOULD DO SO IN THE CHEF KITCHEN FOR THIS SERVER AND RUN:
# `amoeba node push --node <%= node[:name] %>`
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/x-javascript js;
application/json json;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg svgz;
image/webp webp;
application/java-archive jar war ear;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.ms-excel xls;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream eot;
application/octet-stream iso img;
application/octet-stream msi msp msm;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}
webapp/._libraries 000755 000765 000024 00000000467 12263165751 014414 0 ustar 00drj staff 000000 000000 Mac OS X 2 7 ATTR 7 ˜ Ÿ ˜ Ÿ com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited,file_inherit,directory_inherit:read,execute,readattr,readextattr,readsecurity
webapp/libraries/ 000755 000765 000024 00000000000 12263165751 014242 5 ustar 00drj staff 000000 000000 webapp/libraries/._init.rb 000644 000765 000024 00000000430 12263165751 015744 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/libraries/init.rb 000644 000765 000024 00000000666 12263165751 015542 0 ustar 00drj staff 000000 000000 def app; node.application end
def appdefs; default.application end
def app_init(c, *a)
"/bin/su #{app.user.name} -c '#{app.init_script} #{c} #{a.join ' '}'"
end
# Note: this must be called in recipe context
def service_commands(service_name, actions=%w(start stop))
service = @run_context.resource_collection.find(service: service_name)
Hash[actions.map {|a| ["#{a}_command", service.instance_variable_get("@#{a}_command")]}]
end
webapp/libraries/._psql.rb 000644 000765 000024 00000000430 12263165751 015760 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/libraries/psql.rb 000644 000765 000024 00000000166 12263165751 015551 0 ustar 00drj staff 000000 000000 def psql_query(sql)
fmt_opts = '-P format="unaligned" -P tuples_only="yes"'
%{ psql #{fmt_opts} -c "#{sql}" }
end
webapp/._metadata.json 000644 000765 000024 00000000430 12263166351 015150 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/metadata.json 000644 000765 000024 00000005121 12263166351 014735 0 ustar 00drj staff 000000 000000 {
"name": "webapp",
"description": "Deploy a web application (Ruby on Rails or NodeJS) using industry best practices. Used with Amoeba Deploy Tools.",
"long_description": "Webapp Cookbook\n===============\nThis cookbook is a set of best practices for deploying web applications. Currently this is mainly focused around Ruby on Rails, but with limited support in the works for Node. We assume that code will be deployed and managed with Capistrano.\n\nPart of the Amoeba Deploy Tools, this cookbook is used to rapidly build out a Ruby on Rails deployment in minutes. See Amoeba Deploy Tools for more information: http://github.com/AmoebaConsulting/amoeba-deploy-tools\n\n\nRequirements\n------------\nCurrently this is tested and works on Ubuntu 12.04 Server.\n\nYou must add the following to your Cookbooks manager. For Librarian Chef you can add the following\nto your `Cheffile`:\n\n```\ncookbook 'rvm', github: 'fnichol/chef-rvm'\ncookbook 'monit', github: 'phlipper/chef-monit'\ncookbook 'nginx', github: ''\n```\n\n\nAttributes\n----------\nTODO: List you cookbook attributes here.\n\ne.g.\n#### webapp::default\n\n \n Key | \n Type | \n Description | \n Default | \n
\n \n ['webapp']['bacon'] | \n Boolean | \n whether to include bacon | \n true | \n
\n
\n\nUsage\n-----\n#### webapp::default\nTODO: Write usage instructions for each cookbook.\n\ne.g.\nJust include `webapp` in your node's `run_list`:\n\n```json\n{\n \"name\":\"my_node\",\n \"run_list\": [\n \"recipe[webapp]\"\n ]\n}\n```\n\nContributing\n------------\nWe welcome contributions to the repo. Please follow a Github friendly process:\n\n1. Fork the repository on Github\n2. Create a named feature branch (like `add_component_x`)\n3. Write your change\n4. Write tests for your change (if applicable)\n5. Run the tests, ensuring they all pass\n6. Submit a Pull Request using Github\n\nLicense and Authors\n-------------------\nAuthors:\n * Daniel Jabbour [Amoeba Labs](http://amoe.ba)",
"maintainer": "Daniel Jabbour",
"maintainer_email": "sayhi@amoe.ba",
"license": "MIT",
"platforms": {
},
"dependencies": {
"nginx": "2.2.0",
"nodejs": "~> 1.3.0",
"postgresql": "~> 3.3.4",
"redisio": "~> 1.7.0",
"rvm": "~> 0.9.1",
"monit": "~> 1.5.0"
},
"recommendations": {
},
"suggestions": {
},
"conflicting": {
},
"providing": {
},
"replacing": {
},
"attributes": {
},
"groupings": {
},
"recipes": {
"webapp": "Default webapp recipe"
},
"version": "0.1.1"
} webapp/._metadata.rb 000644 000765 000024 00000000430 12263165751 014605 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/metadata.rb 000644 000765 000024 00000001563 12263165751 014400 0 ustar 00drj staff 000000 000000 name "webapp"
maintainer "Daniel Jabbour"
maintainer_email "sayhi@amoe.ba"
license "MIT"
description "Deploy a web application (Ruby on Rails or NodeJS) using industry best practices. Used with Amoeba Deploy Tools."
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.1.0"
recipe "webapp", "Default webapp recipe"
depends 'nginx', '2.2.0' # Fixed at 2.2.0 release since we're overriding it a bit
depends 'nodejs', '~> 1.3.0'
depends 'postgresql', '~> 3.3.4'
depends 'redisio', '~> 1.7.0'
# Note: These deps come from Github, and must be imported via your Cheffile (versions fixed to
# ensure Github version is used or a warning is thrown)
depends 'rvm', '~> 0.9.1' # must use version from github: 'fnichol/chef-rvm'
depends 'monit', '~> 1.5.0' # must use version from github: 'phlipper/chef-monit' webapp/._recipes 000755 000765 000024 00000000467 12263165751 014072 0 ustar 00drj staff 000000 000000 Mac OS X 2 7 ATTR 7 ˜ Ÿ ˜ Ÿ com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited,file_inherit,directory_inherit:read,execute,readattr,readextattr,readsecurity
webapp/recipes/ 000755 000765 000024 00000000000 12263165751 013720 5 ustar 00drj staff 000000 000000 webapp/recipes/._capistrano.rb 000644 000765 000024 00000000430 12263165751 016622 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/recipes/capistrano.rb 000644 000765 000024 00000000710 12263165751 016406 0 ustar 00drj staff 000000 000000 # Prepare dirs for capistrano deployment, similar to running `cap deploy:setup`
directory app.path do
owner app.user.name
group app.user.group
mode 0755
end
[app.releases_path, app.shared_path, app.log_path, app.system_path, app.run_path].each do |dir|
directory dir do
owner app.user.name
group app.user.group
mode 0775
end
end
directory app.config_path do
owner app.user.name
group app.user.group
mode 0700
end webapp/recipes/._cron.rb 000644 000765 000024 00000000430 12263165751 015420 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/recipes/cron.rb 000644 000765 000024 00000000730 12263165751 015206 0 ustar 00drj staff 000000 000000 app.crontab.each do |c|
cron "#{app.name}-#{c.name}" do
user app.user.name
if c[:action] && c[:action].to_sym == :delete
action :delete
else
command "bash -c 'source #{app.user.home}/.rvm/scripts/rvm; cd #{app.current_path}; bundle exec #{c.command} >> #{app.log_path}/cron.log 2>&1'"
environment app.env_vars
for k, v in c
next if [:command, :name].include?(k.to_sym)
send(k.to_sym, v)
end
end
end
end
webapp/recipes/._db.rb 000644 000765 000024 00000000430 12263165751 015044 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/recipes/db.rb 000644 000765 000024 00000001723 12263165751 014635 0 ustar 00drj staff 000000 000000 db_conf = Hash[app.database]
db_conf.delete 'environments'
db_conf['database'] = db_conf.delete 'name'
db_type = db_conf.delete('type').downcase
# create database user
case db_type
when /^postgres/
if %w(localhost 127.0.0.1).include? app.database.host
db_conf.delete 'host'
end
include_recipe 'postgresql::server'
psql_create_user app.user.name
psql_create_database app.database.name do
owner app.user.name
end
else
raise "You must specify a valid database type in your application config"
end
# Ensure monit has a monitor of the DB
template "/etc/monit/conf.d/#{db_type}.conf" do
source "monit/#{db_type}.conf.erb"
owner 'root'
group 'root'
mode 0644
notifies :reload, 'service[monit]', :delayed
end
file "#{app.config_path}/database.yml" do
owner app.user.name
group app.user.group
mode 0600
content YAML.dump(Hash[app.database.environments.map {|env, conf| [env, db_conf.merge(conf).to_hash] }])
end
webapp/recipes/._default.rb 000644 000765 000024 00000000430 12263165751 016103 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/recipes/default.rb 000644 000765 000024 00000001323 12263165751 015670 0 ustar 00drj staff 000000 000000 # Create app user
user app.user.name do
comment "#{app.name} app user"
shell "/bin/bash"
home app.user.home
supports :manage_home => true
end
# RVM should come first
include_recipe 'webapp::rvm'
# Then the app type
case app.type.downcase
when 'rails', 'passenger'
include_recipe 'webapp::passenger'
when 'unicorn'
raise "Unicorn support not yet implemented"
when 'nodejs'
raise "NodeJS support not yet implemented"
else
raise "You must specify an application type (hint: passenger, unicorn, nodejs, and so forth)"
end
# Followed by nginx and others
%w( nginx capistrano cron ).each do |r|
include_recipe "webapp::#{r}"
end
if app.database
include_recipe "webapp::db"
end
webapp/recipes/._javascript.rb 000644 000765 000024 00000000430 12263165751 016625 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/recipes/javascript.rb 000644 000765 000024 00000000132 12263165751 016407 0 ustar 00drj staff 000000 000000 include_recipe 'nodejs'
execute 'sudo npm install -g bower' do
not_if 'which bower'
end webapp/recipes/._nginx.rb 000644 000765 000024 00000000430 12263165751 015602 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/recipes/nginx.rb 000644 000765 000024 00000001714 12263165751 015373 0 ustar 00drj staff 000000 000000 include_recipe 'webapp::nginx_source'
if app[:nginx][:enabled]
service "nginx" do
action :start
end
else
service "nginx" do
action :stop
end
service "nginx" do
action :disable
end
end
# Can't force ssl w/o ssl
if app.ssl.force && !app.ssl.enabled
raise "Can't force ssl in your application if ssl is not enabled!"
end
# site nginx config which goes into sites-available/
template "#{node[:nginx][:dir]}/sites-available/#{app.name}.conf" do
source "nginx.site.conf.erb"
notifies :reload, resources(:service => "nginx")
end
nginx_site "#{app.name}.conf"
if app[:http_auth]
package "apache2-utils"
htpasswd "#{node[:nginx][:dir]}/htpasswd" do
user app.http_auth.user
password app.http_auth.password
end
end
# Finally ensure monit has a nginx config
template "/etc/monit/conf.d/nginx.conf" do
source 'monit/nginx.conf.erb'
owner 'root'
group 'root'
mode 0644
notifies :reload, 'service[monit]', :delayed
end
webapp/recipes/._nginx_source.rb 000644 000765 000024 00000000430 12263165751 017162 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/recipes/nginx_source.rb 000644 000765 000024 00000006711 12263165751 016755 0 ustar 00drj staff 000000 000000 require 'digest/sha1'
#include_recipe 'nginx::source' (not working due to ohai plugin and chef 11)
# Grabbing most of the cookbook of nginx::source here, and including the parts that I can
#
nginx_url = node['nginx']['source']['url'] ||
"http://nginx.org/download/nginx-#{node['nginx']['source']['version']}.tar.gz"
node.set['nginx']['binary'] = node['nginx']['source']['sbin_path']
node.set['nginx']['daemon_disable'] = true
include_recipe 'nginx::commons_dir'
include_recipe 'nginx::commons_script'
include_recipe 'build-essential::default'
src_filepath = "#{Chef::Config['file_cache_path'] || '/tmp'}/nginx-#{node['nginx']['source']['version']}.tar.gz"
packages = %w(libpcre3 libpcre3-dev libssl-dev)
packages.each do |name|
package name
end
remote_file nginx_url do
source nginx_url
checksum node['nginx']['source']['checksum']
path src_filepath
backup false
end
node.run_state['nginx_force_recompile'] = false
node.run_state['nginx_configure_flags'] =
node['nginx']['source']['default_configure_flags'] | node['nginx']['configure_flags']
include_recipe 'nginx::commons_conf'
cookbook_file "#{node['nginx']['dir']}/mime.types" do
source 'mime.types'
owner 'root'
group 'root'
mode '0644'
notifies :reload, 'service[nginx]'
end
# Unpack downloaded source so we could apply nginx patches
# in custom modules - example http://yaoweibin.github.io/nginx_tcp_proxy_module/
# patch -p1 < /path/to/nginx_tcp_proxy_module/tcp.patch
bash 'unarchive_source' do
cwd ::File.dirname(src_filepath)
code <<-EOH
tar zxf #{::File.basename(src_filepath)} -C #{::File.dirname(src_filepath)}
EOH
not_if { ::File.directory?("#{Chef::Config['file_cache_path'] || '/tmp'}/nginx-#{node['nginx']['source']['version']}") }
end
node['nginx']['source']['modules'].each do |ngx_module|
include_recipe ngx_module
end
# Calculate the version information (based on version number and compile flags)
configure_flags = node.run_state['nginx_configure_flags']
version_info = node['nginx']['source']['version'].to_s + ' ' + configure_flags.sort.join(' ')
version_info = Digest::SHA1.hexdigest(version_info)
previous_version_info = ''
if ::File.exist?('/etc/nginx/version-info')
previous_version_info = ::File.read('/etc/nginx/version-info').chomp
end
rvm_shell 'compile_nginx_source' do
ruby_string node[:global_ruby_version]
cwd ::File.dirname(src_filepath)
code <<-EOH
cd nginx-#{node['nginx']['source']['version']} &&
./configure #{node.run_state['nginx_configure_flags'].join(" ")} &&
make && make install
EOH
not_if do
# Check the version-info file, if it matches our current version_info, don't bother compiling
version_info == previous_version_info
end
notifies :restart, 'service[nginx]'
end
## Upstart init
# we rely on this to set up nginx.conf with daemon disable instead of doing
# it in the upstart init script.
node.set['nginx']['daemon_disable'] = node['nginx']['upstart']['foreground']
template '/etc/init/nginx.conf' do
source 'nginx-upstart.conf.erb'
owner 'root'
group 'root'
mode '0644'
end
service 'nginx' do
provider Chef::Provider::Service::Upstart
supports :status => true, :restart => true, :reload => true
action :nothing
end
node.run_state.delete('nginx_configure_flags')
node.run_state.delete('nginx_force_recompile')
# Write out a hash to determine if we need to recompile later
file '/etc/nginx/version-info' do
owner 'root'
group 'root'
mode '0644'
content version_info
end
webapp/recipes/._passenger.rb 000644 000765 000024 00000000430 12263165751 016446 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/recipes/passenger.rb 000644 000765 000024 00000001156 12263165751 016237 0 ustar 00drj staff 000000 000000 node[:webapp][:passenger][:common_pkgs].each do |p|
package p
end
# Installs passenger into the specified ruby (usually the system ruby), which
# can be different than the ruby version of the application itself.
rvm_gem 'passenger' do
ruby_string node[:webapp][:passenger][:ruby]
version node[:webapp][:passenger][:version]
end
# Ensure nginx is loaded before continuing
include_recipe 'webapp::nginx'
template "#{node["nginx"]["dir"]}/conf.d/passenger.conf" do
source 'modules/passenger.conf.erb'
cookbook 'nginx'
owner 'root'
group 'root'
mode '0644'
notifies :reload, 'service[nginx]'
end
webapp/recipes/._redis.rb 000644 000765 000024 00000000430 12263165751 015565 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/recipes/redis.rb 000644 000765 000024 00000001453 12263165751 015356 0 ustar 00drj staff 000000 000000 # Ensure the top-level directory exists for redis' user homes
directory '/var/lib/redis' do
user 'root'
group 'root'
mode 0755
end
directory '/var/log/redis' do
user 'root'
group 'root'
mode 0755
end
%w(redisio::install redisio::enable).each do |r|
include_recipe r
end
redis_commands = service_commands("redis#{app.name}")
link "#{app.run_path}/redis.sock" do
to app.redis.socket
owner app.user.name
group app.user.group
end
group app.redis.group do
action :modify
members app.user.name
append true
end
process_name = "#{app.name}_redis"
template "/etc/monit/conf.d/#{process_name}.conf" do
source 'monit/redis.conf.erb'
owner 'root'
group 'root'
mode 0644
variables redis_commands.merge(process_name: process_name)
notifies :reload, 'service[monit]', :delayed
end
webapp/recipes/._rvm.rb 000644 000765 000024 00000000430 12263165751 015263 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/recipes/rvm.rb 000644 000765 000024 00000001351 12263165751 015051 0 ustar 00drj staff 000000 000000 node[:webapp][:rvm][:common_pkgs].each do |p|
package p
end
node.override.rvm.user_installs = [{
'user' => app.user.name,
'home' => app.user.home,
'default_ruby' => app.ruby_version,
'rvmrc' => {
'rvm_project_rvmrc' => 1,
'rvm_trust_rvmrcs_flag' => 1
},
'global_gems' => [
{ 'name' => 'rubygems-bundler',
'action' => 'remove'
}
] + app.gems.map {|g| { 'name' => g } }
}]
include_recipe 'rvm::system'
include_recipe 'rvm::user'
rvm_script = '$HOME/.rvm/scripts/rvm'
ensure_line "#{app.user.home}/.bashrc" do
content %{[[ -s "#{rvm_script}" ]] && source "#{rvm_script}"}
end
ensure_line "#{app.user.home}/.bashrc" do
content %{export PATH=$PATH:$HOME/.rvm/bin}
end
webapp/recipes/._ssh.rb 000644 000765 000024 00000000430 12263165751 015254 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/recipes/ssh.rb 000644 000765 000024 00000000311 12263165751 015035 0 ustar 00drj staff 000000 000000 # Generate ssh key-pair
generate_keys do
user app.user.name
home app.user.home
end
# Setup ~/.ssh/authorized_keys file
authorized_keys do
user app.user.name
home app.user.home
end
webapp/._templates 000755 000765 000024 00000000467 12263165751 014436 0 ustar 00drj staff 000000 000000 Mac OS X 2 7 ATTR 7 ˜ Ÿ ˜ Ÿ com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited,file_inherit,directory_inherit:read,execute,readattr,readextattr,readsecurity
webapp/templates/ 000755 000765 000024 00000000000 12263165751 014264 5 ustar 00drj staff 000000 000000 webapp/templates/._default 000755 000765 000024 00000000467 12263165751 016062 0 ustar 00drj staff 000000 000000 Mac OS X 2 7 ATTR 7 ˜ Ÿ ˜ Ÿ com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited,file_inherit,directory_inherit:read,execute,readattr,readextattr,readsecurity
webapp/templates/default/ 000755 000765 000024 00000000000 12263165751 015710 5 ustar 00drj staff 000000 000000 webapp/templates/default/._.gitkeep 000644 000765 000024 00000000430 12263165751 017553 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/templates/default/.gitkeep 000644 000765 000024 00000000000 12263165751 017327 0 ustar 00drj staff 000000 000000 webapp/templates/default/._monit 000755 000765 000024 00000000467 12263165751 017210 0 ustar 00drj staff 000000 000000 Mac OS X 2 7 ATTR 7 ˜ Ÿ ˜ Ÿ com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited,file_inherit,directory_inherit:read,execute,readattr,readextattr,readsecurity
webapp/templates/default/monit/ 000755 000765 000024 00000000000 12263165751 017036 5 ustar 00drj staff 000000 000000 webapp/templates/default/._nginx-upstart.conf.erb 000644 000765 000024 00000000430 12263165751 022363 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/templates/default/nginx-upstart.conf.erb 000644 000765 000024 00000002425 12263165751 022154 0 ustar 00drj staff 000000 000000 ## NOTE: THIS FILE IS MANAGED BY CHEF. CHANGES TO THIS FILE WILL BE REMOVED THE NEXT CHEF RUN. IF
# YOU WISH TO MAKE A MODIFICATION, YOU SHOULD DO SO IN THE CHEF KITCHEN FOR THIS SERVER AND RUN:
# `amoeba node push --node <%= node[:name] %>`
description "nginx http daemon"
start on (local-filesystems and net-device-up IFACE=lo and runlevel [<%= node['nginx']['upstart']['runlevels'] %>])
stop on runlevel [!<%= node['nginx']['upstart']['runlevels'] %>]
env DAEMON=<%= node['nginx']['binary'] %>
env PID=<%= node['nginx']['pid'] %>
env CONFIG=<%= node['nginx']['source']['conf_path'] %>
respawn
<% if node['nginx']['upstart']['respawn_limit'] %>
respawn limit <%= node['nginx']['upstart']['respawn_limit'] %>
<% end %>
pre-start script
${DAEMON} -t
if [ $? -ne 0 ]; then
exit $?
fi
end script
<% unless node['nginx']['upstart']['foreground'] %>
expect fork
<% else %>
console output
<% end %>
exec ${DAEMON} -c "${CONFIG}"
<% if node.recipe?('nginx::passenger') and not node['nginx']['upstart']['foreground'] %>
# classic example of why pidfiles should have gone away
# with the advent of fork(). we missed that bus a long
# time ago so hack around it.
post-stop script
start-stop-daemon --stop --pidfile ${PID} --name nginx --exec ${DAEMON} --signal QUIT
end script
<% end %>
webapp/templates/default/._nginx.site.conf.erb 000644 000765 000024 00000000430 12263165751 021626 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/templates/default/nginx.site.conf.erb 000644 000765 000024 00000005612 12263165751 021420 0 ustar 00drj staff 000000 000000 ## NOTE: THIS FILE IS MANAGED BY CHEF. CHANGES TO THIS FILE WILL BE REMOVED THE NEXT CHEF RUN. IF
# YOU WISH TO MAKE A MODIFICATION, YOU SHOULD DO SO IN THE CHEF KITCHEN FOR THIS SERVER AND RUN:
# `amoeba node push --node <%= node[:name] %>`
<% if app[:type].match /unicorn/i %>
# Listen on Application Socket
upstream <%= app[:name] %> {
server unix:<%= app[:socket] %> fail_timeout=0;
}
<% end %>
<% if app.redirect_urls.length > 0 %>
# Redirect URL Aliases
<% app.redirect_urls.each do |url| %>
server {
listen 80;
server_name <%= url %>;
return 301 http://<%= app.url %>$request_uri;
}
<% end; end %>
<% if node[:application][:ssl][:force] %>
# Force SSL for this application
server {
server_name <%= app.url %>;
listen 80;
return 301 https://$host$request_uri;
}
<% end %>
# Serve Application
server {
<% if app[:type].match /(passenger|rails)/i %>
# Application Server Config (Passenger)
passenger_ruby <%= node[:application][:ruby_version] %>;
passenger_app_env <%= node[:application][:environment] %>;
passenger_enabled on;
<% end %>
# Some sensible defaults for a Web Application server
listen 80;
underscores_in_headers on;
sendfile on;
gzip on;
keepalive_timeout <%= node[:application][:nginx][:keepalive_timeout] %>;
# Main URL
server_name <%= app.url %>;
# Alias URLs
<% app.alias_urls.each do |url| %>
server_name <%= url %>;
<% end %>
<% if node[:application][:ssl][:enabled] %>
# Also some SSL directives:
listen 443 ssl;
ssl_certificate /etc/ssl/public/<%= node[:application][:ssl][:cert_name] %>-chained.pem;
ssl_certificate_key /etc/ssl/private/<%= node[:application][:ssl][:cert_name] %>.key;
<% end %>
# Serve static files
root <%= app.static_path %>;
# Error pages
error_page 500 502 503 504 /500.html;
error_page 422 /422.html;
error_page 404 /404.html;
<% if app[:type].match /unicorn/i %>
location / {
try_files $uri @app;
}
# Proxy to app via unix socket
location @app {
proxy_pass http://<%= app.name %>;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
<% end %>
<% if app[:http_auth] %>
location <%= app.http_auth.realm %> {
auth_basic "Restricted";
auth_basic_user_file htpasswd;
}
<% app.http_auth.exclude.each do |exclude_url| %>
location <%= exclude_url %> {
auth_basic off;
}
<% end; end %>
}
webapp/templates/default/monit/._nginx.conf.erb 000644 000765 000024 00000000430 12263165751 022011 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/templates/default/monit/nginx.conf.erb 000644 000765 000024 00000001104 12263165751 021573 0 ustar 00drj staff 000000 000000 ## NOTE: THIS FILE IS MANAGED BY CHEF. CHANGES TO THIS FILE WILL BE REMOVED THE NEXT CHEF RUN. IF
# YOU WISH TO MAKE A MODIFICATION, YOU SHOULD DO SO IN THE CHEF KITCHEN FOR THIS SERVER AND RUN:
# `amoeba node push --node <%= node[:name] %>`
check process nginx with pidfile <%= node[:nginx][:pid] %>
start program = "/usr/sbin/service nginx start"
stop program = "/usr/sbin/service nginx stop"
if children > <%= node[:webapp][:nginx][:monit][:max_children] %> then restart
if 5 restarts within <%= node[:webapp][:nginx][:monit][:restart_cycles] %> cycles then timeout
webapp/templates/default/monit/._postgresql.conf.erb 000644 000765 000024 00000000430 12263165751 023071 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/templates/default/monit/postgresql.conf.erb 000644 000765 000024 00000001144 12263165751 022657 0 ustar 00drj staff 000000 000000 ## NOTE: THIS FILE IS MANAGED BY CHEF. CHANGES TO THIS FILE WILL BE REMOVED THE NEXT CHEF RUN. IF
# YOU WISH TO MAKE A MODIFICATION, YOU SHOULD DO SO IN THE CHEF KITCHEN FOR THIS SERVER AND RUN:
# `amoeba node push --node <%= node[:name] %>`
check process postgresql with pidfile <%= node[:postgresql][:config][:external_pid_file] %>
start program = "/usr/sbin/service postgresql start"
stop program = "/usr/sbin/service postgresql stop"
if failed host localhost port 5432 protocol pgsql then restart
if 5 restarts within <%= node[:webapp][:postgresql][:monit][:restart_cycles] %> cycles then timeout webapp/templates/default/monit/._redis.conf.erb 000644 000765 000024 00000000430 12263165751 021774 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/templates/default/monit/redis.conf.erb 000644 000765 000024 00000001415 12263165751 021563 0 ustar 00drj staff 000000 000000 ## NOTE: THIS FILE IS MANAGED BY CHEF. CHANGES TO THIS FILE WILL BE REMOVED THE NEXT CHEF RUN. IF
# YOU WISH TO MAKE A MODIFICATION, YOU SHOULD DO SO IN THE CHEF KITCHEN FOR THIS SERVER AND RUN:
# `amoeba node push --node <%= node[:name] %>`
check process <%= @process_name %>
with pidfile <%= app.redis.pidfile %>
start program = "<%= @start_command %>" with timeout 60 seconds
stop program = "<%= @stop_command %>"
if failed unixsocket <%= app.redis.socket %> then restart
if failed host 127.0.0.1 port <%= app.redis.port %> then restart
if failed unixsocket <%= app.redis.socket %> then alert
if failed host 127.0.0.1 port <%= app.redis.port %> then alert
if 5 restart within <%= app.redis.monit.restart_cycles %> cycles then timeout
group <%= app.name %>
webapp/templates/default/monit/._unicorn.conf.erb 000644 000765 000024 00000000430 12263165751 022343 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/templates/default/monit/unicorn.conf.erb 000644 000765 000024 00000000743 12263165751 022135 0 ustar 00drj staff 000000 000000 ## NOTE: THIS FILE IS MANAGED BY CHEF. CHANGES TO THIS FILE WILL BE REMOVED THE NEXT CHEF RUN. IF
# YOU WISH TO MAKE A MODIFICATION, YOU SHOULD DO SO IN THE CHEF KITCHEN FOR THIS SERVER AND RUN:
# `amoeba node push --node <%= node[:name] %>`
check process <%= app.name %>_unicorn
with pidfile <%= app.run_path %>/unicorn.pid
start program = "<%= app_init :upgrade %>"
stop program = "<%= app_init :stop %>"
if failed unixsocket <%= app.socket %> then start
group <%= app.name %>
webapp/templates/default/monit/._unicorn_worker.conf.erb 000644 000765 000024 00000000430 12263165751 023734 0 ustar 00drj staff 000000 000000 Mac OS X 2 æ ATTR ˜ € ˜ € com.apple.acl.text !#acl 1
user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000059:_spotlight:89:allow,inherited:read,execute,readattr,readextattr,readsecurity
webapp/templates/default/monit/unicorn_worker.conf.erb 000644 000765 000024 00000000720 12263165751 023521 0 ustar 00drj staff 000000 000000 ## NOTE: THIS FILE IS MANAGED BY CHEF. CHANGES TO THIS FILE WILL BE REMOVED THE NEXT CHEF RUN. IF
# YOU WISH TO MAKE A MODIFICATION, YOU SHOULD DO SO IN THE CHEF KITCHEN FOR THIS SERVER AND RUN:
# `amoeba node push --node <%= node[:name] %>`
check process <%= app.name %>_unicorn_worker_<%= @worker_id %>
with pidfile <%= app.run_path %>/unicorn.<%= @worker_id %>.pid
stop program = "<%= app_init :kill_worker, @worker_id %>"
mode passive
group <%= app.name %>