From 3d26413212c2aaadfe9d7403d06e6abe3145aac7 Mon Sep 17 00:00:00 2001
From: Clark Boylan <clark.boylan@gmail.com>
Date: Wed, 20 Aug 2014 13:04:39 -0700
Subject: [PATCH] Install bundler from gems.

Previously on Debian based machines we attempted to install bundler from
apt and from gems. This worked on precise because the two package names
are different. It does not work on trusty because the package names are
the same and puppet complains that the namevar is duplicated and fails.

Fix this by removing all apt based bundler instalations. We will install
it only from gems and only on "thick" slaves. We do not need this on
devstack slaves because devstack can install it for itself if it needs
it.

Note, this changes the path to the `bundle` executable. We were using it
out of /usr/bin/bundle but a gem install will go in
/usr/local/bin/bundle on ubuntu and /usr/bin/bundle on centos. To keep
the chef jobs happy with this remove the explicit paths to bundle and
rely on $PATH to find it for us regardless of the platform.

Change-Id: Ic1f2158b923c5116f473f5d21250da69809b292d
---
 modules/jenkins/manifests/params.pp           |  9 ---------
 modules/jenkins/manifests/slave.pp            |  4 ----
 .../config/aviator-jobs.yaml                  |  4 ++--
 .../jenkins_job_builder/config/chef-jobs.yaml |  8 ++++----
 .../jenkins_job_builder/config/macros.yaml    | 20 +++++++++----------
 .../manifests/jenkins_params.pp               |  9 ---------
 6 files changed, 16 insertions(+), 38 deletions(-)

diff --git a/modules/jenkins/manifests/params.pp b/modules/jenkins/manifests/params.pp
index 97b70a018e..210bfcc2f9 100644
--- a/modules/jenkins/manifests/params.pp
+++ b/modules/jenkins/manifests/params.pp
@@ -55,15 +55,6 @@ class jenkins::params {
       $memcached_package = 'memcached'
       $ruby1_9_1_package = 'ruby1.9.1'
       $ruby1_9_1_dev_package = 'ruby1.9.1-dev'
-
-      # will install ruby-bundler for Ubuntu Precise
-      # and bundler for Debian or newer Ubuntu distros
-      if $::lsbdistcodename == 'precise' {
-        $ruby_bundler_package = 'ruby-bundler'
-      }
-      else {
-        $ruby_bundler_package = 'bundler'
-      }
       $php5_mcrypt_package = 'php5-mcrypt'
       # For [tooz, taskflow, nova] using zookeeper in unit tests
       $zookeeper_package = 'zookeeperd'
diff --git a/modules/jenkins/manifests/slave.pp b/modules/jenkins/manifests/slave.pp
index 10a648e13a..3400c9fd27 100644
--- a/modules/jenkins/manifests/slave.pp
+++ b/modules/jenkins/manifests/slave.pp
@@ -81,10 +81,6 @@ class jenkins::slave(
         ensure => present,
       }
 
-      package { $::jenkins::params::ruby_bundler_package:
-        ensure => present,
-      }
-
       package { 'openjdk-6-jre-headless':
         ensure  => purged,
         require => Package[$::jenkins::params::jdk_package],
diff --git a/modules/openstack_project/files/jenkins_job_builder/config/aviator-jobs.yaml b/modules/openstack_project/files/jenkins_job_builder/config/aviator-jobs.yaml
index eb626136df..9dd6d404ed 100644
--- a/modules/openstack_project/files/jenkins_job_builder/config/aviator-jobs.yaml
+++ b/modules/openstack_project/files/jenkins_job_builder/config/aviator-jobs.yaml
@@ -8,8 +8,8 @@
             cp test/environment.yml.travis-ci test/environment.yml
             mkdir .bundled_gems
             export GEM_HOME=`pwd`/.bundled_gems
-            ruby1.9.1 /usr/bin/bundle --without development
-            ruby1.9.1 /usr/bin/bundle exec rake
+            bundle --without development
+            bundle exec rake
 
     publishers:
       - console-log
diff --git a/modules/openstack_project/files/jenkins_job_builder/config/chef-jobs.yaml b/modules/openstack_project/files/jenkins_job_builder/config/chef-jobs.yaml
index d20018629b..46cae69371 100644
--- a/modules/openstack_project/files/jenkins_job_builder/config/chef-jobs.yaml
+++ b/modules/openstack_project/files/jenkins_job_builder/config/chef-jobs.yaml
@@ -65,12 +65,12 @@
       - shell: |
           #!/bin/bash -xe
           mkdir -p .cookbooks .bundle
-          ruby1.9.1 /usr/bin/bundle config --global jobs $(nproc)
-          ruby1.9.1 /usr/bin/bundle install --path=.bundle
+          bundle config --global jobs $(nproc)
+          bundle install --path=.bundle
           # Validates cookbooks
-          ruby1.9.1 /usr/bin/bundle exec berks install --path=.cookbooks
+          bundle exec berks install --path=.cookbooks
           # Validates roles
-          ruby1.9.1 /usr/bin/bundle exec spiceweasel infrastructure.yml --debug
+          bundle exec spiceweasel infrastructure.yml --debug
 
     publishers:
       - console-log
diff --git a/modules/openstack_project/files/jenkins_job_builder/config/macros.yaml b/modules/openstack_project/files/jenkins_job_builder/config/macros.yaml
index 09d7a7b94e..7895b7fb34 100644
--- a/modules/openstack_project/files/jenkins_job_builder/config/macros.yaml
+++ b/modules/openstack_project/files/jenkins_job_builder/config/macros.yaml
@@ -122,8 +122,8 @@
     builders:
       - shell: |
           mkdir -p .bundle
-          ruby1.9.1 /usr/bin/bundle config --global jobs $(nproc)
-          ruby1.9.1 /usr/bin/bundle install --path=.bundle
+          bundle config --global jobs $(nproc)
+          bundle install --path=.bundle
 
 - builder:
     name: chef-berkshelf-prep
@@ -132,10 +132,10 @@
           #!/bin/bash -x
           grep -E .*berkshelf.*3\.\d*\.\d*.* Gemfile
           if [ $? -eq 0 ]; then
-            ruby1.9.1 /usr/bin/bundle exec berks vendor .cookbooks
+            bundle exec berks vendor .cookbooks
           else
             mkdir -p .cookbooks
-            ruby1.9.1 /usr/bin/bundle exec berks install --path=.cookbooks
+            bundle exec berks install --path=.cookbooks
           fi
           COOKBOOK=$(awk '/^name/ {print $NF}' metadata.rb |tr -d \"\')
           if [ -z $COOKBOOK ]; then
@@ -148,9 +148,9 @@
     builders:
       - shell: |
           if grep rubocop: Strainerfile; then
-              ruby1.9.1 /usr/bin/bundle exec strainer test --cookbooks-path=.cookbooks --only=rubocop
+              bundle exec strainer test --cookbooks-path=.cookbooks --only=rubocop
           else
-              ruby1.9.1 /usr/bin/bundle exec rubocop
+              bundle exec rubocop
           fi
 
 - builder:
@@ -158,9 +158,9 @@
     builders:
       - shell: |
           if grep foodcritic: Strainerfile; then
-              ruby1.9.1 /usr/bin/bundle exec strainer test --cookbooks-path=.cookbooks --only=foodcritic
+              bundle exec strainer test --cookbooks-path=.cookbooks --only=foodcritic
           else
-              ruby1.9.1 /usr/bin/bundle exec foodcritic -f any -t ~FC003 -t ~FC023 .
+              bundle exec foodcritic -f any -t ~FC003 -t ~FC023 .
           fi
 
 - builder:
@@ -169,9 +169,9 @@
       - shell: |
           COOKBOOK=$(awk '/^name/ {print $NF}' metadata.rb |tr -d \"\')
           if grep chefspec: Strainerfile; then
-              ruby1.9.1 /usr/bin/bundle exec strainer test --cookbooks-path=.cookbooks --only=chefspec
+              bundle exec strainer test --cookbooks-path=.cookbooks --only=chefspec
           else
-              ruby1.9.1 /usr/bin/bundle exec rspec .cookbooks/$COOKBOOK/spec
+              bundle exec rspec .cookbooks/$COOKBOOK/spec
           fi
 
 - builder:
diff --git a/modules/openstack_project/manifests/jenkins_params.pp b/modules/openstack_project/manifests/jenkins_params.pp
index e49e2858c2..e1bbf5e8c1 100644
--- a/modules/openstack_project/manifests/jenkins_params.pp
+++ b/modules/openstack_project/manifests/jenkins_params.pp
@@ -130,15 +130,6 @@ class openstack_project::jenkins_params {
       }
       $ruby1_9_1_package = 'ruby1.9.1'
       $ruby1_9_1_dev_package = 'ruby1.9.1-dev'
-
-      # will install ruby-bundler for Ubuntu Precise
-      # and bundler for Debian or newer Ubuntu distros
-      if ($::lsbdistcodename == 'precise') {
-        $ruby_bundler_package = 'ruby-bundler'
-      }
-      else {
-        $ruby_bundler_package = 'bundler'
-      }
       # Common Lisp interpreter, used for cl-openstack-client
       $sbcl_package = 'sbcl'
       $sqlite_package = 'sqlite3'