diff --git a/.gitignore b/.gitignore index 0cb6eeb..0b801b8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,9 @@ /pkg/ /spec/reports/ /tmp/ + +.vagrant +/vagrant_example/Gemfile.lock +/vagrant_example/.bundle/ +/vagrant_example/vendor/ +/vagrant_example/tmp/ diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..49fe00c --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,21 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure(2) do |config| + config.vm.box = "ubuntu/trusty64" + + config.vm.provision "shell", inline: <<-SHELL + if ! dpkg -l | grep ruby2.2 > /dev/null; then + apt-add-repository ppa:brightbox/ruby-ng + apt-get update + apt-get install ruby2.2 -y + fi + gem install bundler --no-ri --no-rdoc + cp /vagrant/vagrant_example/.insecure_private_key /home/vagrant/.ssh/insecure_key + chmod 400 /home/vagrant/.ssh/insecure_key + chown vagrant:vagrant /home/vagrant/.ssh/insecure_key + if ! grep "`ssh-keygen -y -f .ssh/insecure_key`" /home/vagrant/.ssh/authorized_keys ;then + ssh-keygen -y -f .ssh/insecure_key >> .ssh/authorized_keys + fi + SHELL +end diff --git a/vagrant_example/.insecure_private_key b/vagrant_example/.insecure_private_key new file mode 100644 index 0000000..7d6a083 --- /dev/null +++ b/vagrant_example/.insecure_private_key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI +w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP +kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2 +hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO +Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDL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6/vURRbHSnnn8a/XG+nzedGH5JGqEJNQsz+xT2axM0/W/CRknmGaJ +kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH ++vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ +NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s= +-----END RSA PRIVATE KEY----- diff --git a/vagrant_example/Capfile b/vagrant_example/Capfile new file mode 100644 index 0000000..a0cf0b5 --- /dev/null +++ b/vagrant_example/Capfile @@ -0,0 +1,27 @@ +# Load DSL and set up stages +require 'capistrano/setup' + +# Include default deployment tasks +require 'capistrano/deploy' + +# Include tasks from other gems included in your Gemfile +# +# For documentation on these, see for example: +# +# https://github.com/capistrano/rvm +# https://github.com/capistrano/rbenv +# https://github.com/capistrano/chruby +# https://github.com/capistrano/bundler +# https://github.com/capistrano/rails +# https://github.com/capistrano/passenger +# +# require 'capistrano/rvm' +# require 'capistrano/rbenv' +# require 'capistrano/chruby' +# require 'capistrano/bundler' +# require 'capistrano/rails/assets' +# require 'capistrano/rails/migrations' +# require 'capistrano/passenger' + +# Load custom tasks from `lib/capistrano/tasks` if you have any defined +Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } diff --git a/vagrant_example/Gemfile b/vagrant_example/Gemfile new file mode 100644 index 0000000..c8e58c2 --- /dev/null +++ b/vagrant_example/Gemfile @@ -0,0 +1,5 @@ +# A sample Gemfile +source "https://rubygems.org" + +gem "capistrano" +gem "capistrano-s3_archive", path: '/vagrant' diff --git a/vagrant_example/config/deploy.rb b/vagrant_example/config/deploy.rb new file mode 100644 index 0000000..7521ccf --- /dev/null +++ b/vagrant_example/config/deploy.rb @@ -0,0 +1,50 @@ +# config valid only for current version of Capistrano +lock '3.4.0' + +set :application, 'my_app_name' + +set :repo_url, 's3:///' +set :s3_client_options, { region: 'ap-northeast-1' } # and credentials, etc if needed + +# Default branch is :master +# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp + +# Default deploy_to directory is /var/www/my_app_name +set :deploy_to, '/home/vagrant/my_app_name' + +# Default value for :scm is :git +set :scm, :s3_archive + +# Default value for :format is :pretty +# set :format, :pretty + +# Default value for :log_level is :debug +# set :log_level, :debug + +# Default value for :pty is false +# set :pty, true + +# Default value for :linked_files is [] +# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml') + +# Default value for linked_dirs is [] +# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system') + +# Default value for default_env is {} +# set :default_env, { path: "/opt/ruby/bin:$PATH" } + +# Default value for keep_releases is 5 +# set :keep_releases, 5 + +namespace :deploy do + + after :restart, :clear_cache do + on roles(:web), in: :groups, limit: 3, wait: 10 do + # Here we can do anything such as: + # within release_path do + # execute :rake, 'cache:clear' + # end + end + end + +end diff --git a/vagrant_example/config/deploy/production.rb b/vagrant_example/config/deploy/production.rb new file mode 100644 index 0000000..b5f5845 --- /dev/null +++ b/vagrant_example/config/deploy/production.rb @@ -0,0 +1,7 @@ +server 'localhost', + user: 'vagrant', + roles: ['web', 'app'], + ssh_options: { + auth_methods: ['publickey'], + keys: '/home/vagrant/.ssh/insecure_key' + }