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 <agrimberg@linuxfoundation.org>
# 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
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
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