diff options
-rw-r--r-- | cloudinit/CloudConfig/cc_chef.py | 13 | ||||
-rw-r--r-- | doc/examples/cloud-config-chef.txt | 7 |
2 files changed, 14 insertions, 6 deletions
diff --git a/cloudinit/CloudConfig/cc_chef.py b/cloudinit/CloudConfig/cc_chef.py index 1effba53..807c3717 100644 --- a/cloudinit/CloudConfig/cc_chef.py +++ b/cloudinit/CloudConfig/cc_chef.py @@ -18,6 +18,7 @@ import os import pwd import socket import subprocess +import json import StringIO import ConfigParser import cloudinit.CloudConfig as cc @@ -57,13 +58,13 @@ def handle(name,cfg,cloud,log,args): # set the firstboot json with open('/etc/chef/firstboot.json', 'w') as firstboot_json_fh: - firstboot_json_fh.write("{\n") + initial_json = {} if chef_cfg.has_key('run_list'): - firstboot_json_fh.write(" \"run_list\": [\n") - firstboot_json_fh.write(",\n".join([" \"%s\"" % runlist_item - for runlist_item in chef_cfg['run_list']])) - firstboot_json_fh.write("\n ]\n") - firstboot_json_fh.write("}\n") + initial_json['run_list'] = chef_cfg['run_list'] + if chef_cfg.has_key('initial_attributes'): + initial_attributes = chef_cfg['initial_attributes'] + for k in initial_attributes.keys(): initial_json[k] = initial_attributes[k] + firstboot_json_fh.write(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'): diff --git a/doc/examples/cloud-config-chef.txt b/doc/examples/cloud-config-chef.txt index a1dda4f1..cbaa3467 100644 --- a/doc/examples/cloud-config-chef.txt +++ b/doc/examples/cloud-config-chef.txt @@ -35,3 +35,10 @@ chef: run_list: - "recipe[apache2]" - "role[db]" + + # Specify a list of initial attributes used by the cookbooks + initial_attributes: + apache: + prefork: + maxclients: 100 + keepalive: "off" |