Turning my new Intel NUCs into Jenkins slaves
So, I finally got a break from the long workdays to do a little tinkering with my new Intel NUCs, which I bought to configure a more robust CI environment on my network here at home. All three Intel NUCs are running Debian Jessie, and all are running with static IP addresses assigned on my Intranet here at the house.
I have Jenkins running on my original Intel NUC, but what I was really looking to do was kick off test sessions on my two new Intel NUCs and have those test results available through the one Jenkins innstance, and have that Jenkins instance manage all the jobs running on my two test boxes. The easiest way to do this is configure those two boxes as Jenkins slaves.
Step 1: Install Jenkins on both servers
Now, it is not necessary to install Jenkins, but I am looking for low maintenance for these boxes. Jenkins comes with a slave jar file that needs to be installed on any slave instances. Since I am running the same setup on all three boxes and I already have the Jenkins package downloaded and accessible on all three machines, it's a simple process to install Jenkins on all three boxes, and have the slave jar file readily available without having to install it. This also sets up my Jenkins user on all three machines, with the correct permissions. Now, the downside is this will launch Jenkins on the two slave boxes, which is not necessary, but it's a simple matter of just stopping the jenkins service with 'sudo service jenkins stop' on the two slave machines.
Step 2: Set up a directory for test results
For both servers, I set up a directory that will be used to store the test results:
(Intel NUC i7): /home/jenkins/jenkins-slaves/i7NUCRyH
(Intel NUC i5): /home/jenkins/jenkins-slaves/i5NUCRiR
After setting up the directories, I changed the owner of these directories to the Jenkins user.
Step 3: Generate a public/private keypair for the Jenkins master, and put the public key on the slaves
I won't go into the process to generate a public/private keypair here, you can google it and there is plenty of instructions available on the InterWebs. I generated this keypair on my master jenkins instance, as the Jenkins user.
I then shelled into each of the slave instances, changed my user to the Jenkins user on the instances, and placed the public key from my Jenkins master into the "authorized_keys" file in the .ssh directory for each of my slave instances.
Step 4: Configure the Jenkins master to use the private key as a global credential
Now to configure the Jenkins master so that it can authenticate to the slaves with the private key.
I logged into the Jenkins UI and clicked on "Credentials", and proceeded to configure the global credentials with my jenkins private key, attaching the username "jenkins" to this, and selected to use the private key from the Jenkins master ~/.ssh, and saved that configuration.
Now to hook up the slave instances.
Step 5: Add the slave nodes
In the Jenkins UI on the master Jenkins instance, click "Manage Jenkins > Manage Nodes". You'll see the master node shown. Click the "New Node" link in the left sidebar, and Give the Node a name, select the "Dumb Slave" radio button, and click "OK".
Both of my slave nodes have dual core processors, so I have 4 cores to work with; I set the "# of executors" to 4.
Set the remote root directory to the directory where your test will be executed; in my case I've set that to "/home/jenkins/jenkins-slaves/
Under "Label", enter the name of the machine.
Under Usage, set this to "Only build jobs with label restrictions matching this node". The "Label" is the field above this select box.
Under Launch method, I picked "Launch slave agents on Unix machines via SSH". This selection requires that you fill in the URL / IP address where the machine can be accessed via SSH in the "Host" field, and then you select the name of the credentials you established under "Global Credentials" earlier, where you set up the private key that was created for the slave machines.
Under "Availability" I selected "Keep this slave online as much as possible".
Under Node Tools, I selected the "Tool Locations" checkbox, selected "Git (default)" in the dropdown select.
I then configured the second slave node by copying the first node's profile, and changing the node specific settings I needed to change.
Step 6: Synchronise the Clocks
My listing of Slave nodes shows that the clocks on my two slave machines are not synchronized with the master Jenkins instance. This is easily solvable by installing and configuring "ntp" for each machine. I kept the default configuration for NTP for each. I came back to the Jenkins UI, and refreshed the status a few times until my nodes showed that all three system clocks were "in sync".