Sha256: e391c022b3da332994d01a978b113ccbb18abe1d60a176cdc7c2d9e3f7add8c5

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

namespace :nginx do
  task :install do
    on roles :web, :api do
      execute "#{apt_nointeractive} nginx"
      execute 'sudo sed -i "s/# server_names_hash_bucket_size 64/server_names_hash_bucket_size 64/" /etc/nginx/nginx.conf'
      template 'vhost.conf', '/etc/nginx/conf.d/vhost.conf'

      invoke 'nginx:restart'
    end
  end

  task :cert do
    on roles(:web, :api) do |host|
      run_locally do
        run_in host, <<-EOBLOCK
          sudo snap install --classic certbot
          sudo ln -s /snap/bin/certbot /usr/bin/certbot
          sudo certbot --nginx -m admin@#{host.hostname} --non-interactive --agree-tos --domains #{host.hostname}
        EOBLOCK
      end
    end
  end

  task :ssl do
    on roles(:web, :api) do |host|
      template 'vhost_ssl.conf', '/etc/nginx/conf.d/vhost.conf'
      invoke 'nginx:restart'
    end
  end

  %w(start stop restart status).each do |action|
    desc "Nginx"
    task :"#{action}" do
      on roles(:web, :api) do
        execute "sudo service nginx #{action}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
prun-ops-0.3.3 lib/capistrano/config/nginx.rake
prun-ops-0.3.2 lib/capistrano/config/nginx.rake
prun-ops-0.3.1 lib/capistrano/config/nginx.rake