forward3d/cap-ec2

Multiple Roles Not Defining Properly, Migrations not running

Closed this issue · 6 comments

The problem I was having was that the app wasn't running migrations or precompiling assets. So in diving in, here's what I found.

My ec2 server is currently one machine, all roles.

In my deploy.rb, if i set bundle_role: :all and migration_role: all, it works.

In my staging.rb, I have the following

ec2_role :app, user: :ubuntu
ec2_role :web, user: :ubuntu
ec2_role :cron, user: :ubuntu
ec2_role :db, user: :ubuntu

I additionally found that if I put ec2_role: db, user: ubuntu as the first line of my production.rb, it works. When it was working, I outputted the results of fetch(:migration_role) and found the following

[#<Capistrano::Configuration::Server:0x00000105b75dd0 @user=:ubuntu, @hostname="ec2-54-221-198-113.compute-1.amazonaws.com", @port=nil, @properties=#<Capistrano::Configuration::Server::Properties:0x00000105b75808 @properties={:aws_instance_id=>"i-ce3a3225"}, @roles=#<Set: {:db}>>, @ssh_options={}, @netssh_options={:user=>:ubuntu, :forward_agent=>true}>]

What it looks like to me, is that the only role that's being defined is the first role.

Additionally, I need to rewrite the migration task from capistrano/rake to not use the "primary" server, which doesn't appear to work regardless of how I tag an ec2_role with primary: true. https://github.com/capistrano/rails/blob/master/lib/capistrano/tasks/migrations.rake

Am I missing something? Or are these bugs?

It looks like I'm having the same issue. Going to take a look at this tonight.

@ejhayes Did you manage to find out what was causing this? I am hitting the same issue.

TL;DR It works if you downgrade capistrano to version 3.3.4.

I did some exploration, and it turns out that this is caused by a bug in Capistrano which was fixed at some point but then re-introduced (I think) here: capistrano/capistrano@70d21f2

You can follow the links back from my comment on that commit if you want the details.

Aha...I wasn't able to find any major faults with this gem...never thought to try out different versions of capistrano. Thanks for posting your solution @chopmo!

Thanks @chopmo. I'll chime back in when we get to implementing this.

I believe this is fixed in upstream now.