Merge lp:~smoser/cloud-init/chef-omnibus into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Scott Moser
Status: Merged
Merged at revision: 749
Proposed branch: lp:~smoser/cloud-init/chef-omnibus
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 87 lines (+23/-2)
3 files modified
ChangeLog (+1/-0)
cloudinit/config/cc_chef.py (+14/-1)
doc/examples/cloud-config-chef.txt (+8/-1)
To merge this branch: bzr merge lp:~smoser/cloud-init/chef-omnibus
Reviewer Review Type Date Requested Status
Anatoliy Dobrosynets (community) Approve
cloud-init Commiters Pending
Review via email: mp+139491@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Anatoliy Dobrosynets (anatolijd) wrote :

Yes, that is exactly it and even better.

'omnibus' install mode becomes popular approach to install chef-client software.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-12-04 15:08:05 +0000
3+++ ChangeLog 2012-12-12 15:44:22 +0000
4@@ -7,6 +7,7 @@
5 - fix sudoers writing when entry is a string (LP: #1079002)
6 - tools/write-ssh-key-fingerprints: use '-s' rather than '--stderr'
7 option (LP: #1083715)
8+ - support omnibus installer for chef [Anatoliy Dobrosynets]
9 0.7.1:
10 - sysvinit: fix missing dependency in cloud-init job for RHEL 5.6
11 - config-drive: map hostname to local-hostname (LP: #1061964)
12
13=== modified file 'cloudinit/config/cc_chef.py'
14--- cloudinit/config/cc_chef.py 2012-10-28 02:25:48 +0000
15+++ cloudinit/config/cc_chef.py 2012-12-12 15:44:22 +0000
16@@ -22,6 +22,7 @@
17 import os
18
19 from cloudinit import templater
20+from cloudinit import url_helper
21 from cloudinit import util
22
23 RUBY_VERSION_DEFAULT = "1.8"
24@@ -35,6 +36,8 @@
25 '/var/run/chef',
26 ]
27
28+OMNIBUS_URL = "https://www.opscode.com/chef/install.sh"
29+
30
31 def handle(name, cfg, cloud, log, _args):
32
33@@ -83,7 +86,9 @@
34 util.write_file('/etc/chef/firstboot.json', json.dumps(initial_json))
35
36 # If chef is not installed, we install chef based on 'install_type'
37- if not os.path.isfile('/usr/bin/chef-client'):
38+ if (not os.path.isfile('/usr/bin/chef-client') or
39+ util.get_cfg_option_bool(chef_cfg, 'force_install', default=False)):
40+
41 install_type = util.get_cfg_option_str(chef_cfg, 'install_type',
42 'packages')
43 if install_type == "gems":
44@@ -99,6 +104,14 @@
45 elif install_type == 'packages':
46 # this will install and run the chef-client from packages
47 cloud.distro.install_packages(('chef',))
48+ elif install_type == 'omnibus':
49+ url = util.get_cfg_option_str(chef_cfg, "omnibus_url", OMNIBUS_URL)
50+ content = url_helper.readurl(url=url, retries=5)
51+ with util.tempdir() as tmpd:
52+ # use tmpd over tmpfile to avoid 'Text file busy' on execute
53+ tmpf = "%s/chef-omnibus-install" % tmpd
54+ util.write_file(tmpf, content, mode=0700)
55+ util.subp([tmpf], capture=False)
56 else:
57 log.warn("Unknown chef install type %s", install_type)
58
59
60=== modified file 'doc/examples/cloud-config-chef.txt'
61--- doc/examples/cloud-config-chef.txt 2012-04-09 14:41:48 +0000
62+++ doc/examples/cloud-config-chef.txt 2012-12-12 15:44:22 +0000
63@@ -47,9 +47,13 @@
64
65 chef:
66
67- # Valid values are 'gems' and 'packages'
68+ # Valid values are 'gems' and 'packages' and 'omnibus'
69 install_type: "packages"
70
71+ # Boolean: run 'install_type' code even if chef-client
72+ # appears already installed.
73+ force_install: false
74+
75 # Chef settings
76 server_url: "https://chef.yourorg.com:4000"
77
78@@ -80,6 +84,9 @@
79 maxclients: 100
80 keepalive: "off"
81
82+ # if install_type is 'omnibus', change the url to download
83+ omnibus_url: "https://www.opscode.com/chef/install.sh"
84+
85
86 # Capture all subprocess output into a logfile
87 # Useful for troubleshooting cloud-init issues