Jenkins Slave Setup-1
As we all know jenkins is CI/CD tool it is used to schedule jobs.We can schedule multiple jobs using jenkins. These makes a little bit burden on Jenkins master.To reduce that burden we use slave nodes.These slave nodes takes the burden of some jobs from master.
One master can have any number of slaves.
à In my enviornment i am using 3 vms
1.server1.abc.com
2.server2.abc.com
3.server3.abc.com
à The server1.abc.com i am using as jenkins master and server2.abc.com i want to make slave for the server1.abc.com.
To make a slave i don't need to install jenkins on server2.abc.com.
à In this case i installed jenkins on server1.abc.com only.when you install jenkins it creates a user with jenkins on server1. You can't login using that jenkins user.to login with that user we do following things.
Go to
[root@server1 ~]# vi /etc/passwd
As we all know jenkins is CI/CD tool it is used to schedule jobs.We can schedule multiple jobs using jenkins. These makes a little bit burden on Jenkins master.To reduce that burden we use slave nodes.These slave nodes takes the burden of some jobs from master.
One master can have any number of slaves.
à In my enviornment i am using 3 vms
1.server1.abc.com
2.server2.abc.com
3.server3.abc.com
à The server1.abc.com i am using as jenkins master and server2.abc.com i want to make slave for the server1.abc.com.
To make a slave i don't need to install jenkins on server2.abc.com.
à In this case i installed jenkins on server1.abc.com only.when you install jenkins it creates a user with jenkins on server1. You can't login using that jenkins user.to login with that user we do following things.
Go to
[root@server1 ~]# vi /etc/passwd
jenkins:x:500:500:jenkins:/home/jenkins:/bin/false
change that false as bash
jenkins:x:500:500:jenkins:/home/jenkins:/bin/bash
à Then give sudo permissions to the jenkins user using visudo command as follws
[root@server1 ~]# visudo
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
test ALL=(ALL) NOPASSWD:ALL
dhoni ALL=(ALL) NOPASSWD:ALL
jenkins ALL=(ALL) NOPASSWD:ALL
Esc+Shift+wq+: Save it
à Then goto server2.abc.com create a user with the a name of jenkins and give sudo permissions to him.as below
[root@server2 ~]# useradd jenkins
[root@server2 ~]# passwd jenkins
Changing password for user jenkins.
New password:
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
à
[root@server1 ~]# visudo
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
jenkins ALL=(ALL) NOPASSWD:ALL
Esc+Shift+wq+: Save it
à Now login on server1.abc.com as jenkins by simply below command switch user(su)
[root@server1 ~]# su jenkins
bash-4.1$ ssh-keygen
Then Press Enter you will get the below text
Generating public/private rsa key pair.
Enter file in which to save the key (/var/lib/jenkins/.ssh/id_rsa):
Created directory '/var/lib/jenkins/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /var/lib/jenkins/.ssh/id_rsa.
Your public key has been saved in /var/lib/jenkins/.ssh/id_rsa.pub.
The key fingerprint is:
47:39:ed:50:b5:ab:1c:08:24:a8:5a:da:83:5e:dd:89 jenkins@server1.abc.com
The key's randomart image is:
+--[ RSA 2048]----+
| .. . ... |
| . o + . |
| . . = . . |
| o o = . |
| * . o S o o . |
|+ o. E o . . o |
|. .. o |
| . |
| |
+-----------------+
à
Then copy that key to server2.abc.com
bash-4.1$ ssh-copy-id server2.abc.com
The authenticity of host 'server2.abc.com (192.168.33.11)' can't be established.
RSA key fingerprint is 90:d8:41:6f:c5:39:1d:54:0d:43:4e:34:dc:f1:d2:6b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'server2.abc.com,192.168.33.11' (RSA) to the list of known hosts.
jenkins@server2.abc.com's password:
Now try logging into the machine, with "ssh 'server2.abc.com'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
à
Check it wheather its working or not by below command.
bash-4.1$ ssh server2.abc.com
[jenkins@server2 ~]$ exit
logout
Connection to server2.abc.com closed.
à
To exit from the bash script.
bash-4.1$ exit
exit
[root@server1 ~]#
If you face any problem while practicing feel free to comment it and Bookmark this blog for quick reference.We will try to help you
Thanks
Devops Desk Team
Devops Desk Team
No comments:
Post a Comment