How to run Jenkins on multiple virtual servers?

I installed Jenkins on a server, by default the job will only run on that server. My requirement from my Jenkins is how can I run the same job on multiple servers? How will it ssh on other servers? I'm new to Jenkins, please help. Basically my goal is to deploy my application to multiple servers.

+3


source to share


5 answers


You can use any configuration management tool like Truthful, Chef or Capistrano like jenkins work orders so they can do your jenkins job. You can specify the number of servers in the capistrano cookbook, and whenever you build a job, it will run your job on all servers.



There is also a tool like pssh (parallel ssh) if you want to use ssh.

+2


source


Limitless is the best way to do this. Ansible:

Install Ansible on the same server where Jenkins is installed.

Configure data for multiple servers in a host file under the same name.

Mention the tasks in the Ansible-playbook that will be performed on all mentioned servers.



internal process: it will run a job on multiple servers via ssh in it

or

use a shell script on your Jenkins installed server and use a shell command along with ssh username @ip "#cmd" // mulitple server ip

+3


source


You can use the Master-Slave concept. Install jenkins slave on all other machines, that is, in your case, other application servers. You can find more details on Jenkins' slave concept from here .

You can then use the same job to run on other application servers.

+1


source


I think using one job with post build steps that you can deploy to multiple servers.

Let me know if any fixes

0


source


Using the Master-Slave concept, you can add a Jenkins slave agent on multiple slaves so that you can deploy them.

You can deploy in two ways, either using Jenkins node pipeline syntax, or using Ansible-Playbook via Building Script:

The first path in the Jenkins file will be as follows:

node('node1') {
   // Building Stages on node 1
}

node('node2') {
   // Building Stages node 2
}

      

The second path will be the same as in the Jenkins file:

node('master_node'){
// master node has the ansible-playbook

ansiblePlaybook credentialsId: 'ansible_ssh_user', inventory: 'path_to_inventory_file', playbook: 'path_to_playbook', sudo: true, sudoUser: 'sudo_user_name'

}

      

This method requires the Ansible-plugin to be installed on Jenkins Master Node. and you can put all the nodes you need in the inventory file.

The main difference between the two methods, besides Idempotence, is that the first method will provide sequential execution, and the second method will allow parallel execution using Ansible.

0


source







All Articles