Install the appropriate chef gem version

This commit is contained in:
Ignasi Barrera 2012-12-28 17:27:05 +01:00
parent ad3c164f84
commit df8b8dad20
6 changed files with 10 additions and 9 deletions

View File

@ -32,7 +32,9 @@ import org.jclouds.scriptbuilder.statements.ruby.InstallRuby;
public class InstallChefGems extends StatementList { public class InstallChefGems extends StatementList {
public InstallChefGems() { public InstallChefGems() {
super(new InstallRuby(), exec("gem install ohai chef --no-rdoc --no-ri")); // Chef versions prior to 10.16.4 install an incompatible moneta gem.
// See: http://tickets.opscode.com/browse/CHEF-3721
super(new InstallRuby(), exec("gem install chef -v '>= 10.16.4' --no-rdoc --no-ri"));
} }
@Override @Override

View File

@ -2,7 +2,7 @@ function installRuby() {
if ! hash ruby 2>/dev/null; then if ! hash ruby 2>/dev/null; then
if which dpkg &> /dev/null; then if which dpkg &> /dev/null; then
apt-get-update apt-get-update
apt-get install -y ruby ruby1.8-dev build-essential apt-get install -y ruby ruby-dev build-essential
elif which rpm &> /dev/null; then elif which rpm &> /dev/null; then
# Disable chef from the base repo (http://tickets.opscode.com/browse/CHEF-2906) # Disable chef from the base repo (http://tickets.opscode.com/browse/CHEF-2906)
sed -i "s/\[base\]/\0\n\exclude=ruby*/g" /etc/yum.repos.d/CentOS-Base.repo sed -i "s/\[base\]/\0\n\exclude=ruby*/g" /etc/yum.repos.d/CentOS-Base.repo

View File

@ -382,7 +382,7 @@ public class ChefSoloTest {
private static String installChefGems() throws IOException { private static String installChefGems() throws IOException {
return Resources.toString(Resources.getResource("test_install_ruby." + ShellToken.SH.to(OsFamily.UNIX)), return Resources.toString(Resources.getResource("test_install_ruby." + ShellToken.SH.to(OsFamily.UNIX)),
Charsets.UTF_8) + "gem install ohai chef --no-rdoc --no-ri\n"; Charsets.UTF_8) + "gem install chef -v '>= 10.16.4' --no-rdoc --no-ri\n";
} }
private static String createConfigFile() { private static String createConfigFile() {

View File

@ -38,8 +38,7 @@ import com.google.common.io.Resources;
@Test(groups = "unit", testName = "InstallChefGemsTest") @Test(groups = "unit", testName = "InstallChefGemsTest")
public class InstallChefGemsTest { public class InstallChefGemsTest {
@Test(expectedExceptions = UnsupportedOperationException.class, @Test(expectedExceptions = UnsupportedOperationException.class, expectedExceptionsMessageRegExp = "windows not yet implemented")
expectedExceptionsMessageRegExp = "windows not yet implemented")
public void installChefGemsInWindows() { public void installChefGemsInWindows() {
new InstallChefGems().render(OsFamily.WINDOWS); new InstallChefGems().render(OsFamily.WINDOWS);
} }
@ -48,7 +47,7 @@ public class InstallChefGemsTest {
assertEquals( assertEquals(
new InstallChefGems().render(OsFamily.UNIX), new InstallChefGems().render(OsFamily.UNIX),
Resources.toString(Resources.getResource("test_install_ruby." + ShellToken.SH.to(OsFamily.UNIX)), Resources.toString(Resources.getResource("test_install_ruby." + ShellToken.SH.to(OsFamily.UNIX)),
Charsets.UTF_8) + "gem install ohai chef --no-rdoc --no-ri\n"); Charsets.UTF_8) + "gem install chef -v '>= 10.16.4' --no-rdoc --no-ri\n");
} }
public void installChefGemsUnixInScriptBuilderSourcesSetupPublicCurl() throws IOException { public void installChefGemsUnixInScriptBuilderSourcesSetupPublicCurl() throws IOException {

View File

@ -140,7 +140,7 @@ function installRuby() {
if ! hash ruby 2>/dev/null; then if ! hash ruby 2>/dev/null; then
if which dpkg &> /dev/null; then if which dpkg &> /dev/null; then
apt-get-update apt-get-update
apt-get install -y ruby ruby1.8-dev build-essential apt-get install -y ruby ruby-dev build-essential
elif which rpm &> /dev/null; then elif which rpm &> /dev/null; then
# Disable chef from the base repo (http://tickets.opscode.com/browse/CHEF-2906) # Disable chef from the base repo (http://tickets.opscode.com/browse/CHEF-2906)
sed -i "s/\[base\]/\0\n\exclude=ruby*/g" /etc/yum.repos.d/CentOS-Base.repo sed -i "s/\[base\]/\0\n\exclude=ruby*/g" /etc/yum.repos.d/CentOS-Base.repo
@ -178,7 +178,7 @@ END_OF_JCLOUDS_SCRIPT
gem update --system gem update --system
gem update --no-rdoc --no-ri gem update --no-rdoc --no-ri
gem install ohai chef --no-rdoc --no-ri gem install chef -v '>= 10.16.4' --no-rdoc --no-ri
END_OF_JCLOUDS_SCRIPT END_OF_JCLOUDS_SCRIPT

View File

@ -140,7 +140,7 @@ function installRuby() {
if ! hash ruby 2>/dev/null; then if ! hash ruby 2>/dev/null; then
if which dpkg &> /dev/null; then if which dpkg &> /dev/null; then
apt-get-update apt-get-update
apt-get install -y ruby ruby1.8-dev build-essential apt-get install -y ruby ruby-dev build-essential
elif which rpm &> /dev/null; then elif which rpm &> /dev/null; then
# Disable chef from the base repo (http://tickets.opscode.com/browse/CHEF-2906) # Disable chef from the base repo (http://tickets.opscode.com/browse/CHEF-2906)
sed -i "s/\[base\]/\0\n\exclude=ruby*/g" /etc/yum.repos.d/CentOS-Base.repo sed -i "s/\[base\]/\0\n\exclude=ruby*/g" /etc/yum.repos.d/CentOS-Base.repo