capitate 0.1.9 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Capfile +3 -2
- data/History.txt +6 -0
- data/Manifest.txt +28 -11
- data/bin/capitate +13 -61
- data/config/hoe.rb +2 -2
- data/docs/nginx.README +12 -0
- data/docs/recipes/centos.txt +33 -0
- data/docs/recipes/deploy-pending.txt +25 -0
- data/docs/recipes/deploy-web.txt +33 -0
- data/docs/recipes/deploy.txt +159 -0
- data/docs/recipes/docs.txt +26 -0
- data/docs/recipes/imagemagick-centos.txt +20 -0
- data/docs/recipes/imagemagick.txt +8 -0
- data/docs/recipes/index.txt +26 -0
- data/docs/recipes/memcached-centos.txt +32 -0
- data/docs/recipes/memcached.txt +35 -0
- data/docs/recipes/mongrel_cluster-centos.txt +27 -0
- data/docs/recipes/mongrel_cluster.txt +40 -0
- data/docs/recipes/monit-centos.txt +32 -0
- data/docs/recipes/monit.txt +8 -0
- data/docs/recipes/mysql-centos.txt +22 -0
- data/docs/recipes/mysql.txt +58 -0
- data/docs/recipes/nginx-centos.txt +43 -0
- data/docs/recipes/nginx.txt +51 -0
- data/docs/recipes/rails.txt +58 -0
- data/docs/recipes/ruby-centos.txt +22 -0
- data/docs/recipes/ruby.txt +8 -0
- data/docs/recipes/sphinx-centos.txt +35 -0
- data/docs/recipes/sphinx.txt +89 -0
- data/lib/capitate/cap_ext/run_via.rb +14 -0
- data/lib/capitate/plugins/gem.rb +2 -3
- data/lib/capitate/plugins/prompt.rb +24 -0
- data/lib/capitate/plugins/script.rb +29 -15
- data/lib/capitate/plugins/templates.rb +45 -40
- data/lib/capitate/plugins/yum.rb +12 -22
- data/lib/capitate/task_node.rb +28 -9
- data/lib/capitate/version.rb +2 -2
- data/lib/capitate.rb +4 -5
- data/lib/deployment/deploy.rb +42 -0
- data/lib/deployment/install-centos-rubyweb.rb +131 -0
- data/lib/recipes/centos/centos.rb +30 -21
- data/lib/recipes/centos/imagemagick.rb +9 -8
- data/lib/recipes/centos/memcached.rb +11 -21
- data/lib/recipes/centos/mongrel_cluster.rb +7 -11
- data/lib/recipes/centos/monit.rb +13 -18
- data/lib/recipes/centos/mysql.rb +6 -9
- data/lib/recipes/centos/nginx.rb +17 -30
- data/lib/recipes/centos/ruby.rb +14 -19
- data/lib/recipes/centos/sphinx.rb +14 -28
- data/lib/recipes/docs.rb +22 -6
- data/lib/recipes/memcached.rb +14 -8
- data/lib/recipes/mongrel_cluster.rb +11 -14
- data/lib/recipes/mysql.rb +22 -40
- data/lib/recipes/nginx.rb +9 -4
- data/lib/recipes/rails.rb +53 -6
- data/lib/recipes/sphinx.rb +86 -17
- data/lib/templates/capistrano/Capfile +2 -6
- data/lib/templates/monit/cert.sh +1 -1
- data/lib/templates/mysql/install_db.sql.erb +2 -2
- data/lib/templates/sphinx/sphinx.conf.erb +28 -399
- data/lib/templates/sphinx/sphinx_app.initd.centos.erb +1 -1
- data/website/index.html +20 -34
- data/website/index.txt +12 -22
- data/website/stylesheets/screen.css +22 -11
- data/website/template.rhtml +7 -5
- data/website/template_recipe.rhtml +7 -3
- metadata +55 -15
- data/lib/capitate/plugins/package.rb +0 -30
- data/lib/capitate/plugins/profiles.rb +0 -33
- data/lib/capitate/plugins/wget.rb +0 -23
- data/lib/profiles/centos-sick.rb +0 -116
- data/lib/recipes/README +0 -5
- data/lib/recipes/centos/README +0 -3
- data/lib/recipes/gems.rb +0 -20
- data/lib/recipes/packages.rb +0 -39
- data/lib/recipes/recipes.rb +0 -30
- data/lib/templates/centos/setup_for_web.sh +0 -17
- data/lib/templates/centos/sudoers +0 -95
    
        data/lib/recipes/centos/monit.rb
    CHANGED
    
    | @@ -5,40 +5,35 @@ namespace :monit do | |
| 5 5 | 
             
                desc <<-DESC
         | 
| 6 6 | 
             
                Install monit.
         | 
| 7 7 |  | 
| 8 | 
            -
                 | 
| 9 | 
            -
                
         | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
                monit_password | 
| 13 | 
            -
                
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                  
         | 
| 8 | 
            +
                *monit_build_options*: Monit build options.\n
         | 
| 9 | 
            +
                *monit_port*: Monit port. _Defaults to 2812_\n    
         | 
| 10 | 
            +
                @set :monit_port, 2812@\n
         | 
| 11 | 
            +
                *monit_password*: Monit password. _Defaults to password prompt_\n    
         | 
| 12 | 
            +
                @set :monit_password, prompt.password('Monit admin password (to set): ')@\n    
         | 
| 13 | 
            +
                *monit_conf_dir*: Directory for monitrc files.\n    
         | 
| 14 | 
            +
                @set :monit_conf_dir, "/etc/monit"@\n      
         | 
| 16 15 | 
             
                DESC
         | 
| 17 16 | 
             
                task :install do
         | 
| 18 17 |  | 
| 19 18 | 
             
                  # Settings
         | 
| 20 19 | 
             
                  fetch_or_default(:monit_port, 2812)
         | 
| 21 | 
            -
                  fetch_or_default(:monit_password, 
         | 
| 22 | 
            -
             | 
| 20 | 
            +
                  fetch_or_default(:monit_password, prompt.password('Monit admin password (to set): ', true))
         | 
| 21 | 
            +
                  fetch_or_default(:monit_conf_dir, "/etc/monit")
         | 
| 22 | 
            +
                  fetch(:monit_build_options)
         | 
| 23 23 |  | 
| 24 24 | 
             
                  # Install dependencies
         | 
| 25 25 | 
             
                  yum.install([ "flex", "byacc" ])
         | 
| 26 26 |  | 
| 27 | 
            -
                  # Build options
         | 
| 28 | 
            -
                  monit_options = {
         | 
| 29 | 
            -
                    :url => "http://www.tildeslash.com/monit/dist/monit-4.10.1.tar.gz"
         | 
| 30 | 
            -
                  }
         | 
| 31 | 
            -
             | 
| 32 27 | 
             
                  # Build
         | 
| 33 | 
            -
                  script.make_install("monit",  | 
| 28 | 
            +
                  script.make_install("monit", monit_build_options)
         | 
| 34 29 |  | 
| 35 30 | 
             
                  # Install initscript
         | 
| 36 31 | 
             
                  put template.load("monit/monit.initd.centos.erb"), "/tmp/monit.initd"
         | 
| 37 | 
            -
                   | 
| 32 | 
            +
                  run_via "install -o root /tmp/monit.initd /etc/init.d/monit && rm -f /tmp/monit.initd"
         | 
| 38 33 |  | 
| 39 34 | 
             
                  # Install monitrc
         | 
| 40 35 | 
             
                  put template.load("monit/monitrc.erb"), "/tmp/monitrc"
         | 
| 41 | 
            -
                   | 
| 36 | 
            +
                  run_via "mkdir -p #{monit_conf_dir} && install -o root -m 700 /tmp/monitrc /etc/monitrc && rm -f /tmp/monitrc"
         | 
| 42 37 |  | 
| 43 38 | 
             
                  # Patch initab
         | 
| 44 39 | 
             
                  script.sh("monit/patch_inittab.sh")
         | 
    
        data/lib/recipes/centos/mysql.rb
    CHANGED
    
    | @@ -5,26 +5,23 @@ namespace :mysql do | |
| 5 5 | 
             
                desc <<-DESC
         | 
| 6 6 | 
             
                Install mysql.
         | 
| 7 7 |  | 
| 8 | 
            -
                mysql_admin_password_set | 
| 9 | 
            -
                
         | 
| 10 | 
            -
                  set :mysql_admin_password_set, Proc.new { Capistrano::CLI.ui.ask('Mysql admin password (to set): ') }
         | 
| 11 | 
            -
                  
         | 
| 8 | 
            +
                *mysql_admin_password_set*: Mysql admin password (to set). _Defaults to password prompt._\n    
         | 
| 9 | 
            +
                <pre>set :mysql_admin_password_set, prompt.password('Mysql admin password (to set): ')</pre>\n      
         | 
| 12 10 | 
             
                DESC
         | 
| 13 11 | 
             
                task :install do    
         | 
| 14 12 |  | 
| 15 13 | 
             
                  # Settings
         | 
| 16 | 
            -
                  fetch_or_default(:mysql_admin_password_set, 
         | 
| 17 | 
            -
                    Proc.new { Capistrano::CLI.ui.ask('Mysql admin password (to set): ') })      
         | 
| 14 | 
            +
                  fetch_or_default(:mysql_admin_password_set, prompt.password('Mysql admin password (to set): ', true))
         | 
| 18 15 |  | 
| 19 16 | 
             
                  # Install through package manager
         | 
| 20 17 | 
             
                  yum.install([ "mysql", "mysql-devel", "mysql-server" ])
         | 
| 21 18 |  | 
| 22 19 | 
             
                  # Install service
         | 
| 23 | 
            -
                   | 
| 24 | 
            -
                   | 
| 20 | 
            +
                  run_via "/sbin/chkconfig --level 345 mysqld on"
         | 
| 21 | 
            +
                  run_via "/sbin/service mysqld start"
         | 
| 25 22 |  | 
| 26 23 | 
             
                  # Set admin password
         | 
| 27 | 
            -
                   | 
| 24 | 
            +
                  run_via "/usr/bin/mysqladmin -u root password #{mysql_admin_password_set}"    
         | 
| 28 25 | 
             
                end
         | 
| 29 26 |  | 
| 30 27 | 
             
              end
         | 
    
        data/lib/recipes/centos/nginx.rb
    CHANGED
    
    | @@ -4,26 +4,21 @@ namespace :nginx do | |
| 4 4 |  | 
| 5 5 | 
             
                desc <<-DESC
         | 
| 6 6 | 
             
                Install nginx, conf, initscript, nginx user and service.
         | 
| 7 | 
            -
                nginx_bin_path: Nginx sbin path. Defaults to /sbin/nginx
         | 
| 8 7 |  | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
                 | 
| 12 | 
            -
                
         | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
                nginx_pid_path | 
| 16 | 
            -
                
         | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
                nginx_prefix_path: Nginx install prefix. Defaults to /var/nginx
         | 
| 20 | 
            -
                
         | 
| 21 | 
            -
                  set :nginx_prefix_path, "/var/nginx"
         | 
| 22 | 
            -
                  
         | 
| 8 | 
            +
                *nginx_build_options*: Nginx build options.\n
         | 
| 9 | 
            +
                *nginx_bin_path*: Nginx sbin path. _Defaults to /sbin/nginx_\n    
         | 
| 10 | 
            +
                @set :nginx_bin_path, "/sbin/nginx"@\n
         | 
| 11 | 
            +
                *nginx_conf_path*: Path to nginx conf. _Defaults to /etc/nginx/nginx.conf_\n    
         | 
| 12 | 
            +
                @set :nginx_conf_path, "/etc/nginx/nginx.conf"@\n
         | 
| 13 | 
            +
                *nginx_pid_path*: Path to nginx pid file. _Defaults to /var/run/nginx.pid_\n    
         | 
| 14 | 
            +
                @set :nginx_pid_path, "/var/run/nginx.pid"@\n
         | 
| 15 | 
            +
                *nginx_prefix_path*: Nginx install prefix. _Defaults to /var/nginx_\n    
         | 
| 16 | 
            +
                @set :nginx_prefix_path, "/var/nginx"@\n      
         | 
| 23 17 | 
             
                DESC
         | 
| 24 18 | 
             
                task :install do
         | 
| 25 19 |  | 
| 26 20 | 
             
                  # Settings
         | 
| 21 | 
            +
                  fetch(:nginx_build_options)
         | 
| 27 22 | 
             
                  fetch_or_default(:nginx_bin_path, "/sbin/nginx")
         | 
| 28 23 | 
             
                  fetch_or_default(:nginx_conf_path, "/etc/nginx/nginx.conf")
         | 
| 29 24 | 
             
                  fetch_or_default(:nginx_pid_path, "/var/run/nginx.pid")
         | 
| @@ -32,30 +27,22 @@ namespace :nginx do | |
| 32 27 | 
             
                  # Install dependencies
         | 
| 33 28 | 
             
                  yum.install([ "pcre-devel", "openssl", "openssl-devel" ]) 
         | 
| 34 29 |  | 
| 35 | 
            -
                  # Build options
         | 
| 36 | 
            -
                  nginx_options = {
         | 
| 37 | 
            -
                    :url => "http://sysoev.ru/nginx/nginx-0.5.35.tar.gz",
         | 
| 38 | 
            -
                    :configure_options => "--sbin-path=#{nginx_bin_path} --conf-path=#{nginx_conf_path} \
         | 
| 39 | 
            -
            --pid-path=#{nginx_pid_path} --error-log-path=/var/log/nginx_master_error.log --lock-path=/var/lock/nginx \
         | 
| 40 | 
            -
            --prefix=#{nginx_prefix_path} --with-md5=auto/lib/md5 --with-sha1=auto/lib/sha1 --with-http_ssl_module"
         | 
| 41 | 
            -
                  }
         | 
| 42 | 
            -
             | 
| 43 30 | 
             
                  # Build
         | 
| 44 | 
            -
                  script.make_install("nginx",  | 
| 31 | 
            +
                  script.make_install("nginx", nginx_build_options)
         | 
| 45 32 |  | 
| 46 33 | 
             
                  # Install initscript, and turn it on
         | 
| 47 34 | 
             
                  put template.load("nginx/nginx.initd.erb"), "/tmp/nginx.initd"
         | 
| 48 | 
            -
                   | 
| 49 | 
            -
                   | 
| 35 | 
            +
                  run_via "install -o root /tmp/nginx.initd /etc/init.d/nginx && rm -f /tmp/nginx.initd"
         | 
| 36 | 
            +
                  run_via "/sbin/chkconfig --level 345 nginx on"
         | 
| 50 37 |  | 
| 51 38 | 
             
                  # Setup nginx
         | 
| 52 | 
            -
                   | 
| 53 | 
            -
                   | 
| 39 | 
            +
                  run_via "mkdir -p /etc/nginx/vhosts"
         | 
| 40 | 
            +
                  run_via "echo \"# Blank nginx conf; work-around for nginx conf include issue\" > /etc/nginx/vhosts/blank.conf"
         | 
| 54 41 | 
             
                  put template.load("nginx/nginx.conf.erb", binding), "/tmp/nginx.conf"
         | 
| 55 | 
            -
                   | 
| 42 | 
            +
                  run_via "install -o root -m 644 /tmp/nginx.conf #{nginx_conf_path} && rm -f /tmp/nginx.conf"
         | 
| 56 43 |  | 
| 57 44 | 
             
                  # Create nginx user
         | 
| 58 | 
            -
                   | 
| 45 | 
            +
                  run_via "id nginx || /usr/sbin/adduser -r nginx"
         | 
| 59 46 | 
             
                end
         | 
| 60 47 |  | 
| 61 48 | 
             
                # Restart nginx
         | 
    
        data/lib/recipes/centos/ruby.rb
    CHANGED
    
    | @@ -2,35 +2,30 @@ namespace :ruby do | |
| 2 2 |  | 
| 3 3 | 
             
              namespace :centos do
         | 
| 4 4 |  | 
| 5 | 
            -
                desc  | 
| 5 | 
            +
                desc <<-DESC
         | 
| 6 | 
            +
                Install ruby and rubygems.
         | 
| 7 | 
            +
                
         | 
| 8 | 
            +
                *ruby_build_options*: Ruby build options.\n
         | 
| 9 | 
            +
                *rubygems_build_options*: Rubygems build options.\n
         | 
| 10 | 
            +
                DESC
         | 
| 6 11 | 
             
                task :install do 
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  # Settings
         | 
| 14 | 
            +
                  fetch(:ruby_build_options)
         | 
| 15 | 
            +
                  fetch(:rubygems_build_options)
         | 
| 7 16 |  | 
| 8 17 | 
             
                  # Install dependencies
         | 
| 9 18 | 
             
                  yum.install([ "zlib", "zlib-devel" ])
         | 
| 10 19 |  | 
| 11 | 
            -
                  ruby_options = {
         | 
| 12 | 
            -
                    :url => "http://capigen.s3.amazonaws.com/ruby-1.8.6-p110.tar.gz",
         | 
| 13 | 
            -
                    :build_dest => "/usr/src",
         | 
| 14 | 
            -
                    :configure_options => "--prefix=/usr",       
         | 
| 15 | 
            -
                    :clean => false
         | 
| 16 | 
            -
                  }
         | 
| 17 | 
            -
                
         | 
| 18 20 | 
             
                  # Install ruby 1.8.6
         | 
| 19 | 
            -
                  script.make_install("ruby",  | 
| 20 | 
            -
                
         | 
| 21 | 
            -
                  # Fix openssl
         | 
| 22 | 
            -
                  script.sh("ruby/fix_openssl.sh")    
         | 
| 23 | 
            -
                
         | 
| 24 | 
            -
                  rubygems_options = { 
         | 
| 25 | 
            -
                    :url => "http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz"
         | 
| 26 | 
            -
                  }
         | 
| 21 | 
            +
                  script.make_install("ruby", ruby_build_options)
         | 
| 27 22 |  | 
| 28 23 | 
             
                  # Install rubygems
         | 
| 29 | 
            -
                  script.install("rubygems",  | 
| 30 | 
            -
                     | 
| 24 | 
            +
                  script.install("rubygems", rubygems_build_options) do |dir|
         | 
| 25 | 
            +
                    run_via "echo 'Running setup...' && cd #{dir} && ruby setup.rb > install.log"
         | 
| 31 26 | 
             
                  end
         | 
| 32 27 |  | 
| 33 | 
            -
                end
         | 
| 28 | 
            +
                end        
         | 
| 34 29 |  | 
| 35 30 | 
             
              end
         | 
| 36 31 |  | 
| @@ -3,59 +3,45 @@ namespace :sphinx do | |
| 3 3 | 
             
              namespace :centos do
         | 
| 4 4 |  | 
| 5 5 | 
             
                desc <<-DESC
         | 
| 6 | 
            -
                Install sphinx | 
| 7 | 
            -
                
         | 
| 8 | 
            -
                sphinx_prefix | 
| 9 | 
            -
                
         | 
| 10 | 
            -
                  set :sphinx_prefix, "/usr/local/sphinx"
         | 
| 11 | 
            -
                  
         | 
| 6 | 
            +
                Install sphinx.\n
         | 
| 7 | 
            +
                *sphinx_build_options*: Sphinx build options.\n
         | 
| 8 | 
            +
                *sphinx_prefix*: Sphinx install prefix. _Defaults to "/usr/local/sphinx"_\n
         | 
| 12 9 | 
             
                DESC
         | 
| 13 10 | 
             
                task :install do 
         | 
| 14 11 |  | 
| 15 12 | 
             
                  # Settings
         | 
| 13 | 
            +
                  fetch(:sphinx_build_options)
         | 
| 16 14 | 
             
                  fetch_or_default(:sphinx_prefix, "/usr/local/sphinx")
         | 
| 17 15 |  | 
| 18 16 | 
             
                  # Install dependencies
         | 
| 19 17 | 
             
                  yum.install([ "gcc-c++" ])
         | 
| 20 18 |  | 
| 21 | 
            -
                  # Build options
         | 
| 22 | 
            -
                  sphinx_options = {
         | 
| 23 | 
            -
                    :url => "http://www.sphinxsearch.com/downloads/sphinx-0.9.7.tar.gz",
         | 
| 24 | 
            -
                    :configure_options => "--with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib/mysql \
         | 
| 25 | 
            -
              --prefix=#{sphinx_prefix}"
         | 
| 26 | 
            -
                  }
         | 
| 27 | 
            -
                  
         | 
| 28 19 | 
             
                  # Build
         | 
| 29 | 
            -
                  script.make_install("sphinx",  | 
| 20 | 
            +
                  script.make_install("sphinx", sphinx_build_options)
         | 
| 30 21 | 
             
                end
         | 
| 31 22 |  | 
| 32 23 | 
             
                desc <<-DESC
         | 
| 33 | 
            -
                Setup sphinx for application | 
| 34 | 
            -
                
         | 
| 35 | 
            -
                 | 
| 36 | 
            -
                
         | 
| 37 | 
            -
                  set :sphinx_prefix, "/usr/local/sphinx"
         | 
| 38 | 
            -
                  
         | 
| 24 | 
            +
                Setup sphinx for application.\n    
         | 
| 25 | 
            +
                *sphinx_prefix*: Sphinx install prefix. _Defaults to "/usr/local/sphinx"_\n
         | 
| 26 | 
            +
                *sphinx_pid_path*: Directory to sphinx pid. _Defaults to "[shared_path]/pids/searchd.pid"_\n
         | 
| 27 | 
            +
                *sphinx_conf_path*: Path to sphinx.conf. _Defaults to "[shared_path]/config/sphinx.conf"_\n
         | 
| 39 28 | 
             
                DESC
         | 
| 40 29 | 
             
                task :setup do       
         | 
| 41 30 |  | 
| 42 31 | 
             
                  # Settings
         | 
| 43 32 | 
             
                  fetch_or_default(:sphinx_prefix, "/usr/local/sphinx")
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                  # | 
| 46 | 
            -
                  set :sphinx_bin_path, "#{sphinx_prefix}/bin"
         | 
| 47 | 
            -
                  set :sphinx_conf_path, "#{shared_path}/config/sphinx.conf"
         | 
| 48 | 
            -
                  set :sphinx_pid_path, "#{shared_path}/pids/searchd.pid"
         | 
| 33 | 
            +
                  fetch_or_default(:sphinx_pid_path, "#{shared_path}/pids/searchd.pid")
         | 
| 34 | 
            +
                  fetch_or_default(:sphinx_conf_path, "#{shared_path}/config/sphinx.conf")      
         | 
| 49 35 |  | 
| 50 36 | 
             
                  # Install initscript
         | 
| 51 37 | 
             
                  put template.load("sphinx/sphinx_app.initd.centos.erb"), "/tmp/sphinx.initd"
         | 
| 52 | 
            -
                   | 
| 38 | 
            +
                  run_via "install -o root /tmp/sphinx.initd /etc/init.d/sphinx_#{application}"
         | 
| 53 39 |  | 
| 54 40 | 
             
                  # Enable service
         | 
| 55 | 
            -
                   | 
| 41 | 
            +
                  run_via "/sbin/chkconfig --level 345 sphinx_#{application} on"    
         | 
| 56 42 |  | 
| 57 43 | 
             
                  # Create app indexes dir
         | 
| 58 | 
            -
                   | 
| 44 | 
            +
                  run_via "mkdir -p #{shared_path}/var/index"    
         | 
| 59 45 | 
             
                end
         | 
| 60 46 | 
             
              end
         | 
| 61 47 |  | 
    
        data/lib/recipes/docs.rb
    CHANGED
    
    | @@ -1,14 +1,30 @@ | |
| 1 1 | 
             
            namespace :docs do
         | 
| 2 2 |  | 
| 3 | 
            -
              desc  | 
| 3 | 
            +
              desc <<-DESC
         | 
| 4 | 
            +
              Generate documentation for all currently loaded recipes. Assumes textile formatting.
         | 
| 5 | 
            +
              
         | 
| 6 | 
            +
              *docs_recipes_dir*: Destination directory. _Defaults to "docs/recipes"_
         | 
| 7 | 
            +
              
         | 
| 8 | 
            +
              @set :docs_recipes_dir, "docs/recipes"@
         | 
| 9 | 
            +
                 
         | 
| 10 | 
            +
              *docs_recipes_clear*: Whether to clear destination before generating.
         | 
| 11 | 
            +
              
         | 
| 12 | 
            +
              @set :docs_recipes_clear, true@
         | 
| 13 | 
            +
                
         | 
| 14 | 
            +
              DESC
         | 
| 4 15 | 
             
              task :recipes do
         | 
| 5 | 
            -
                top_node = capitate.task_tree
         | 
| 6 16 |  | 
| 7 | 
            -
                 | 
| 8 | 
            -
                 | 
| 9 | 
            -
                 | 
| 17 | 
            +
                # Settings
         | 
| 18 | 
            +
                fetch_or_default(:docs_recipes_dir, "docs/recipes")
         | 
| 19 | 
            +
                fetch_or_default(:docs_recipes_clear, true)
         | 
| 20 | 
            +
                
         | 
| 21 | 
            +
                # Build task tree
         | 
| 22 | 
            +
                top_node = capitate.task_tree
         | 
| 23 | 
            +
                    
         | 
| 24 | 
            +
                FileUtils.rm_rf(docs_recipes_dir) if docs_recipes_clear
         | 
| 25 | 
            +
                FileUtils.mkdir_p(docs_recipes_dir)
         | 
| 10 26 |  | 
| 11 | 
            -
                top_node.write_doc( | 
| 27 | 
            +
                top_node.write_doc(docs_recipes_dir, "index", "Recipes")
         | 
| 12 28 |  | 
| 13 29 | 
             
              end
         | 
| 14 30 | 
             
            end
         | 
    
        data/lib/recipes/memcached.rb
    CHANGED
    
    | @@ -1,24 +1,30 @@ | |
| 1 1 | 
             
            namespace :memcached do
         | 
| 2 2 |  | 
| 3 3 | 
             
              desc <<-DESC
         | 
| 4 | 
            -
               | 
| 4 | 
            +
              Generate and install memcached monitrc.
         | 
| 5 5 |  | 
| 6 | 
            -
              memcached_pid_path | 
| 6 | 
            +
              *memcached_pid_path*: Path to memcached pid file. _Defaults to /var/run/memcached.pid_
         | 
| 7 7 |  | 
| 8 | 
            -
             | 
| 8 | 
            +
              @set :memcached_pid_path, "/var/run/memcached.pid"@
         | 
| 9 9 |  | 
| 10 | 
            -
              memcached_port | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 10 | 
            +
              *memcached_port*: Memcached port. _Defaults to 11211_   
         | 
| 11 | 
            +
              
         | 
| 12 | 
            +
              @set :memcached_port, 11211@
         | 
| 13 | 
            +
                 
         | 
| 14 | 
            +
              *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
              @set :monit_conf_dir, "/etc/monit"@
         | 
| 17 | 
            +
                 
         | 
| 13 18 | 
             
              DESC
         | 
| 14 19 | 
             
              task :install_monit do
         | 
| 15 20 |  | 
| 16 21 | 
             
                # Settings
         | 
| 17 22 | 
             
                fetch_or_default(:memcached_pid_path, "/var/run/memcached.pid")
         | 
| 18 23 | 
             
                fetch_or_default(:memcached_port, 11211)    
         | 
| 24 | 
            +
                fetch_or_default(:monit_conf_dir, "/etc/monit")
         | 
| 19 25 |  | 
| 20 | 
            -
                put template.load("memcached/memcached.monitrc.erb" | 
| 21 | 
            -
                 | 
| 26 | 
            +
                put template.load("memcached/memcached.monitrc.erb"), "/tmp/memcached.monitrc"    
         | 
| 27 | 
            +
                run_via "install -o root /tmp/memcached.monitrc #{monit_conf_dir}/memcached.monitrc"
         | 
| 22 28 | 
             
              end
         | 
| 23 29 |  | 
| 24 30 | 
             
            end
         | 
| @@ -4,19 +4,15 @@ namespace :mongrel_cluster do | |
| 4 4 | 
             
              desc <<-DESC
         | 
| 5 5 | 
             
              Create monit configuration for mongrel cluster.
         | 
| 6 6 |  | 
| 7 | 
            -
              mongrel_size | 
| 8 | 
            -
              
         | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
              mongrel_port | 
| 12 | 
            -
               | 
| 13 | 
            -
                
         | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
              mongrel_config_script: Config script to load with mongrel.
         | 
| 17 | 
            -
              
         | 
| 18 | 
            -
                set :mongrel_config_script, "config/mongrel_handler.rb"
         | 
| 19 | 
            -
                
         | 
| 7 | 
            +
              *mongrel_size*: Number of mongrels.\n  
         | 
| 8 | 
            +
              @set :mongrel_size, 3@\n
         | 
| 9 | 
            +
              *mongrel_port*: Starting port for mongrels. If there are 3 mongrels with port 9000, then instances 
         | 
| 10 | 
            +
              will be at 9000, 9001, and 9002\n    
         | 
| 11 | 
            +
              @set :mongrel_port, 9000@\n    
         | 
| 12 | 
            +
              *mongrel_config_script*: Config script to load with mongrel. _Defaults to nil_\n  
         | 
| 13 | 
            +
              @set :mongrel_config_script, "config/mongrel_handler.rb"@\n    
         | 
| 14 | 
            +
              *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_\n  
         | 
| 15 | 
            +
              @set :monit_conf_dir, "/etc/monit"@\n  
         | 
| 20 16 | 
             
              DESC
         | 
| 21 17 | 
             
              task :setup_monit do
         | 
| 22 18 |  | 
| @@ -29,6 +25,7 @@ namespace :mongrel_cluster do | |
| 29 25 | 
             
                fetch(:mongrel_size)
         | 
| 30 26 | 
             
                fetch(:mongrel_port)
         | 
| 31 27 | 
             
                fetch_or_default(:mongrel_config_script, nil)
         | 
| 28 | 
            +
                fetch_or_default(:monit_conf_dir, "/etc/monit")
         | 
| 32 29 |  | 
| 33 30 | 
             
                processes = []
         | 
| 34 31 | 
             
                ports = (0...mongrel_size).collect { |i| mongrel_port + i }
         | 
| @@ -60,7 +57,7 @@ namespace :mongrel_cluster do | |
| 60 57 | 
             
                set :processes, processes
         | 
| 61 58 |  | 
| 62 59 | 
             
                put template.load("mongrel/mongrel_cluster.monitrc.erb"), "/tmp/mongrel_cluster_#{application}.monitrc"    
         | 
| 63 | 
            -
                sudo "install -o root /tmp/mongrel_cluster_#{application}.monitrc / | 
| 60 | 
            +
                sudo "install -o root /tmp/mongrel_cluster_#{application}.monitrc #{monit_conf_dir}/mongrel_cluster_#{application}.monitrc"
         | 
| 64 61 | 
             
              end
         | 
| 65 62 |  | 
| 66 63 | 
             
            end
         | 
    
        data/lib/recipes/mysql.rb
    CHANGED
    
    | @@ -4,53 +4,35 @@ namespace :mysql do | |
| 4 4 | 
             
              desc <<-DESC
         | 
| 5 5 | 
             
              Install mysql monit hooks.
         | 
| 6 6 |  | 
| 7 | 
            -
              db_port | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
               | 
| 12 | 
            -
                
         | 
| 13 | 
            -
                set :mysql_pid_path, "/var/run/mysqld/mysqld.pid"
         | 
| 14 | 
            -
                
         | 
| 7 | 
            +
              *db_port*: Mysql port. _Defaults to 3306_\n
         | 
| 8 | 
            +
              *mysql_pid_path*: Path to mysql pid file. _Defaults to /var/run/mysqld/mysqld.pid_\n
         | 
| 9 | 
            +
              @set :mysql_pid_path, "/var/run/mysqld/mysqld.pid"@\n
         | 
| 10 | 
            +
              *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_\n
         | 
| 11 | 
            +
              @set :monit_conf_dir, "/etc/monit"@\n
         | 
| 15 12 | 
             
              DESC
         | 
| 16 13 | 
             
              task :install_monit do
         | 
| 17 14 |  | 
| 18 15 | 
             
                # Settings 
         | 
| 19 16 | 
             
                fetch_or_default(:mysql_pid_path, "/var/run/mysqld/mysqld.pid")
         | 
| 20 | 
            -
                fetch_or_default(:db_port, 3306) | 
| 17 | 
            +
                fetch_or_default(:db_port, 3306)   
         | 
| 18 | 
            +
                fetch_or_default(:monit_conf_dir, "/etc/monit") 
         | 
| 21 19 |  | 
| 22 20 | 
             
                put template.load("mysql/mysql.monitrc.erb", binding), "/tmp/mysql.monitrc"    
         | 
| 23 | 
            -
                 | 
| 21 | 
            +
                run_via "install -o root /tmp/mysql.monitrc #{monit_conf_dir}/mysql.monitrc"
         | 
| 24 22 | 
             
              end
         | 
| 25 23 |  | 
| 26 24 | 
             
              desc <<-DESC
         | 
| 27 | 
            -
              Create database user, and  | 
| 28 | 
            -
              
         | 
| 29 | 
            -
              db_name | 
| 30 | 
            -
              
         | 
| 31 | 
            -
             | 
| 32 | 
            -
              
         | 
| 33 | 
            -
               | 
| 34 | 
            -
              
         | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
               | 
| 38 | 
            -
              
         | 
| 39 | 
            -
                set :db_pass, "the_password"
         | 
| 40 | 
            -
                
         | 
| 41 | 
            -
              web_host: Web host to provide access privileges to (if recipe used in context of web app). 
         | 
| 42 | 
            -
              Defaults to nil. TODO: Support multiple web hosts    
         | 
| 43 | 
            -
              
         | 
| 44 | 
            -
                set :web_host, 10.0.6.100
         | 
| 45 | 
            -
                
         | 
| 46 | 
            -
              db_host: Database host (to provide itself with access).    
         | 
| 47 | 
            -
              
         | 
| 48 | 
            -
                set :db_host, 10.0.6.101
         | 
| 49 | 
            -
                
         | 
| 50 | 
            -
              mysql_admin_password: Mysql admin password (to use to connect). Defaults to password prompt.
         | 
| 51 | 
            -
              
         | 
| 52 | 
            -
                set :mysql_admin_password, Proc.new { Capistrano::CLI.ui.ask('Mysql admin password: ') })
         | 
| 53 | 
            -
                
         | 
| 25 | 
            +
              Create database, database user, and set grant permissions.
         | 
| 26 | 
            +
              
         | 
| 27 | 
            +
              *db_name*: Database name (application).\n
         | 
| 28 | 
            +
              *db_user*: Database user (application).\n    
         | 
| 29 | 
            +
              *db_pass*: Database password (application).\n
         | 
| 30 | 
            +
              *grant_locations*: Grant locations. _Defaults to localhost_\n
         | 
| 31 | 
            +
              @set :grant_locations, [ "localhost", "192.168.1.111" ]@\n
         | 
| 32 | 
            +
              *grant_priv_type*: Grant privilege types. _Defaults to ALL_\n
         | 
| 33 | 
            +
              @set :grant_priv_type, "ALL"@\n
         | 
| 34 | 
            +
              *mysql_admin_password*: Mysql admin password (to use to connect). Defaults to password prompt.\n
         | 
| 35 | 
            +
              @set :mysql_admin_password, prompt.password('Mysql admin password: '))@    
         | 
| 54 36 | 
             
              DESC
         | 
| 55 37 | 
             
              task :setup do    
         | 
| 56 38 |  | 
| @@ -58,9 +40,9 @@ namespace :mysql do | |
| 58 40 | 
             
                fetch(:db_name)
         | 
| 59 41 | 
             
                fetch(:db_user)
         | 
| 60 42 | 
             
                fetch(:db_pass)
         | 
| 61 | 
            -
                 | 
| 62 | 
            -
                fetch_or_default(: | 
| 63 | 
            -
                fetch_or_default(: | 
| 43 | 
            +
                fetch_or_default(:mysql_admin_password, prompt.password('Mysql admin password: '))
         | 
| 44 | 
            +
                fetch_or_default(:grant_locations, [ "localhost" ])
         | 
| 45 | 
            +
                fetch_or_default(:grant_priv_type, "ALL")
         | 
| 64 46 |  | 
| 65 47 | 
             
                # Add localhost to grant locations
         | 
| 66 48 | 
             
                set :locations_for_grant, [ "localhost", web_host, db_host ].compact
         | 
    
        data/lib/recipes/nginx.rb
    CHANGED
    
    | @@ -4,18 +4,23 @@ namespace :nginx do | |
| 4 4 | 
             
              desc <<-DESC 
         | 
| 5 5 | 
             
              Install nginx monit hooks.
         | 
| 6 6 |  | 
| 7 | 
            -
              nginx_pid_path | 
| 7 | 
            +
              *nginx_pid_path*: Path to nginx pid file. _Defaults to /var/run/nginx.pid_
         | 
| 8 | 
            +
              
         | 
| 9 | 
            +
              @set :nginx_pid_path, "/var/run/nginx.pid"@
         | 
| 10 | 
            +
              
         | 
| 11 | 
            +
              *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              @set :monit_conf_dir, "/etc/monit"@
         | 
| 8 14 |  | 
| 9 | 
            -
                set :nginx_pid_path, "/var/run/nginx.pid"
         | 
| 10 | 
            -
                
         | 
| 11 15 | 
             
              DESC
         | 
| 12 16 | 
             
              task :install_monit do
         | 
| 13 17 |  | 
| 14 18 | 
             
                # Settings
         | 
| 15 19 | 
             
                fetch_or_default(:nginx_pid_path, "/var/run/nginx.pid")
         | 
| 20 | 
            +
                fetch_or_default(:monit_conf_dir, "/etc/monit")
         | 
| 16 21 |  | 
| 17 22 | 
             
                put template.load("nginx/nginx.monitrc.erb", binding), "/tmp/nginx.monitrc"    
         | 
| 18 | 
            -
                 | 
| 23 | 
            +
                run_via "install -o root /tmp/nginx.monitrc #{monit_conf_dir}/nginx.monitrc"
         | 
| 19 24 | 
             
              end
         | 
| 20 25 |  | 
| 21 26 | 
             
              desc <<-DESC
         | 
    
        data/lib/recipes/rails.rb
    CHANGED
    
    | @@ -4,17 +4,17 @@ namespace :rails do | |
| 4 4 | 
             
              desc <<-DESC
         | 
| 5 5 | 
             
              Create database yaml in shared path.
         | 
| 6 6 |  | 
| 7 | 
            -
              db_name | 
| 7 | 
            +
              *db_name*: Database name (rails).    
         | 
| 8 8 |  | 
| 9 | 
            -
             | 
| 9 | 
            +
              @set :db_name, "app_db_name"@
         | 
| 10 10 |  | 
| 11 | 
            -
              db_user | 
| 11 | 
            +
              *db_user*: Database user (rails).    
         | 
| 12 12 |  | 
| 13 | 
            -
             | 
| 13 | 
            +
              @set :db_user, "app_db_user"@
         | 
| 14 14 |  | 
| 15 | 
            -
              db_pass | 
| 15 | 
            +
              *db_pass*: Database password (rails).    
         | 
| 16 16 |  | 
| 17 | 
            -
             | 
| 17 | 
            +
              @set :db_pass, "the_password"@
         | 
| 18 18 |  | 
| 19 19 | 
             
              DESC
         | 
| 20 20 | 
             
              task :setup do    
         | 
| @@ -32,4 +32,51 @@ namespace :rails do | |
| 32 32 | 
             
              task :update_code do
         | 
| 33 33 | 
             
                run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" 
         | 
| 34 34 | 
             
              end
         | 
| 35 | 
            +
              
         | 
| 36 | 
            +
              desc <<-DESC
         | 
| 37 | 
            +
              Tail production log files. (http://errtheblog.com/posts/19-streaming-capistrano)
         | 
| 38 | 
            +
              DESC
         | 
| 39 | 
            +
              task :tail_logs, :roles => :web do
         | 
| 40 | 
            +
                run "tail -f #{shared_path}/log/production.log" do |channel, stream, data|
         | 
| 41 | 
            +
                  puts  # for an extra line break before the host name
         | 
| 42 | 
            +
                  puts "#{channel[:host]}: #{data}" 
         | 
| 43 | 
            +
                  break if stream == :err    
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
             | 
| 48 | 
            +
              desc <<-DESC
         | 
| 49 | 
            +
              Check production log files in TextMate.  (http://errtheblog.com/posts/19-streaming-capistrano)
         | 
| 50 | 
            +
              DESC
         | 
| 51 | 
            +
              task :mate_logs, :roles => :app do
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                require 'tempfile'
         | 
| 54 | 
            +
                tmp = Tempfile.open('w')
         | 
| 55 | 
            +
                logs = Hash.new { |h,k| h[k] = '' }
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                run "tail -n500 #{shared_path}/log/production.log" do |channel, stream, data|
         | 
| 58 | 
            +
                  logs[channel[:host]] << data
         | 
| 59 | 
            +
                  break if stream == :err
         | 
| 60 | 
            +
                end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                logs.each do |host, log|
         | 
| 63 | 
            +
                  tmp.write("--- #{host} ---\n\n")
         | 
| 64 | 
            +
                  tmp.write(log + "\n")
         | 
| 65 | 
            +
                end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                exec "mate -w #{tmp.path}" 
         | 
| 68 | 
            +
                tmp.close
         | 
| 69 | 
            +
              end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
              desc <<-DESC
         | 
| 72 | 
            +
              Remotely console. (http://errtheblog.com/posts/19-streaming-capistrano)
         | 
| 73 | 
            +
              DESC
         | 
| 74 | 
            +
              task :console, :roles => :app do
         | 
| 75 | 
            +
                input = ''
         | 
| 76 | 
            +
                run "cd #{current_path} && ./script/console #{ENV['RAILS_ENV']}" do |channel, stream, data|
         | 
| 77 | 
            +
                  next if data.chomp == input.chomp || data.chomp == ''
         | 
| 78 | 
            +
                  print data
         | 
| 79 | 
            +
                  channel.send_data(input = $stdin.gets) if data =~ /^(>|\?)>/
         | 
| 80 | 
            +
                end
         | 
| 81 | 
            +
              end
         | 
| 35 82 | 
             
            end
         |