Updated Branches:
  refs/heads/branch-0.8 c1e9c1096 -> 38152764e

WHIRR-694. Install puppet from puppetlabs instead of ruby gem. Contributed by 
Roman Shaposhnik.


Project: http://git-wip-us.apache.org/repos/asf/whirr/repo
Commit: http://git-wip-us.apache.org/repos/asf/whirr/commit/90f9c111
Tree: http://git-wip-us.apache.org/repos/asf/whirr/tree/90f9c111
Diff: http://git-wip-us.apache.org/repos/asf/whirr/diff/90f9c111

Branch: refs/heads/branch-0.8
Commit: 90f9c11117171957fc78759763815933ce0ccb2e
Parents: c1e9c10
Author: Andrew Bayer <andrew.ba...@gmail.com>
Authored: Sun Mar 31 20:47:17 2013 -0700
Committer: Andrew Bayer <andrew.ba...@gmail.com>
Committed: Sun Mar 31 20:48:59 2013 -0700

----------------------------------------------------------------------
 CHANGES.txt                                        |    3 +
 .../whirr/service/puppet/PuppetConstants.java      |    1 +
 .../puppet/PuppetInstallClusterActionHandler.java  |    4 +-
 .../src/main/resources/functions/install_puppet.sh |   55 +++++++++++++--
 4 files changed, 57 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/whirr/blob/90f9c111/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9adbdfc..b2e86cf 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,6 +4,9 @@ Release 0.8.2 (unreleased changes)
 
   IMPROVEMENTS
 
+    WHIRR-694. Install puppet from puppetlabs repo instead of ruby
+    gem. (Roman Shaposhnik via abayer)
+    
     WHIRR-709. Bump Hadoop to latest available version (1.0.4) at
     osuosl. (abayer)
     

http://git-wip-us.apache.org/repos/asf/whirr/blob/90f9c111/services/puppet/src/main/java/org/apache/whirr/service/puppet/PuppetConstants.java
----------------------------------------------------------------------
diff --git 
a/services/puppet/src/main/java/org/apache/whirr/service/puppet/PuppetConstants.java
 
b/services/puppet/src/main/java/org/apache/whirr/service/puppet/PuppetConstants.java
index 3aca26c..4acd385 100644
--- 
a/services/puppet/src/main/java/org/apache/whirr/service/puppet/PuppetConstants.java
+++ 
b/services/puppet/src/main/java/org/apache/whirr/service/puppet/PuppetConstants.java
@@ -25,6 +25,7 @@ import java.util.regex.Pattern;
  */
 public class PuppetConstants {
   public static final String PUPPET = "puppet";
+  public static final String PUPPET_ORIGIN = PUPPET + ".repourl";
   public static final String PUPPET_ROLE_PREFIX = PUPPET + ":";
   public static final String MODULE_SOURCE_SUBKEY = "module";
 

http://git-wip-us.apache.org/repos/asf/whirr/blob/90f9c111/services/puppet/src/main/java/org/apache/whirr/service/puppet/PuppetInstallClusterActionHandler.java
----------------------------------------------------------------------
diff --git 
a/services/puppet/src/main/java/org/apache/whirr/service/puppet/PuppetInstallClusterActionHandler.java
 
b/services/puppet/src/main/java/org/apache/whirr/service/puppet/PuppetInstallClusterActionHandler.java
index f814bb0..f79d72b 100644
--- 
a/services/puppet/src/main/java/org/apache/whirr/service/puppet/PuppetInstallClusterActionHandler.java
+++ 
b/services/puppet/src/main/java/org/apache/whirr/service/puppet/PuppetInstallClusterActionHandler.java
@@ -24,6 +24,7 @@ import java.io.IOException;
 
 import org.apache.whirr.service.ClusterActionEvent;
 import org.apache.whirr.service.ClusterActionHandlerSupport;
+import static org.apache.whirr.service.puppet.PuppetConstants.PUPPET_ORIGIN;
 
 /**
  * Installs puppet (and ruby).
@@ -53,6 +54,7 @@ public class PuppetInstallClusterActionHandler extends 
ClusterActionHandlerSuppo
     addStatement(event, call("install_git"));
 
     // install puppet
-    addStatement(event, call("install_puppet"));
+    addStatement(event, call("install_puppet", 
event.getClusterSpec().getConfiguration().
+                                               getString(PUPPET_ORIGIN, "")));
   }
 }

http://git-wip-us.apache.org/repos/asf/whirr/blob/90f9c111/services/puppet/src/main/resources/functions/install_puppet.sh
----------------------------------------------------------------------
diff --git a/services/puppet/src/main/resources/functions/install_puppet.sh 
b/services/puppet/src/main/resources/functions/install_puppet.sh
index e01a152..7427b57 100644
--- a/services/puppet/src/main/resources/functions/install_puppet.sh
+++ b/services/puppet/src/main/resources/functions/install_puppet.sh
@@ -17,7 +17,7 @@
 
 function install_puppet() {
   if ! which puppet &> /dev/null ; then
-    install_puppet_forced
+    install_puppet_forced $1
   fi
 }
 
@@ -31,9 +31,54 @@ function install_puppet_forced() {
   mkdir -p /usr/share/puppet/modules
   mkdir -p /var/lib/puppet/lib/facter
 
-  # install the puppet and facter gems
-  sudo gem install facter --no-rdoc --no-ri --bindir /usr/bin/
-  sudo gem install puppet --no-rdoc --no-ri --bindir /usr/bin/
+  if [ -z "$1" ] ; then # install the puppet and facter gems
+    sudo gem install facter --no-rdoc --no-ri --bindir /usr/bin/
+    sudo gem install puppet --no-rdoc --no-ri --bindir /usr/bin/
  
-  sudo useradd puppet
+    sudo useradd puppet
+  else # install puppet from a given repo
+    case $1 in
+      *.deb)
+         REPOMGMT=apt-get
+         TMPDIR=`mktemp -d /tmp/whirr-XXXXXXXXXX`
+         PKGNAME=`basename $1`
+         yes | apt-get install -y wget
+         (cd $TMPDIR ; wget "$1")
+         dpkg -i $TMPDIR/$PKGNAME
+         rm -f $TMPDIR/$PKGNAME
+         rmdir $TMPDIR
+         apt-get update
+         ;;
+      *.rpm)
+         rpm -i "$1"
+         if which zypper ; then
+           REPOMGMT=zypper
+           zypper clean
+         else
+           REPOMGMT=yum
+           yum clean all
+         fi
+         ;;
+      *.repo)
+         if zypper ar -f "$1" ; then
+           REPOMGMT=zypper
+         else
+           REPOMGMT=yum
+           yes | yum install -y wget
+           (cd /etc/yum.repos.d && wget "$1")
+           yum clean all
+         fi
+         ;;
+      *.list)
+         REPOMGMT=apt-get
+         (cd /etc/apt/sources.list.d ; wget "$1")
+         apt-get update
+         ;;
+      *)
+         REPOMGMT=zypper
+         zypper ar -f "$1" `basename "$1"`
+         ;;
+    esac
+    yes | $REPOMGMT install -y puppet
+  fi
 }

Reply via email to