Jenkins is a continuous integration (CI) / continuous delivery (CD) platform consisting of a Jenkins master - essentially a controller - which launches jobs on Jenkins slaves. Often slaves are controlled via SSH.
Recently I ran into an issue with a legacy Jenkins slave where the "jenkins" where Puppet tried to enforce the home directory of "jenkins" to be /home/jenkins instead of /var/lib/jenkins:
Error: Could not set home on user[jenkins]: Execution of '/usr/sbin/usermod -d /home/jenkins jenkins' returned 8: usermod: user jenkins is currently used by p rocess 802
The usermod command failed because several Jenkins processes (ssh-agent, Java) locked the user from modification. The solution was relatively straightforward:
- Mark slave as offline from Jenkins master
- pkill jenkins
- run puppet (sets correct home directory)
- mv /var/lib/jenkins /home/
- Change slave directory to /home/jenkins on the Jenkins master
- Mark slave as online on Jenkins master
- Start slave from Jenkins master