Make distribution-check job an ODL-releng templated job
[releng/builder.git] / vagrant / baseline / bootstrap.sh
index 2eb7a3c6fbd60260bad47076c34a5f551615c80c..5abcf35b319c9f9c512d1c0cd67bf638ed6787b4 100644 (file)
@@ -25,13 +25,23 @@ rh_systems() {
         echo "*******************************************"
     fi
 
+    # Allow jenkins access to alternatives command to switch java version
+    cat <<EOF >/etc/sudoers.d/89-jenkins-user-defaults
+Defaults:jenkins !requiretty
+jenkins ALL = NOPASSWD: /usr/sbin/alternatives
+EOF
+
     echo "---> Updating operating system"
     yum clean all -q
     yum update -y -q
 
     # add in components we need or want on systems
     echo "---> Installing base packages"
-    yum install -y -q @base unzip xz puppet git perl-XML-XPath
+    yum install -y -q @base
+    # separate group installs from package installs since a non-existing
+    # group with dnf based systems (F21+) will fail the install if such
+    # a group does not exist
+    yum install -y -q unzip xz puppet git perl-XML-XPath
 
     # All of our systems require Java (because of Jenkins)
     # Install all versions of the OpenJDK devel but force 1.7.0 to be the
@@ -39,14 +49,36 @@ rh_systems() {
 
     echo "---> Configuring OpenJDK"
     yum install -y -q 'java-*-openjdk-devel'
-    alternatives --set java /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
-    alternatives --set java_sdk_openjdk /usr/lib/jvm/java-1.7.0-openjdk.x86_64
+
+    FACTER_OS=`/usr/bin/facter operatingsystem`
+    FACTER_OSVER=`/usr/bin/facter operatingsystemrelease`
+    case "$FACTER_OS" in
+        Fedora)
+            if [ "$FACTER_OSVER" -ge "21" ]
+            then
+                echo "---> not modifying java alternatives as OpenJDK 1.7.0 does not exist"
+            else
+                alternatives --set java /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
+                alternatives --set java_sdk_openjdk /usr/lib/jvm/java-1.7.0-openjdk.x86_64
+            fi
+        ;;
+        *)
+            alternatives --set java /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
+            alternatives --set java_sdk_openjdk /usr/lib/jvm/java-1.7.0-openjdk.x86_64
+        ;;
+    esac
 }
 
 ubuntu_systems() {
     # Ignore SELinux since slamming that onto Ubuntu leads to
     # frustration
 
+    # Allow jenkins access to update-alternatives command to switch java version
+    cat <<EOF >/etc/sudoers.d/89-jenkins-user-defaults
+Defaults:jenkins !requiretty
+jenkins ALL = NOPASSWD: /usr/bin/update-alternatives
+EOF
+
     echo "---> Updating operating system"
     apt-get update -qq
     apt-get upgrade -y --force-yes -qq
@@ -58,7 +90,7 @@ ubuntu_systems() {
     # install Java 7
     echo "---> Configuring OpenJDK"
     apt-get install -y --force-yes -qq openjdk-7-jdk
-    
+
     # make jdk8 available
     add-apt-repository -y ppa:openjdk-r/ppa
     apt-get update -qq