diff options
author | Scott Moser <smoser@ubuntu.com> | 2014-02-12 16:05:35 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2014-02-12 16:05:35 -0500 |
commit | 7204a820b561f23453820ff79a8228500bc754c9 (patch) | |
tree | 9046e12241ba9b87a7c1bf400ca0975eef93da27 /cloudinit | |
parent | 4d80411700ca70401cda401ee9bca799b9b8c55d (diff) | |
download | vyos-cloud-init-7204a820b561f23453820ff79a8228500bc754c9.tar.gz vyos-cloud-init-7204a820b561f23453820ff79a8228500bc754c9.zip |
Add 'unverified_modules' config option and skip unverified modules
Config modules are able to declare distros that they were verified
to run on by setting 'distros' as a list in the config module.
Previously, if a module was configured to run and the running distro was not
listed as supported, it would run anyway, and a warning would be written.
Now, we change the behavior to skip those modules.
The distro (or user) can specify that a given list of modules should run anyway
by declaring the 'unverified_modules' config variable.
run_once modules will be run without this filter (ie, expecting that the user
explicitly wanted to run it).
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/config/cc_ssh_import_id.py | 3 | ||||
-rw-r--r-- | cloudinit/stages.py | 36 |
2 files changed, 27 insertions, 12 deletions
diff --git a/cloudinit/config/cc_ssh_import_id.py b/cloudinit/config/cc_ssh_import_id.py index 50d96e15..76c1663d 100644 --- a/cloudinit/config/cc_ssh_import_id.py +++ b/cloudinit/config/cc_ssh_import_id.py @@ -26,9 +26,8 @@ from cloudinit import distros as ds from cloudinit import util import pwd -# The ssh-import-id only seems to exist on ubuntu (for now) # https://launchpad.net/ssh-import-id -distros = ['ubuntu'] +distros = ['ubuntu', 'debian'] def handle(_name, cfg, cloud, log, args): diff --git a/cloudinit/stages.py b/cloudinit/stages.py index 593b72a2..7acd3355 100644 --- a/cloudinit/stages.py +++ b/cloudinit/stages.py @@ -632,7 +632,6 @@ class Modules(object): return mostly_mods def _run_modules(self, mostly_mods): - d_name = self.init.distro.name cc = self.init.cloudify() # Return which ones ran # and which ones failed + the exception of why it failed @@ -646,15 +645,6 @@ class Modules(object): if not freq in FREQUENCIES: freq = PER_INSTANCE - worked_distros = set(mod.distros) - worked_distros.update( - distros.Distro.expand_osfamily(mod.osfamilies)) - - if (worked_distros and d_name not in worked_distros): - LOG.warn(("Module %s is verified on %s distros" - " but not on %s distro. It may or may not work" - " correctly."), name, list(worked_distros), - d_name) # Use the configs logger and not our own # TODO(harlowja): possibly check the module # for having a LOG attr and just give it back @@ -686,6 +676,32 @@ class Modules(object): def run_section(self, section_name): raw_mods = self._read_modules(section_name) mostly_mods = self._fixup_modules(raw_mods) + d_name = self.init.distro.name + + skipped = [] + forced = [] + overridden = self.cfg.get('unverified_modules', []) + for (mod, name, _freq, _args) in mostly_mods: + worked_distros = set(mod.distros) + worked_distros.update( + distros.Distro.expand_osfamily(mod.osfamilies)) + + # module does not declare 'distros' or lists this distro + if not worked_distros or d_name in worked_distros: + continue + + if name in overridden: + forced.append(name) + else: + skipped.append(name) + + if skipped: + LOG.info("Skipping modules %s because they are not verified " + "on distro '%s'. To run anyway, add them to " + "'unverified_modules' in config.", skipped, d_name) + if forced: + LOG.info("running unverified_modules: %s", forced) + return self._run_modules(mostly_mods) |