Sha256: 8896f738b956712c99b9e2e69b82b1c4b8d01abcd9b8181b6fd6a13a682bb271

Contents?: true

Size: 958 Bytes

Versions: 6

Compression:

Stored size: 958 Bytes

Contents

set :server_name, ->{ fetch(:application) }

namespace :nginx do
  desc "Installs nginx on all app servers"
  task :install do
    on roles(:app) do |host|
      execute :sudo, "apt-get -y update"
      execute :sudo, "apt-get -y install nginx"
    end
  end

  %w[start stop restart].each do |command|
    desc "#{command} nginx"
    task command do
      on roles :app do
        as :root do
          execute :service, "nginx #{command}"
        end
      end
    end
  end
end

namespace :nginx do
  namespace :rainbows do
    desc "Setup nginx configuration for this application (rainbows)"
    task :setup do
      on roles :web do
        template "nginx_rainbows.erb", "/tmp/nginx_conf"

        as :root do
          execute :mv, "/tmp/nginx_conf /etc/nginx/sites-enabled/#{fetch(:application)}"
          execute :rm, "-f /etc/nginx/sites-enabled/default"
        end
      end
      after 'nginx:rainbows:setup', 'nginx:restart'
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
capistrano-devops-0.0.9 lib/capistrano/tasks/nginx.rake
capistrano-devops-0.0.8 lib/capistrano/tasks/nginx.rake
capistrano-devops-0.0.7 lib/capistrano/tasks/nginx.rake
capistrano-devops-0.0.6 lib/capistrano/tasks/nginx.rake
capistrano-devops-0.0.5 lib/capistrano/tasks/nginx.rake
capistrano-devops-0.0.4 lib/capistrano/tasks/nginx.rake