Reputation: 1306
I have an Ant script on one Linux box which does a series of task locally on that box. I would like to leverage that same script on other Linux boxes.
Is there a way I can tell Ant to connect to that remote linux box via SSH then run the series of task as if it was on that server without copying the Ant script to the remote servers?
I know it is possible to use sshexec
, but I would have to do that for each task
, which in the end become a different script.
<sshexec host="${remote.host}"
username="${remote.user}"
password="${remote.pass}"
trust="true"
command="rm -rf ${remote.webapps.path}/ROOT*">
Upvotes: 0
Views: 1352
Reputation: 3739
You can encapsulate all the steps performed in a shell script and call it via sshexec
you can also write a parameterized ant macro/target that captures all the ssh commands . In this case all you need to do is call this target with a command/script and that should reduce the burdne of copy pasting commands
You can always pass in a specific command via a parameter For ex
<macrodef name="ssexec-wrapper>
<attribute name="exec-command/>
<attribute name="remote.host"/>
##Other variables as required
<sequential>
<sshexec host="@{remote.host} ... command=@{exec-command} failonerror="false|true"/>
</sequential>
</macrodef>
Upvotes: 1