summaryrefslogtreecommitdiff
path: root/cloudinit/CloudConfig/cc_chef.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/CloudConfig/cc_chef.py')
-rw-r--r--cloudinit/CloudConfig/cc_chef.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/cloudinit/CloudConfig/cc_chef.py b/cloudinit/CloudConfig/cc_chef.py
index 10f3a67a..cbf92ee7 100644
--- a/cloudinit/CloudConfig/cc_chef.py
+++ b/cloudinit/CloudConfig/cc_chef.py
@@ -32,8 +32,9 @@ def handle(name,cfg,cloud,log,args):
chef_cfg = cfg['chef']
# Install chef packages from selected source
+ install_type = util.get_cfg_option_str(chef_cfg, "install_type", "packages")
if not os.path.isfile('/usr/bin/chef-client'):
- if chef_cfg['install_type'] == "gems":
+ if install_type == "gems":
if chef_cfg.has_key('version'):
chef_version = chef_cfg['version']
else:
@@ -48,10 +49,12 @@ def handle(name,cfg,cloud,log,args):
if chef_cfg.has_key('validation_cert'):
with open('/etc/chef/validation.pem', 'w') as validation_cert_fh:
validation_cert_fh.write(chef_cfg['validation_cert'])
-
+
+ validation_name = chef_cfg.get('validation_name','chef-validator')
# create the chef config from template
util.render_to_file('chef_client.rb', '/etc/chef/client.rb',
- {'server_url': chef_cfg['server_url'], 'validation_name': chef_cfg['validation_name'] || 'chef-validator'})
+ {'server_url': chef_cfg['server_url'],
+ 'validation_name': chef_cfg['validation_name']})
chef_args = ['-d']
# set the firstboot json
@@ -59,11 +62,13 @@ def handle(name,cfg,cloud,log,args):
with open('/etc/chef/firstboot.json', 'w') as firstboot_json_fh:
firstboot_json_fh.write("{\n\"run_list\":\n[\n")
for runlist_item in chef_cfg['run_list']:
- firstboot_json_fh.write(runlist_item + "\n")
- firstboot_json_fh.write("]\n\}")
+ firstboot_json_fh.write("\"" + runlist_item + "\"\n")
+ firstboot_json_fh.write("]\n}")
+
chef_args.append('-j /etc/chef/firstboot.json')
# and finally, run chef
+ log.debug("running chef-client %s" % chef_args)
subprocess.check_call(['/usr/bin/chef-client'] + chef_args)
def install_chef_from_gems(ruby_version, chef_version = None):