Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Using conditional check for hosts in task definition
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Noman Amir Jamil  
View profile  
 More options Feb 8, 4:12 am
From: Noman Amir Jamil <n.amir.ja...@gmail.com>
Date: Wed, 8 Feb 2012 13:12:34 +0400
Local: Wed, Feb 8 2012 4:12 am
Subject: Using conditional check for hosts in task definition

Hi All,

I was wondering if it is possible to include a conditional check in task
definition. For example, I have a task defined:

task :check_tomcat6_status, :roles => :app do
    sudo "/sbin/service tomcat6 status"
    run "sleep 15s"
end

I want to introduce a conditional hosts check in it, like:

if :hosts = host1 then
   sudo "/sbin/service tomcat5 status"
else
  sudo "/sbin/service tomcat6 status"
fi
 run "sleep 15s"
end

Can someone help me with the correct syntax for this scenario?

Thanks
Noman A.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lee Hambley  
View profile  
 More options Feb 8, 4:24 am
From: Lee Hambley <lee.hamb...@gmail.com>
Date: Wed, 8 Feb 2012 10:24:13 +0100
Local: Wed, Feb 8 2012 4:24 am
Subject: Re: [capistrano] Using conditional check for hosts in task definition

That's not possible, as the task body runs in parallel on all hosts.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rafa García  
View profile  
 More options Feb 8, 6:10 am
From: Rafa García <conta...@rafagarcia.net>
Date: Wed, 8 Feb 2012 12:10:06 +0100
Local: Wed, Feb 8 2012 6:10 am
Subject: Re: [capistrano] Using conditional check for hosts in task definition

Hi Noman,

  You can do it using shellscript:

task :check_tomcat_status, :roles => :app do
    run "#{sudo} /usr/local/sbin/check_tomcat_status.sh"
    run "sleep 15s"
end

Being check_tomcat_status.sh a shell script that check, i.e., if service
tomcat6 exists and do the work else do the work with tomcat5

   Another option could be define the role with tomcat5 and tomcat6
modifier:

role :app, "127.0.0.1", :tomcat5 => true
role :app, "127.0.0.2", :tomcat6 => true

   Later define the task:

task :check_tomcat_status, :roles => :app do
    run "#{sudo} /sbin/service tomcat5 status", :only => {:tomcat5 => true}
    run "#{sudo} /sbin/service tomcat6 status", :only => {:tomcat6 => true}
    run "sleep 15s"
end

Regards

Note: The sudo use as run command is deprecated, last
paragraph<https://github.com/capistrano/capistrano/wiki/2.x-DSL-Action-Invokati...>
[1]

[1]
https://github.com/capistrano/capistrano/wiki/2.x-DSL-Action-Invokati...

2012/2/8 Noman Amir Jamil <n.amir.ja...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Noman Amir Jamil  
View profile  
 More options Feb 8, 7:07 am
From: Noman Amir Jamil <n.amir.ja...@gmail.com>
Date: Wed, 8 Feb 2012 16:07:42 +0400
Local: Wed, Feb 8 2012 7:07 am
Subject: Re: [capistrano] Using conditional check for hosts in task definition

Hi Garcia,

Thank you so much for the detailed input. I will give both the options a
shot and see which one gets my task done!

Regards
Noman A.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »