summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2011-10-27 21:38:28 -0400
committerScott Moser <smoser@ubuntu.com>2011-10-27 21:38:28 -0400
commitc6b33abbfb97da1358c3daff2a50595bb8da0f59 (patch)
tree0f66e2cfe6ff9d99a32eb1b9f2cb3f150044563d /cloudinit
parent6fc476625714c56809eacd0df7634dc24b0a4ba3 (diff)
downloadvyos-cloud-init-c6b33abbfb97da1358c3daff2a50595bb8da0f59.tar.gz
vyos-cloud-init-c6b33abbfb97da1358c3daff2a50595bb8da0f59.zip
Replace static dict mapping version to packages with a method (LP: #848932)
Previously, there was a 'ruby_packages' dictionary that mapped the ruby version (1.8, 1.9, 1.9.1) to a list of packages that would need to be installed to get a functional gems. This replaces that with a method that is more likely to support future versions without requiring updates to cloud-init. It is not identical output as before. The changes are: * do not include 'ruby' in the case of 1.8, but rather 'ruby1.8' This is because the default could change, and 'ruby' would depend on a different default version. * do not explicitly list 'libruby-<version>' as that is a dependenency of 'ruby<version>' * End result is for any 'version' != 1.8, you'll get the following installed ruby<version> ruby<version>-dev LP: #848932
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/CloudConfig/cc_chef.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/cloudinit/CloudConfig/cc_chef.py b/cloudinit/CloudConfig/cc_chef.py
index 807c3717..14960a3c 100644
--- a/cloudinit/CloudConfig/cc_chef.py
+++ b/cloudinit/CloudConfig/cc_chef.py
@@ -24,9 +24,7 @@ import ConfigParser
import cloudinit.CloudConfig as cc
import cloudinit.util as util
-ruby_packages = {'1.8': ('ruby', 'rubygems', 'ruby-dev', 'libopenssl-ruby'),
- '1.9.1': ('ruby1.9.1', 'ruby1.9.1-dev', 'libruby1.9.1'),
- '1.9': ('ruby1.9', 'ruby1.9-dev', 'libruby1.9') }
+ruby_version_default = "1.8"
def handle(name,cfg,cloud,log,args):
# If there isn't a chef key in the configuration don't do anything
@@ -72,7 +70,8 @@ def handle(name,cfg,cloud,log,args):
if install_type == "gems":
# this will install and run the chef-client from gems
chef_version = util.get_cfg_option_str(chef_cfg, 'version', None)
- ruby_version = util.get_cfg_option_str(chef_cfg, 'ruby_version', '1.8')
+ ruby_version = util.get_cfg_option_str(chef_cfg, 'ruby_version',
+ ruby_version_default)
install_chef_from_gems(ruby_version, chef_version)
# and finally, run chef-client
log.debug('running chef-client')
@@ -81,8 +80,15 @@ def handle(name,cfg,cloud,log,args):
# this will install and run the chef-client from packages
cc.install_packages(('chef',))
+def get_ruby_packages(version):
+ # return a list of packages needed to install ruby at version
+ pkgs = [ 'ruby%s' % version, 'ruby%s-dev' % version ]
+ if version == "1.8":
+ pkgs.extend(('libopenssl-ruby1.8', 'rubygems1.8'))
+ return(pkgs)
+
def install_chef_from_gems(ruby_version, chef_version = None):
- cc.install_packages(ruby_packages[ruby_version])
+ cc.install_packages(get_ruby_packages(ruby_version))
if not os.path.exists('/usr/bin/gem'):
os.symlink('/usr/bin/gem%s' % ruby_version, '/usr/bin/gem')
if not os.path.exists('/usr/bin/ruby'):