make the module list that cloud-config selects specified via cmdline

instead of hard-coding in cloud-init-cfg the module list that should be
read, read it from the second command line argument.  Basically, instead
of reading 'cloud_config_modules', specify 'cloud_config' when
cloud-init-cfg is run.

change the upstart job to invoke cloud-init-cfg with:
   exec cloud-init-cfg all cloud_config
rather than
   exec cloud-init-cfg all
This commit is contained in:
Scott Moser
2011-01-24 12:04:09 -05:00
parent d5c79cbb76
commit e9150389b9
2 changed files with 8 additions and 4 deletions

View File

@@ -35,11 +35,14 @@ def main():
# read cloud config jobs from config (builtin -> system)
# and run all in order
modlist = "cloud_config"
if len(sys.argv) < 2:
Usage(sys.stderr)
sys.exit(1)
if sys.argv[1] == "all":
name = "all"
if len(sys.argv) > 2:
modlist = sys.argv[2]
else:
freq = None
run_args = []
@@ -64,16 +67,17 @@ def main():
module_list = [ ]
if name == "all":
modules_list = CC.read_cc_modules(cc.cfg,"cloud_config_modules")
modlist_cfg_name = "%s_modules" % modlist
modules_list = CC.read_cc_modules(cc.cfg,modlist_cfg_name)
if not len(modules_list):
err("no modules to run in cloud_config",log)
err("no modules to run in cloud_config [%s]" % modlist,log)
sys.exit(0)
else:
module_list.append( [ name, freq ] + run_args )
failures = CC.run_cc_modules(cc,module_list,log)
if len(failures):
err("errors running cloud_config modules: %s" % failures)
err("errors running cloud_config [%s]: %s" % (modlist,failures), log)
sys.exit(len(failures))
def err(msg,log=None):

View File

@@ -5,4 +5,4 @@ start on (filesystem and started rsyslog)
console output
task
exec cloud-init-cfg all
exec cloud-init-cfg all cloud_config