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

Roles are ignored #3

Open
maxim opened this issue Aug 15, 2012 · 2 comments
Open

Roles are ignored #3

maxim opened this issue Aug 15, 2012 · 2 comments

Comments

@maxim
Copy link
Contributor

maxim commented Aug 15, 2012

I have a task similar to this:

namespace :provision do
  task :redis, roles: :redis do
    roundsman.run_list('recipe[redis::server]')
  end
end

And roles like this

role :web, 'web01'
role :app, 'app01'
role :db, 'db01', primary: true
role :redis, 'redis01'

When I run cap provision:redis, I expect it to run recipe[redis::server] only on redis01 host (as per README). Instead, it runs on every host.

  * 01:27:09 == Currently executing `roundsman:chef:chef_solo'
 ** Now running recipe[redis::server]
  * executing "sudo -p 'sudo password: ' chef-solo -c /tmp/roundsman/solo.rb -j /tmp/roundsman/solo.json"
    servers: ["web01", "app01", "db01", "redis01"]
    [db01] executing command
    [web01] executing command
    [redis01] executing command
    [app01] executing command

I made a sanity check by adding this test task.

task :foo, roles: :redis do
  run "echo foo"
end

Running cap foo only ran this task on redis server, as expected.

@maxim
Copy link
Contributor Author

maxim commented Aug 15, 2012

Turns out this is an ancient issue — capistrano won't scope roles of the nested task to the roles you specified on the caller task. Capistrano mailing list has a bunch of info on this, for example here is one possible solution. Worked ok for me to wrap each roundsman task in with_role block.

However, README is mistaken about this, and should be updated.

@kbrock
Copy link
Contributor

kbrock commented Jan 17, 2013

this was really screwing things up for me.

I converting almost all of roundsman capistrano tasks to methods. I'm happy with the results, but feel I may have been able to use roundsman unchanged if I understood capistrano more.

Also of note, roles are ignored when running with a HOSTS environment variable. So I could installing a run_list into the wrong computer. fixed this by defining the run_list in the roles section. (it introduced minor other problems, but works very well for my process)

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

2 participants