Limiting tasks via ROLES environment varables

57 views
Skip to first unread message

Carlos Peñas

unread,
Feb 22, 2014, 5:30:52 AM2/22/14
to capis...@googlegroups.com
Hi

In capistrano 2.15 I'm getting some trouble limiting task execution,
using ROLES environment variables

if I use ROLES=role and call a task which have some "after" hooks, the
tasks indicated by these hooks are called regardless the roles indicated
in the task.

For example in this example cap file:

server "127.0.0.1", :web, :app
server "127.1.1.1", :app, :db

task :do_all do
  run "echo hi do all"
end

task :do_db, :roles => :db do
  run "echo hi do db"
end
after :do_all, :do_db

task :do_app, :roles => :app do
  run "echo hi do app"
end
after :do_all, :do_app

task :do_web, :roles => :db do
  run "echo hi do web"
end
after :do_all, :do_web

If I call ROLES="db" cap do_all

I get:

  * 2014-02-22 11:15:33 executing `do_all'
  * executing "echo hi do all"
    servers: ["127.1.1.1"]
Password:
    [127.1.1.1] executing command
 ** [out :: 127.1.1.1] hi do all
    command finished in 13ms
    triggering after callbacks for `do_all'
  * 2014-02-22 11:15:44 executing `do_db'
  * executing "echo hi do db"
    servers: ["127.1.1.1"]
    [127.1.1.1] executing command
 ** [out :: 127.1.1.1] hi do db
    command finished in 3ms
  * 2014-02-22 11:15:44 executing `do_app'
  * executing "echo hi do app"
    servers: ["127.1.1.1"]
    [127.1.1.1] executing command
 ** [out :: 127.1.1.1] hi do app
    command finished in 3ms
  * 2014-02-22 11:15:44 executing `do_web'
  * executing "echo hi do web"
    servers: ["127.1.1.1"]
    [127.1.1.1] executing command
 ** [out :: 127.1.1.1] hi do web
    command finished in 3ms

So the ROLES variable is limiting the server to apply the tasks but not
the tasks applied. I'd expected do_all, do_db but not do_web and do_app

Is there a way to achieve the behavior I expected? Im stuck in this
scheme of after :this, :do_that and I really need do partial task apply
to a role

Thanks.

Donovan Bray

unread,
Feb 22, 2014, 3:12:54 PM2/22/14
to capis...@googlegroups.com


--
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/5187fb3e-6e14-42ea-82c1-1c162d174d5f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Carlos Peñas

unread,
Feb 24, 2014, 4:14:08 AM2/24/14
to capis...@googlegroups.com, donn...@donovanbray.com


On Saturday, February 22, 2014 9:12:54 PM UTC+1, dbray wrote:

HOSTFILTER do not work as I wanted, indeed HOSTFILTER behaves the same as my ROLES try.

(pastie whit new output)  http://pastie.org/8764556

I want to partially apply a series of tasks and my problem is not to limiting servers.

My problem is once I limit server via HOSTS, ROLES, HOSTFILTER or HOSTROLEFILTER the servers chosen behaves like it belongs to all roles and apply tasks I dont want to apply in a chain. And I need a way to limit servers which only apply the tasks which belogns to the roles declared in the limited servers

So my goal with this (simple example) Capfile http://pastie.org/8764626 is be able to limit server only to 127.1.1.1 and apply only do_all -> do_db and not do_app and do_web

But sems that the code behind ROLES stuff states "Pick the servers whit role <$ROLES> and apply to it all tasks" instead of "Pick the servers whit role <$ROLES> and apply to it <$ROLES> tasks"
 

Carlos Peñas

unread,
Feb 24, 2014, 4:25:46 AM2/24/14
to capis...@googlegroups.com, donn...@donovanbray.com


So my goal with this (simple example) Capfile http://pastie.org/8764626 is be able to limit server only to 127.1.1.1 and apply only do_all -> do_db and not do_app and do_web

This is the good pastie http://pastie.org/8764863
 
Reply all
Reply to author
Forward
0 new messages