capistrano-deploy-recipes 0.1.1 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YzU4MzE0ZDg4YTMyZjgyZGFhZTZlZjUzZGM5MTM5ZGE3MTY1MjUzNg==
5
- data.tar.gz: !binary |-
6
- YzNlMjc1MGE5N2Y1ZmVmZjhjYjY5Yjk5MzhkOTc2NzFmYjkzYzVkMg==
2
+ SHA1:
3
+ metadata.gz: 78ae7e3370518c1e4b97ed60c9599c0ec75dbdb9
4
+ data.tar.gz: ed8d9c11c2b0683075fe932e1cd9c70e36d5e370
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MGZjZWM5YjE3YjYyNzhlODViYTEzZDQ5ZDU2NDczNjdkMmNiYWU3YWMxZjY5
10
- N2YzZjVhOThjNzRlZTZlOTAyZWM0NjQ3NzJlYTJiZjZmMjE5ZTgzYjU4NmYx
11
- MGIwY2ViNGQxMzAzMzNjMmU0NjZmZGZlZDkyY2FiYTYxM2ViYjA=
12
- data.tar.gz: !binary |-
13
- YTdjZDdlYTRiMDFiMzlkOTEzOGU4MTQxZjBkOThkYzU0YTc0MDczOGM3NWVm
14
- YWYxYTk1NjVkZGQyNWQ4NmRmMTBhYzVlODIzZDg0Yzk0NzIxNjk4ZTk3MTM2
15
- NWE2ZTlkYWM1NTMzMzQyOTQ0NTBmZjc0OTkyNDM0ZmZkYjJiMGQ=
6
+ metadata.gz: c52932e34d17c1ced74939fa31256b44ada1f0017a38ef4712c7ee7ad1359602769696324eeecb74f141d98117a6617365e55713d0cc64feed4eee7511fbcf40
7
+ data.tar.gz: d53667cc49576763e412091e1e508f67186d21a98f248df5d2ef3a294229ab4d14d79e75803023c949be2d7534d1d26b94dfab8ac9a4eaf60d70eae71ac73d3c
data/.gitignore CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/Gemfile.lock CHANGED
File without changes
data/LICENSE.md CHANGED
File without changes
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- > NOTICE: we are on the early stages. Nothing is working properly yet ;)
1
+ > NOTICE: we are on the early stages. ;)
2
2
 
3
3
  # Capistrano Deploy Recipes
4
4
 
5
- Just a bunch of usefull Capistrano V3 deploy recipes.
5
+ Just a bunch of useful Capistrano V3 deploy recipes.
6
6
 
7
7
  ## The need
8
8
 
@@ -11,14 +11,14 @@ and we would be so happy if all the dependencies (ruby, unicorn, nginx,
11
11
  postgres and so on) get installed by Capistrano.
12
12
 
13
13
  To make the stack deploy easier we can use a base image for the machines
14
- (which, by the way, we do have) or use tools like [Puppet][0] and [Cheff][1]
14
+ (which, by the way, we do have) or use tools like [Puppet][0] and [Chef][1]
15
15
  or services like [configr][2]. Those options are great and will fit for
16
16
  many situations, but (there is always a but)...
17
17
 
18
18
  But sometimes wouldn't it be lovely if a simple `cap production deploy`
19
19
  solve it all?
20
20
 
21
- Whatching [RailsCast episode 337][3], Ryan Bates showed a simple way
21
+ Watching [RailsCast episode 337][3], Ryan Bates showed a simple way
22
22
  to achieve that.
23
23
 
24
24
  Googling around we found some gems that seems to do that, but they dont
@@ -39,17 +39,31 @@ Add on your `Capfile` file the recipes you want to use
39
39
 
40
40
  ```ruby
41
41
  require 'recipes/ruby'
42
+ require 'recipes/nodejs'
42
43
  require 'recipes/nginx'
43
- require 'recipes/unicorn'
44
44
  require 'recipes/postgres'
45
45
  ```
46
46
 
47
47
  > Those requires must go inside `Capfile` and not on `deploy.rb`
48
48
 
49
- To discover a list of all the avaiable recipes just type:
49
+ Then on the shell just call
50
50
 
51
+ ```bash
52
+ cap production recipes:install recipes:setup
51
53
  ```
52
- bundle exec cap recipes:list
54
+
55
+ It will install all the selected packages and then run extra configurations when needed on the setup phase.
56
+
57
+ You can also see and invoke just the tasks you want using `cap -T`.
58
+
59
+ Some tasks have also other features like `nginx` which have this options:
60
+
61
+ ```
62
+ cap nginx:install # Install the latest stable release of nginx
63
+ cap nginx:restart # Restart nginx
64
+ cap nginx:setup # Setup nginx configuration for this application
65
+ cap nginx:start # Start nginx
66
+ cap nginx:stop # Stop nginx
53
67
  ```
54
68
 
55
69
  ## Contributing
@@ -80,7 +94,7 @@ included in all copies or substantial portions of the Software.
80
94
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
81
95
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
82
96
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
83
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
97
+ NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
84
98
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
85
99
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
86
100
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
File without changes
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "capistrano-deploy-recipes"
7
- gem.version = '0.1.1'
7
+ gem.version = '0.1.5'
8
8
  gem.authors = ["Adilson Carvalho"]
9
9
  gem.email = ["lc.adilson@gmail.com"]
10
10
  gem.description = %q{Capistrano fullstack deploy recipes}
data/lib/recipes.rb CHANGED
@@ -1,6 +1,29 @@
1
+ require 'sshkit_extensions'
2
+
1
3
  namespace :recipes do
2
- desc "List all known recipes"
3
- task :list do
4
- raise 'Not implemented'
4
+ desc "Install selected recipes on remote server"
5
+ task :install do
6
+ on roles(:all) do
7
+ as :root do
8
+ aptitude :update
9
+ aptitude %w{
10
+ software-properties-common python-software-properties curl wget git
11
+ }
12
+ end
13
+ end
5
14
  end
15
+
16
+ desc "Setup selected recipes on remote server"
17
+ task :setup do
18
+ # no actual action happens here
19
+ end
20
+ end
21
+
22
+ def needs_implementation
23
+ puts "Needs to be implemented +_+"
24
+ end
25
+
26
+ # Keeps only a..zA..Z0..9_
27
+ def application
28
+ @application ||= fetch(:application).gsub(/\W/,'')
6
29
  end
@@ -0,0 +1,53 @@
1
+ require 'recipes'
2
+
3
+ namespace :nginx do
4
+
5
+ desc "Install the latest stable release of nginx"
6
+ task :install do
7
+ on roles(:web) do
8
+ as :root do
9
+ aptitude %w{install -y nginx}
10
+ execute 'update-rc.d', %w{nginx defaults}
11
+ end
12
+ end
13
+ end
14
+ after "recipes:install", "nginx:install"
15
+
16
+ desc "Setup nginx configuration for this application"
17
+ task :setup do
18
+ temp_file = "#{fetch :tmp_dir}/#{fetch :application}"
19
+ sites_available = "/etc/nginx/sites-available/#{fetch :application}"
20
+ sites_enabled = "/etc/nginx/sites-enabled/#{fetch :application}"
21
+
22
+ on roles(:web) do
23
+ as :root do
24
+ erb = File.read(File.expand_path("../../templates/nginx_unicorn.erb", __FILE__))
25
+ upload! StringIO.new(ERB.new(erb).result(binding)), temp_file
26
+ execute :chown, 'root:', temp_file
27
+ execute :chmod, 'a+r', temp_file
28
+ execute :mv, temp_file, sites_available
29
+
30
+ # link creation from sites-available ~> sites-enabled
31
+ if test("[ -f #{sites_enabled} ]")
32
+ execute :rm, sites_enabled
33
+ end
34
+ execute :ln, '--symbolic', sites_available, sites_enabled
35
+
36
+ info "Generated nginx site configuration at /etc/nginx/sites-available/#{fetch(:application)}"
37
+ end
38
+ end
39
+ end
40
+ after "recipes:setup", "nginx:setup"
41
+
42
+ %w{start stop restart}.each do |command|
43
+ desc "#{command.capitalize} nginx"
44
+ task command do
45
+ on roles(:web) do
46
+ as :root do
47
+ service 'nginx', command
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,26 @@
1
+ require 'recipes'
2
+
3
+ namespace :nodejs do
4
+
5
+ desc "Install the latest stable version of NodeJS"
6
+ task :install do
7
+ on roles(:app) do
8
+ as :root do
9
+ # dependencies
10
+ aptitude %w{
11
+ install -y software-properties-common
12
+ python-software-properties python g++ make
13
+ }
14
+
15
+ # adding repo with the latest stable version
16
+ execute 'add-apt-repository', 'ppa:chris-lea/node.js'
17
+ aptitude :update
18
+
19
+ # installing nodejs
20
+ aptitude %w{ install -y nodejs }
21
+ end
22
+ end
23
+ end
24
+ after "recipes:install", "nodejs:install"
25
+
26
+ end
@@ -0,0 +1,34 @@
1
+ require 'recipes'
2
+
3
+ namespace :postgres do
4
+
5
+ desc "Install the latest stable release of postgres"
6
+ task :install do
7
+ on roles(:db), only: { primary: true } do
8
+ as :root do
9
+ execute 'add-apt-repository', 'ppa:pitti/postgresql'
10
+ aptitude %w{ -y update }
11
+ aptitude %w{ -y install postgresql-9.3 postgresql-contrib-9.3 postgresql-client-9.3 libpq-dev postgresql-server-dev-9.3 }
12
+ end
13
+ end
14
+ end
15
+ after "recipes:install", "postgres:install"
16
+
17
+ desc "Setup postgres configuration for this application"
18
+ task :setup do
19
+ needs_implementation
20
+ end
21
+ after "recipes:setup", "postgres:setup"
22
+
23
+ %w{start stop restart status}.each do |command|
24
+ desc "#{command.capitalize} postgres"
25
+ task command do
26
+ on roles(:db) do
27
+ as :root do
28
+ service 'postgresql', command
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,53 @@
1
+ require 'recipes'
2
+
3
+ set :ruby_version, '2.1.1'
4
+
5
+ namespace :ruby do
6
+
7
+ desc "Installs ruby #{fetch :ruby_version}"
8
+ task :install do
9
+ on roles(:app, :web) do
10
+ as :root do
11
+ # update de package manager
12
+ aptitude :update
13
+
14
+ # installation task dependencies
15
+ aptitude %w{ install -y wget }
16
+
17
+ # ruby dependencies
18
+ aptitude %w{
19
+ install -y build-essential openssl libreadline6 libreadline6-dev
20
+ zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt1-dev
21
+ autoconf libc6-dev libncurses5-dev automake libtool bison libffi-dev
22
+ imagemagick
23
+ }
24
+
25
+ # acquiring ruby
26
+ within '/tmp' do
27
+ ruby_major = fetch(:ruby_version).scan(/^\d+\.\d+/).first
28
+ ruby_version = "ruby-#{fetch :ruby_version}"
29
+
30
+ execute :wget, %W{ --quiet http://cache.ruby-lang.org/pub/ruby/#{ruby_major}/#{ruby_version}.tar.gz }
31
+ execute :tar, 'xf', "#{ruby_version}.tar.gz"
32
+
33
+ # building and installing it
34
+ within ruby_version do
35
+ execute './configure'
36
+ execute :make
37
+ execute :make, 'install'
38
+ end
39
+
40
+ # updating rubygems
41
+ execute :gem, %w{ update --system }
42
+
43
+ # removing temporary files
44
+ execute :rm, '-rf', ruby_version, "#{ruby_version}.tar.gz"
45
+
46
+ info "#{ruby_version.capitalize} installed successfuly"
47
+ end
48
+ end
49
+ end
50
+ end
51
+ after "recipes:install", "ruby:install"
52
+
53
+ end
@@ -0,0 +1,30 @@
1
+ require 'recipes'
2
+
3
+ set :unicorn_name, nil
4
+ set :unicorn_worker_processes, 2
5
+
6
+ def unicorn_name
7
+ fetch(:unicorn_name) || [:unicorn, application].join('_')
8
+ end
9
+
10
+ namespace :unicorn do
11
+ desc "Install the latest stable release of unicorn"
12
+ task :install do
13
+ needs_implemetation
14
+ end
15
+ after "recipes:install", "unicorn:install"
16
+
17
+ desc "Setup unicorn configuration for this application"
18
+ task :setup do
19
+ needs_implementation
20
+ end
21
+ after "recipes:setup", "unicorn:setup"
22
+
23
+ %w{start stop restart}.each do |command|
24
+ desc "#{command.capitalize} unicorn"
25
+ task status do
26
+ needs_implementation
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,11 @@
1
+ module SSHKit
2
+ module CommandHelper
3
+ def aptitude(*tasks)
4
+ execute 'apt-get', tasks.flatten
5
+ end
6
+
7
+ def service(*tasks)
8
+ execute :service, tasks.flatten
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ upstream unicorn_<%= application %>_server {
2
+ server unix:/tmp/unicorn.<%= application %>.sock fail_timeout=30;
3
+ }
4
+
5
+ server {
6
+ server_name paysagesunrise.com.br www.paysagesunrise.com.br;
7
+ listen 80 default_server;
8
+
9
+ access_log <%= shared_path %>/access.log;
10
+ error_log <%= shared_path %>/error.log;
11
+
12
+ root <%= current_path %>/public;
13
+
14
+ try_files $uri/index.html $uri.html $uri @app;
15
+
16
+ location @app {
17
+ proxy_set_header X-Forwarded-Proto $scheme;
18
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19
+ proxy_set_header Host $http_host;
20
+ proxy_redirect off;
21
+ proxy_pass http://unicorn_<%= application %>_server;
22
+ }
23
+ }
@@ -0,0 +1,31 @@
1
+ require 'fileutils'
2
+
3
+ rails_env = ENV['RAILS_ENV'] || Dir.pwd.scan(/\/(production|homologation)\//).flatten.first || 'production'
4
+
5
+ worker_processes <%= fetch :unicorn_worker_processes %>
6
+ working_directory '<%= current_path %>'
7
+ listen '<%= "/tmp/unicorn.<%= application %>.sock" %>', :backlog => 64
8
+ timeout 30
9
+
10
+ FileUtils.mkdir_p '<%= shared_path %>/pids'
11
+ FileUtils.mkdir_p '<%= shared_path %>/log'
12
+
13
+ pid '<%= shared_path %>/pids/unicorn.pid'
14
+ stderr_path '<%= shared_path %>/log/unicorn.stderr.log'
15
+ stdout_path '<%= shared_path %>/log/unicorn.stdout.log'
16
+
17
+ preload_app true
18
+ GC.respond_to?(:copy_on_write_friendly=) and
19
+ GC.copy_on_write_friendly = true
20
+
21
+ check_client_connection false
22
+
23
+ before_fork do |server, worker|
24
+ defined?(ActiveRecord::Base) and
25
+ ActiveRecord::Base.connection.disconnect!
26
+ end
27
+
28
+ after_fork do |server, worker|
29
+ defined?(ActiveRecord::Base) and
30
+ ActiveRecord::Base.establish_connection
31
+ end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-deploy-recipes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adilson Carvalho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-04 00:00:00.000000000 Z
11
+ date: 2014-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: capistrano-bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.1'
41
41
  description: Capistrano fullstack deploy recipes
@@ -45,7 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .gitignore
48
+ - ".gitignore"
49
49
  - Gemfile
50
50
  - Gemfile.lock
51
51
  - LICENSE.md
@@ -53,8 +53,15 @@ files:
53
53
  - Rakefile
54
54
  - capistrano-deploy-recipes.gemspec
55
55
  - lib/recipes.rb
56
- - lib/recipes/.gitkeep
57
- - lib/templates/.gitkeep
56
+ - lib/recipes/nginx.rb
57
+ - lib/recipes/nodejs.rb
58
+ - lib/recipes/postgres.rb
59
+ - lib/recipes/ruby.rb
60
+ - lib/recipes/unicorn.rb
61
+ - lib/sshkit_extensions.rb
62
+ - lib/templates/nginx_unicorn.erb
63
+ - lib/templates/unicorn.rb.erb
64
+ - lib/templates/unicorn_init.erb
58
65
  homepage: https://github.com/mcorp/capistrano-deploy-recipes
59
66
  licenses: []
60
67
  metadata: {}
@@ -64,17 +71,17 @@ require_paths:
64
71
  - lib
65
72
  required_ruby_version: !ruby/object:Gem::Requirement
66
73
  requirements:
67
- - - ! '>='
74
+ - - ">="
68
75
  - !ruby/object:Gem::Version
69
76
  version: '0'
70
77
  required_rubygems_version: !ruby/object:Gem::Requirement
71
78
  requirements:
72
- - - ! '>='
79
+ - - ">="
73
80
  - !ruby/object:Gem::Version
74
81
  version: '0'
75
82
  requirements: []
76
83
  rubyforge_project:
77
- rubygems_version: 2.2.1
84
+ rubygems_version: 2.2.2
78
85
  signing_key:
79
86
  specification_version: 4
80
87
  summary: Capistrano fullstack deploy recipes
File without changes