From: Andrew Grimberg Date: Wed, 8 Jun 2016 15:15:02 +0000 (-0700) Subject: Rearrange the user creation step for slaves X-Git-Tag: release/beryllium-sr3~337 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=4995838d169f87cb135a3425f6bcc8f765e59b9b;p=releng%2Fbuilder.git Rearrange the user creation step for slaves With the change from JClouds to the OpenStack slave plugin we need to fully manage the creation of the Jenkins user. This modifies the timing of when the user gets created to be the last step. This will hopefully prevent us from having issues with the init scripts not having been completed before a job starts on the system. Secondly, we handle adding Jenkins to the docker group in a slightly more sane manner but without breaking our current production setup that executes some, but not all of these scripts and in a different order. Change-Id: I8d88cd0d9de6b3defd6615faa474e4ce8d583ea4 Signed-off-by: Andrew Grimberg --- diff --git a/jenkins-scripts/create_jenkins_user.sh b/jenkins-scripts/create_jenkins_user.sh index 238f335e1..f2874de33 100755 --- a/jenkins-scripts/create_jenkins_user.sh +++ b/jenkins-scripts/create_jenkins_user.sh @@ -4,9 +4,18 @@ # Create Jenkins User # ####################### -OS=`facter operatingsystem | tr '[:upper:]' '[:lower:]'` +OS=$(facter operatingsystem | tr '[:upper:]' '[:lower:]') -useradd -m -s /bin/bash jenkins +# Determine if we need to add jenkins to the docker group +grep -q docker /etc/group +if [ "$?" == '0' ] +then + GROUP='-G docker' +else + GROUP='' +fi + +useradd -m ${GROUP} -s /bin/bash jenkins mkdir /home/jenkins/.ssh mkdir /w cp -r /home/${OS}/.ssh/authorized_keys /home/jenkins/.ssh/authorized_keys diff --git a/jenkins-scripts/docker.sh b/jenkins-scripts/docker.sh index 365dc9574..c70408da3 100755 --- a/jenkins-scripts/docker.sh +++ b/jenkins-scripts/docker.sh @@ -6,7 +6,13 @@ Defaults:jenkins !requiretty jenkins ALL = NOPASSWD: /sbin/ifconfig EOF -/usr/sbin/usermod -a -G docker jenkins +# make sure jenkins is part of the docker only if jenkins has already been +# created +grep -q jenkins /etc/passwd +if [ "$?" == '0' ] +then + /usr/sbin/usermod -a -G docker jenkins +fi # stop firewall systemctl stop firewalld diff --git a/jenkins-scripts/jenkins-init-script.sh b/jenkins-scripts/jenkins-init-script.sh index dfb5ee858..88c5eb620 100755 --- a/jenkins-scripts/jenkins-init-script.sh +++ b/jenkins-scripts/jenkins-init-script.sh @@ -15,5 +15,8 @@ chmod +x *.sh source /tmp/system_type.sh ./basic_settings.sh -./create_jenkins_user.sh ./${SYSTEM_TYPE}.sh + +# Create the jenkins user last so that hopefully we don't have to deal with +# guard files +./create_jenkins_user.sh