lib/deprec/recipes/apache.rb in deprec-2.1.19 vs lib/deprec/recipes/apache.rb in deprec-2.2.0

- old
+ new

@@ -11,45 +11,16 @@ set :apache_ssl_forward_all, apache_ssl_enabled set :apache_ssl_chainfile, false set :apache_modules_enabled, %w(rewrite ssl proxy_balancer proxy_http deflate expires headers) - # Start apache vhost extras - # These are only used for generating vhost files with: - # - # cap deprec:apache:vhost - # - set(:apache_vhost_domain) { Capistrano::CLI.ui.ask 'Primary domain' } - set(:apache_vhost_server_alii) { - Capistrano::CLI.ui.ask('ServerAlii (space separated)' ).split(' ') - } - set :apache_vhost_access_log_type, 'combined' - set :apache_vhost_canonicalize_hostname, true - set(:apache_vhost_access_log) { - File.join(apache_log_dir, "#{apache_vhost_domain}-access.log") - } - set(:apache_vhost_error_log) { - File.join(apache_log_dir, "#{apache_vhost_domain}-error.log") - } - set(:apache_vhost_document_root) { - File.join('/var/apps', "#{apache_vhost_domain}", 'public') - } - set :apache_vhost_rack_env, false - # End apache vhost extras - - - desc "Install apache" + desc "Install Apache" task :install do - install_deps - config - end - - # install dependencies for apache - task :install_deps do apt.install( {:base => %w(apache2-mpm-prefork apache2-prefork-dev rsync ssl-cert)}, :stable ) + config end SYSTEM_CONFIG_FILES[:apache] = [ { :template => 'apache2.conf.erb', @@ -81,47 +52,34 @@ PROJECT_CONFIG_FILES[:apache] = [ # Not required ] - desc "Generate configuration file(s) for apache from template(s)" + desc "Generate Apache config files" task :config_gen do config_gen_system end + # Generate system level apache configs task :config_gen_system do SYSTEM_CONFIG_FILES[:apache].each do |file| deprec2.render_template(:apache, file) end end + # Not used here task :config_gen_project do - PROJECT_CONFIG_FILES[:apache].each do |file| - deprec2.render_template(:apache, file) - end - # XXX Need to flesh out generation of custom certs - # In the meantime we'll just use the snakeoil cert - # - # top.deprec.ssl.config_gen if apache_ssl_enabled - top.deprec.ssl.config_gen if apache_ssl_enabled end - desc "Push apache config files to server" + desc "Push Apache config files to server" task :config, :roles => :web do config_system enable_modules reload end - desc "Generate initial configs and copy direct to server." - task :initial_config, :roles => :web do - SYSTEM_CONFIG_FILES[:apache].each do |file| - deprec2.render_template(:apache, file.merge(:remote => true)) - end - end - - desc "Push apache config files to server" + desc "Push Apache config files to server" task :config_system, :roles => :web do deprec2.push_configs(:apache, SYSTEM_CONFIG_FILES[:apache]) run "#{sudo} touch /var/www/check.txt" # Used to test webserver up end @@ -131,60 +89,83 @@ # In the meantime we'll just use the snakeoil cert # top.deprec.ssl.config if apache_ssl_enabled end - task :vhost do - file = { - :template => 'vhost.erb', - :path => "/etc/apache2/sites-available/#{apache_vhost_domain}", - :mode => 0644, - :owner => 'root:root' - } - deprec2.render_template(:apache, file) - end - task :enable_modules, :roles => :web do apache_modules_enabled.each { |mod| sudo "a2enmod #{mod}" } end + + # + # Control + # desc "Start Apache" task :start, :roles => :web do - send(run_method, "/etc/init.d/apache2 start") + run "#{sudo} /etc/init.d/apache2 start" end desc "Stop Apache" task :stop, :roles => :web do - send(run_method, "/etc/init.d/apache2 stop") + run "#{sudo} /etc/init.d/apache2 stop" end desc "Restart Apache" task :restart, :roles => :web do - send(run_method, "/etc/init.d/apache2 restart") + run "#{sudo} /etc/init.d/apache2 restart" end desc "Reload Apache" task :reload, :roles => :web do - send(run_method, "/etc/init.d/apache2 force-reload") + run "#{sudo} /etc/init.d/apache2 force-reload" end - desc "Set apache to start on boot" + desc "Set Apache to start on boot" task :activate, :roles => :web do - send(run_method, "update-rc.d apache2 defaults") + run "#{sudo} update-rc.d apache2 defaults" end - desc "Set apache to not start on boot" + desc "Set Apache to not start on boot" task :deactivate, :roles => :web do - send(run_method, "update-rc.d -f apache2 remove") + run "#{sudo} update-rc.d -f apache2 remove" end - task :backup, :roles => :web do - # not yet implemented + # Apache vhost extras + # + # These are only used for generating vhost files with: + # + # cap deprec:apache:vhost + # + set(:apache_vhost_domain) { Capistrano::CLI.ui.ask 'Primary domain' } + set(:apache_vhost_server_alii) { + Capistrano::CLI.ui.ask('ServerAlii (space separated)' ).split(' ') + } + set :apache_vhost_access_log_type, 'combined' + set :apache_vhost_canonicalize_hostname, true + set(:apache_vhost_access_log) { + File.join(apache_log_dir, "#{apache_vhost_domain}-access.log") + } + set(:apache_vhost_error_log) { + File.join(apache_log_dir, "#{apache_vhost_domain}-error.log") + } + set(:apache_vhost_document_root) { + File.join('/var/apps', "#{apache_vhost_domain}", 'public') + } + set :apache_vhost_rack_env, false + # + task :vhost do + file = { + :template => 'vhost.erb', + :path => "/etc/apache2/sites-available/#{apache_vhost_domain}", + :mode => 0644, + :owner => 'root:root' + } + if ! File.exists? 'config' + file[:path] = "../../#{apache_vhost_domain}" + end + deprec2.render_template(:apache, file) end - task :restore, :roles => :web do - # not yet implemented - end - + # End apache vhost extras end end end