the :only => { :primary => true } and :except => { :primary => true }
work as intended... but ONLY if I have at least 1 server that matches
each scenario.Not every environment that I deploy to is guaranteed to have multiple servers... some have 1, some have 2 and some have more than 2. I'm trying to have 1 deploy script that works for all my scenarios (using multi-stage)... but for the single server setups, the original run commands fail when there are no servers beyond the primary. Thoughts? On Dec 4, 9:30 pm, Donovan Bray <[email protected]> wrote: > You could set :primary => false on any non primary servers and change > your run mycommand2 to :only => { :primary => false } > > Keep in mind :primary must be set to false not omitted from the :role > specification. > > If your use case supports it you may be able to: > > > run "my command 2", :roles => :app > > run "my command 1", :roles => :app, :once => true > > As long as c1 will overwrite the state of c2 and it's not critical > which server c1 is ran on; just that it's ran once. > > On Dec 4, 2009, at 6:59 AM, jmadtech <[email protected]> wrote: > > > Hello all, > > > I am currently trying to write a set of task commands that run based > > on whether or not a particular server within the role attached to the > > task is the primary server. > > > So for example, I have the following: > > > task :push_my_configs, :on_error => :continue do > > run "my command 1", :roles => :app, :only => { :primary => true } > > run "my command 2", :roles => :app, :except => { :primary => > > true } > > end > > > This works perfectly if I have the following: > > > role :app, "mydomain1.com", :primary => true > > role :app, "mydomain2.com" > > > it executes command 1 on mydomain1.com and command 2 on mydomain2.com > > exactly as I intend. However, if I have a situation where I only have > > 1 server, I get an error on one or the other command (depending on > > whether or not I have the single server denoted as the primary). > > > 'configs:push_my_configs' is only run for servers matching {}, but no > > servers matched. > > > I'd be ok with the error if I could get it to proceed, but it won't. > > It hits that and exits the deploy script. > > > How do I handle this situation? > > > Thanks in advance! > > > -- > > * You received this message because you are subscribed to the Google > > Groups "Capistrano" group. > > * To post to this group, send email to [email protected] > > * To unsubscribe from this group, send email to > > [email protected] > > For more options, visit this group > > athttp://groups.google.com/group/capistrano?hl=en -- * You received this message because you are subscribed to the Google Groups "Capistrano" group. * To post to this group, send email to [email protected] * To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/capistrano?hl=en
