← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~smoser/cloud-init/chef-omnibus into lp:cloud-init

 

Scott Moser has proposed merging lp:~smoser/cloud-init/chef-omnibus into lp:cloud-init.

Requested reviews:
  Anatoliy Dobrosynets (anatolijd)
  cloud init development team (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~smoser/cloud-init/chef-omnibus/+merge/139491

Add 'omnibus' install mode for chef

This adds 'omnibus' to the values supported for chef's "omnibus_url" config
option.  It also:
 * makes 'omnibus_url' configurable in cloud-config.
 * adds a 'force_install' flag, to allow the install code to
   act even if /usr/bin/chef-client is already present.

-- 
https://code.launchpad.net/~smoser/cloud-init/chef-omnibus/+merge/139491
Your team cloud init development team is requested to review the proposed merge of lp:~smoser/cloud-init/chef-omnibus into lp:cloud-init.
=== modified file 'ChangeLog'
--- ChangeLog	2012-12-04 15:08:05 +0000
+++ ChangeLog	2012-12-12 15:44:22 +0000
@@ -7,6 +7,7 @@
  - fix sudoers writing when entry is a string (LP: #1079002)
  - tools/write-ssh-key-fingerprints: use '-s' rather than '--stderr'
    option (LP: #1083715)
+ - support omnibus installer for chef [Anatoliy Dobrosynets]
 0.7.1:
  - sysvinit: fix missing dependency in cloud-init job for RHEL 5.6 
  - config-drive: map hostname to local-hostname (LP: #1061964)

=== modified file 'cloudinit/config/cc_chef.py'
--- cloudinit/config/cc_chef.py	2012-10-28 02:25:48 +0000
+++ cloudinit/config/cc_chef.py	2012-12-12 15:44:22 +0000
@@ -22,6 +22,7 @@
 import os
 
 from cloudinit import templater
+from cloudinit import url_helper
 from cloudinit import util
 
 RUBY_VERSION_DEFAULT = "1.8"
@@ -35,6 +36,8 @@
     '/var/run/chef',
 ]
 
+OMNIBUS_URL = "https://www.opscode.com/chef/install.sh";
+
 
 def handle(name, cfg, cloud, log, _args):
 
@@ -83,7 +86,9 @@
     util.write_file('/etc/chef/firstboot.json', json.dumps(initial_json))
 
     # If chef is not installed, we install chef based on 'install_type'
-    if not os.path.isfile('/usr/bin/chef-client'):
+    if (not os.path.isfile('/usr/bin/chef-client') or
+        util.get_cfg_option_bool(chef_cfg, 'force_install', default=False)):
+
         install_type = util.get_cfg_option_str(chef_cfg, 'install_type',
                                                'packages')
         if install_type == "gems":
@@ -99,6 +104,14 @@
         elif install_type == 'packages':
             # this will install and run the chef-client from packages
             cloud.distro.install_packages(('chef',))
+        elif install_type == 'omnibus':
+            url = util.get_cfg_option_str(chef_cfg, "omnibus_url", OMNIBUS_URL)
+            content = url_helper.readurl(url=url, retries=5)
+            with util.tempdir() as tmpd:
+                # use tmpd over tmpfile to avoid 'Text file busy' on execute
+                tmpf = "%s/chef-omnibus-install" % tmpd
+                util.write_file(tmpf, content, mode=0700)
+                util.subp([tmpf], capture=False)
         else:
             log.warn("Unknown chef install type %s", install_type)
 

=== modified file 'doc/examples/cloud-config-chef.txt'
--- doc/examples/cloud-config-chef.txt	2012-04-09 14:41:48 +0000
+++ doc/examples/cloud-config-chef.txt	2012-12-12 15:44:22 +0000
@@ -47,9 +47,13 @@
 
 chef:
 
- # Valid values are 'gems' and 'packages'
+ # Valid values are 'gems' and 'packages' and 'omnibus'
  install_type: "packages"
 
+ # Boolean: run 'install_type' code even if chef-client
+ #          appears already installed.
+ force_install: false
+
  # Chef settings
  server_url: "https://chef.yourorg.com:4000";
 
@@ -80,6 +84,9 @@
         maxclients: 100
       keepalive: "off"
 
+ # if install_type is 'omnibus', change the url to download
+ omnibus_url: "https://www.opscode.com/chef/install.sh";
+
 
 # Capture all subprocess output into a logfile
 # Useful for troubleshooting cloud-init issues


Follow ups