Performing tasks in remote servers as slave or SSH?

25 views
Skip to first unread message

hezjing

unread,
Jan 27, 2016, 8:03:33 PM1/27/16
to Jenkins Users
Hi

I want to create a job that will login to multiple remote servers (and with multiple user accounts) and install some products. How should I create this job?

One way is to create a slave node for every user in each of the remote servers, then trigger the job on that specific slave node.

Another way is use SSH plugin that login to the remote hosts and execute the commands.

What are the differences between these two ways? Any better idea?


Dirk Heinrichs

unread,
Jan 28, 2016, 1:37:15 AM1/28/16
to jenkins...@googlegroups.com
Am 28.01.2016 um 02:03 schrieb hezjing:

What are the differences between these two ways? Any better idea?

The difference is that you'd need to solve how to access the different user accounts via ssh (distribute, possibly passwordless, keys) and also get the commands right for remote execution.

How about using one slave per node and use sudo to execute commands as different users? This way, you get fine grained control over what the Jenkins user is allowed to execute as those other users and, at the same time, avoid the key management hassle.

HTH...

    Dirk
--

Dirk Heinrichs, Senior Systems Engineer, Engineering Solutions
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Tel: +49 2226 1596666 (Ansage) 1149
Email: d...@recommind.com
Skype: dirk.heinrichs.recommind
www.recommind.com

Maciej Jaros

unread,
Jan 28, 2016, 6:13:26 AM1/28/16
to jenkins...@googlegroups.com
hezjing (2016-01-28 02:03):
One blocker would be if you have a Windows machine to test. SSH on Windows is very unstable (or at least I haven't found any that would work fine with Jenkins).

For Linux machines I find it easier to setup SSH connection and it's handy anyway. Just remember to generate password-less key. Then for each machine just use `ssh-copy-id` to set it up.

Sometimes I even find it more convinet to use `scp` and `ssh` commands in jenskins as you can easily do loops like:
serverList=(app1 app2 app5 app7)
for appServer in ${serverList[@]}
do
  connectionString="root@$appServer"
  scp commands.sh $connectionString:/remote/path/commands.sh
  ssh $connectionString "cd /remote/path/; commands.sh"
done

I don't think you can easily do something like that with slaves. But maybe you can with Groovy scripts? Haven't tried.

Regards,
Nux.

Dirk Heinrichs

unread,
Jan 28, 2016, 7:06:45 AM1/28/16
to jenkins...@googlegroups.com
Am 28.01.2016 um 12:12 schrieb Maciej Jaros:

One blocker would be if you have a Windows machine to test. SSH on Windows is very unstable (or at least I haven't found any that would work fine with Jenkins).

Cygwin/SSH works just fine.

Bye...
Reply all
Reply to author
Forward
0 new messages