Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hosts filtering not working #1154

Open
RobinClowers opened this issue Oct 15, 2014 · 6 comments
Open

hosts filtering not working #1154

RobinClowers opened this issue Oct 15, 2014 · 6 comments

Comments

@RobinClowers
Copy link

I seem to have hit a bug with hosts filtering. I have a pretty simple setup with 2 servers, and when I try to deploy to only one (either with HOSTS=hostname or --hosts=hostname) I get an error about a release directory not existing on the other host.

@epifanov
Copy link
Contributor

epifanov commented Nov 7, 2014

Hi guys, I have same issue. @RobinClowers did you solve it somehow?

@epifanov
Copy link
Contributor

epifanov commented Nov 7, 2014

@RobinClowers do you use Rails? It could be rails specific problem: capistrano/rails#87

@RobinClowers
Copy link
Author

No, I didn't solve it. I am using rails, but I had the same issue with a custom task, so I don't think it's rails specific.

@epifanov
Copy link
Contributor

epifanov commented Nov 7, 2014

@RobinClowers I checked sources of capistrano-rails gem and found this: https://github.com/capistrano/rails/blob/master/lib/capistrano/tasks/migrations.rake#L7

It means that it searches primary servers with db role, so I added "primary:true" key in my deploy.rb config and it helped.

@qhwa
Copy link
Contributor

qhwa commented Feb 1, 2015

Hi, I came across the same issue on v3.3+.

It seems that it was supposed to ignore host filter?
https://github.com/capistrano/capistrano/blob/master/spec/integration/dsl_spec.rb#L106-L107

I added a hack in my capistrano plugin:

# Usage: 
# set_host_filter ['example1.com']
def set_host_filter hosts
  if defined? Capistrano::Configuration::Servers::HostFilter
    set :filter, hosts: hosts
  else
    # hack for Capistrano v3.3+
    Capistrano::Configuration.env.send(:servers).send(:servers).select! do |srv|
      hosts.include?(srv.hostname)
    end
  end
end

I think one can allow host filtering via command line by fixing Capistrano::Configuration::Servers#roles_for. I did but it broke some specs, so I gave up.

@will-in-wi
Copy link
Contributor

Is this still an issue in latest Capistrano? I use the hosts feature all the time and it works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants