summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Moulton <mike@meltmedia.com>2011-09-13 00:38:37 +0000
committerMike Moulton <mike@meltmedia.com>2011-09-13 00:38:37 +0000
commit2e6b44be4a2c352a49910c437a830c27b0ad131c (patch)
tree42fc9d241f10393ba36bde182e7c465b78feb26a
parent1ef5047ac957afc33113e9a4417e22489ddea084 (diff)
downloadvyos-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
-rw-r--r--cloudinit/CloudConfig/cc_chef.py13
-rw-r--r--doc/examples/cloud-config-chef.txt7
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"