While deploying Rails 3 application on EC2 with RDS(Free instance) we are getting following error.
* executing "cd /home/ubuntu/integrity_matters/releases/20150318063048 && bundle exec rake RAILS_ENV=production db:migrate"
servers: ["52.10.245.227"]
[52.10.245.227] executing command
** [out :: 52.10.245.227] /home/ubuntu/integrity_matters/shared/bundle/ruby/2.2.0/gems/activesupport-3.2.17/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now
** [out :: 52.10.245.227]
** [out :: 52.10.245.227] rake aborted!
** [out :: 52.10.245.227]
** [out :: 52.10.245.227] FATAL: role "ubuntu" does not exist
deployment.rb
require "bundler/capistrano"
require "rvm/capistrano"
server "IP_ADDRESS", :web, :app, :db, primary: true
set :application, "integrity_matters"
set :user, "ubuntu"
ssh_options[:keys] = ["~/.ssh/im_ec2_free.pem"]
set :deploy_to, "/home/#{user}/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :scm, "git"
set :repository, "git@github.com:BoTreeConsultingTeam/IntegrityMatters.git"
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
after "deploy", "deploy:cleanup" # keep only the last 5 releases
after "deploy", "deploy:migrate"
namespace :deploy do
# Reference: http://ift.tt/1MIWfEE
task :symlink_assets, :roles => [:app, :db, :web] do
run "ln -nfs #{shared_path}/assets #{deploy_to}/assets"
end
after "deploy", "deploy:symlink_assets"
# Reference: http://ift.tt/1FvEqZj
task :cold do
transaction do
update
setup_db #replacing migrate in original
start
end
end
task :setup_db, :roles => :app do
raise RuntimeError.new('db:setup aborted!') unless Capistrano::CLI.ui.ask("About to `rake db:setup`. Are you sure to wipe the entire database (anything other than 'yes' aborts):") == 'yes'
run "cd #{current_path}; bundle exec rake db:setup RAILS_ENV=#{rails_env}"
end
%w[start stop restart].each do |command|
desc "#{command} unicorn server"
task command, roles: :app, except: {no_release: true} do
run "/etc/init.d/unicorn_#{application} #{command}"
end
end
task :setup_config, roles: :app do
sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}"
run "mkdir -p #{shared_path}/config"
put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
puts "Now edit the config files in #{shared_path}."
end
after "deploy:setup", "deploy:setup_config"
task :symlink_config, roles: :app do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
after "deploy:finalize_update", "deploy:symlink_config"
after "deploy", "deploy:assets:precompile"
end
database.yml
production:
adapter: postgresql
encoding: unicode
host: HOST_COPIED_FROM_RDS
reconnect: false
pool: 5
user_name: imdeploy
password: ****
port: 5432
Please not that if I connect to EC2 server via ssh with ubuntu
user, I am able to connect to RDS from EC2 server with following commands
$ psql -h HOST_COPIED_FROM_RDS --port=5432 --username=imdeploy --password --dbname=prod_rds_integrity_matters
Further here is list of DB and permission details
prod_rds_integrity_matters=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
----------------------------+----------+----------+-------------+-------------+-----------------------
postgres | imdeploy | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
prod_rds_integrity_matters | imdeploy | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
rdsadmin | rdsadmin | UTF8 | en_US.UTF-8 | en_US.UTF-8 | rdsadmin=CTc/rdsadmin
template0 | rdsadmin | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/rdsadmin +
| | | | | rdsadmin=CTc/rdsadmin
template1 | imdeploy | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/imdeploy +
| | | | | imdeploy=CTc/imdeploy
(5 rows)
prod_rds_integrity_matters=> \du
List of roles
Role name | Attributes | Member of
---------------+------------------------------------------------+-----------------
imdeploy | Create role, Create DB +| {rds_superuser}
| Password valid until infinity |
rds_superuser | Cannot login | {}
rdsadmin | Superuser, Create role, Create DB, Replication+| {}
| Password valid until infinity |
rdsrepladmin | No inheritance, Cannot login, Replication | {}
I also tried setting set :use_sudo, true
in deploy.rb
but still getting same issue.
Aucun commentaire:
Enregistrer un commentaire