Jenkins: choose among different deployment methods (Master slave vs ansible) - jenkins

I have three VMs which I have used to deploy develop, staging and master branch of a project.
Lets say jenkins is running on VM named JEN
Develop branch on VM named DEV
Staging branch on VM named STAGE
And Master branch on VM named MASTER
I have made three slave node (DEV, STAGE, MASTER) on Jenkins and thee different branch's Jenkinsfile run on different VMs(DEV, STAGE, MASTER).
Another approch I am coming through is:
Not to make DEV, STAGE, MASTER as slave node. That is we have only one Jenkins Agent (JEN).
Run pipeline and the tests in it on JEN and use ANSIBLE to deploy remotely on (DEV, STAGE, MASTER)
How would that compare with the first approach?

First, I believe it is Ansible, not ancible.
Second, the interest of an Ansible deployment model is that is is agentless (as opposed to Jenkins, which needs an agent listener agent.jar)
So if what you need to deploy is not the sources but deliverables, Ansible is more suited for that task, provided the target machines are accessible through SSH.
The Jenkins pipeline would simply do a tower_cli call to the right Ansible Job Template: that is what I have in my deployment platform.

Related

single jenkins job to deploy all the application to k8s

we have 150 applications which has individual jenkins file for each application in Git repository. we deploying each application one by one in Jenkins by triggering desired branch and when it reaches to k8s deployment stage in pipeline, we need to select the environment dev/test/prod from the dropdown there to deploy in desired environment. Now I need help to prepare a single jenkins job to deploy all the 150 applications to k8s at a time. Please suggest step by step process if any..

Jenkins - Master Strategy for Prod & Non-Prod Environments

I am trying to get a CI/CD pipeline going, my problem arises from having to create separate Jenkins instances of Prod and Non-Prod environments.
My CI/CD setup is pretty basic, I use a jenkinsfile with a series of standard steps, that are automatically triggered by pull request approvals on develop or master branches. Now if we go with 2 separate Jenkins masters, one per environment, how can the pipeline still work? So basically, when pull requests are approved on develop branch, Jenkinsfile executes a bunch of steps (test-build-archive artifact) on Non-Prod Jenkins Master and when pull requests are approved on master branch, Jenkinsfile executes steps(promote archived artifact to prod) on Prod Jenkins Master.

Jenkins 2.x Slave-Agent Variables in Pipelines

I have tried every permutation that I can find to pull a pre-existing variable from a specific Jenkins Slave and I cannot find a solution.
We have a git branch variable defined on each slave agent as a default branch for all builds initiated on that slave. This is to ensure that all DSL scripted job config is tested on our dev machine before it is promoted to a higher jenkins environment.
I have created a pipeline that will build all the components needed to stand up a new jenkins (with all of our enterprise deployment pipelines created) and it needs access to that one specific variable to correctly build the jobs based on the jenkins master/slave combo that it is running on.
I need a way (in a jenkinsfile) to access the variables that are configured on a particular jenkins slave machine.

spread job equally on Jenkins slaves

I added 3 new slaves to my jenkins master, so at the total my master has 5 powerful slaves. All of them from the same instance type (RAM/CPU, Disks and same network).
My Master jenkins is 2.78.
I am not using "Restrict where this project can be run" plugin. However, Jenkins executes builds mostly on slave1 and slave2. It rarely executes jobs on slaves[3-5].
Is there a configuration option within Jenkins, that prioritises the slaves?

Jenkins Master/Slave configuration

I've been reading about Jenkins master/slave configurations but I still have some questions:
Is it so that the slave Jenkins is not actually installed and started up the way master Jenkins is? I assumed I would install one master Jenkins and another slave Jenkins in the same way, and then master Jenkins would control the slave e.g. through SSH? So I cannot view the slave Jenkins through a GUI?
The reason why I have thought about adding a slave Jenkins on another VM is because the VM contains our application servers (many test environments). Deploying and starting/stopping application servers from master Jenkins is a pain because master Jenkins and application servers are on different machines. Therefore, if I would add a slave Jenkins to the machine where our application servers are, these would actually be deployed and started/stopped locally (by slave Jenkins). I wonder if I have missed something, of if my presumptions are still valid.
In a standard Jenkins master/slave setup, Jenkins is only installed on the master. That is where you see the user interface and start/configure build jobs.
The slaves execute the jobs. There is no Jenkins installation here other than a small Java app to have Jenkins communicate to/from the slave. Jenkins talks to these slaves through the slave.jar app over e.g. SSH via the SSH Slaves Plugin and can monitor if the slave is running, etc.
So in your case, you can start jobs from the master that will execute on the application servers.
The master/slave setup also allows you to host all whole bunch of different slaves, with different OSes, different hardware, etc. You can communicate job results (artifacts) from one slave to another via the Copy Artifacts Plugin.
There are also ways to duplicate the actual Jenkins master with load balancing in a heavy use scenario. That is not what you seem to be looking for.

Resources