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

on roles(:role_name) blocks are not skipped correctly #740

Closed
tetherit opened this issue Oct 28, 2013 · 4 comments
Closed

on roles(:role_name) blocks are not skipped correctly #740

tetherit opened this issue Oct 28, 2013 · 4 comments

Comments

@tetherit
Copy link

I have this in my task:

on roles(:agent) do |host|
  puts "this should never run!!!!"
end

When I run it for a server that does not have :agent in the role list, I see this:

 WARN [SKIPPING] No Matching Host for /usr/bin/env sudo echo
this should never run!!!!

I think it would make a lot more sense if the entire block is skipped, otherwise expensive calculations, local database operations, file preparations, all kinds of local stuff is still ran when it should really be skipped.

@leehambley
Copy link
Member

Happy to take a PR if you can make it work without breaking backwards
compatibility, this will need to be implemented in sshkit.
On 28 Oct 2013 23:18, "hackeron" notifications@github.com wrote:

I have this in my task:

on roles(:agent) do |host|
puts "this should never run!!!!"end

When I run it for a server that does not have :agent in the role list, I
see this:

WARN [SKIPPING] No Matching Host for /usr/bin/env sudo echo
this should never run!!!!

I think it would make a lot more sense if the entire block is skipped,
otherwise expensive calculations, local database operations, file
preparations, all kinds of local stuff is still ran when it should really
be skipped.


Reply to this email directly or view it on GitHubhttps://github.com//issues/740
.

@tetherit
Copy link
Author

I will have a look but I am not familiar with the code.

This workaround seems to work though! -

on roles(:cloud) do |host|
      next unless host

@leehambley
Copy link
Member

I suppose the question is what should happen in this case:

on [] do |host|
  puts "this should never run!!!!"
end

As in that event, on evaluates the block once, in each server backend instance, and if there are none, then nothing should happen.

@leehambley
Copy link
Member

Closing, although I admit this is a problem, because I think it was fixed by a recent PR. I'd be really, really glad to see this fixed, and I really thought it was.

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

No branches or pull requests

1 participant