diff options
author | Mike Moulton <mike@meltmedia.com> | 2011-09-13 00:38:37 +0000 |
---|---|---|
committer | Mike Moulton <mike@meltmedia.com> | 2011-09-13 00:38:37 +0000 |
commit | 2e6b44be4a2c352a49910c437a830c27b0ad131c (patch) | |
tree | 42fc9d241f10393ba36bde182e7c465b78feb26a /cloudinit/CloudConfig/cc_chef.py | |
parent | 1ef5047ac957afc33113e9a4417e22489ddea084 (diff) | |
download | vyos-cloud-init-2e6b44be4a2c352a49910c437a830c27b0ad131c.tar.gz vyos-cloud-init-2e6b44be4a2c352a49910c437a830c27b0ad131c.zip |
Bringing in proper json support for firstboot.json from lp:~avishai-ish-shalom/cloud-init/chef
Bringing in 'initial_properties' support from lp:~avishai-ish-shalom/cloud-init/chef
Diffstat (limited to 'cloudinit/CloudConfig/cc_chef.py')
-rw-r--r-- | cloudinit/CloudConfig/cc_chef.py | 13 |
1 files changed, 7 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'): |