summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2017-03-28 16:35:48 -0400
committerScott Moser <smoser@brickies.net>2017-03-29 12:52:57 -0400
commite80dbb80987ba44be2899e34fbbbf7d48389b6b5 (patch)
tree80c397615586cf7b3baf8ad96a89c8143c7fff38 /cloudinit
parentdab9d6e0e92c7c933d86a0f696504fad2cebbda7 (diff)
downloadvyos-cloud-init-e80dbb80987ba44be2899e34fbbbf7d48389b6b5.tar.gz
vyos-cloud-init-e80dbb80987ba44be2899e34fbbbf7d48389b6b5.zip
apt_configure: run only when needed.
Do not bother configuring apt if no 'apt' config is provided and either: a.) running on snappy b.) there is no 'apt' command (possibly a different distro) If apt config is provided in either of the above situations, then config will continue. LP: #1675185
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/config/cc_apt_configure.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/cloudinit/config/cc_apt_configure.py b/cloudinit/config/cc_apt_configure.py
index 7f09c919..06804e85 100644
--- a/cloudinit/config/cc_apt_configure.py
+++ b/cloudinit/config/cc_apt_configure.py
@@ -278,15 +278,29 @@ def handle(name, ocfg, cloud, log, _):
raise ValueError("Expected dictionary for 'apt' config, found %s",
type(cfg))
- LOG.debug("handling apt (module %s) with apt config '%s'", name, cfg)
+ apply_debconf_selections(cfg, target)
+ apply_apt(cfg, cloud, target)
+
+
+def apply_apt(cfg, cloud, target):
+ # cfg is the 'apt' top level dictionary already in 'v3' format.
+ if not cfg:
+ # no config was provided. If apt configuration does not seem
+ # necessary on this system, then return.
+ if util.system_is_snappy():
+ LOG.debug("Nothing to do: No apt config and running on snappy")
+ return
+ if not (util.which('apt-get') or util.which('apt')):
+ LOG.debug("Nothing to do: No apt config and no apt commands")
+ return
+
+ LOG.debug("handling apt config: %s", cfg)
release = util.lsb_release(target=target)['codename']
arch = util.get_architecture(target)
mirrors = find_apt_mirror_info(cfg, cloud, arch=arch)
LOG.debug("Apt Mirror info: %s", mirrors)
- apply_debconf_selections(cfg, target)
-
if util.is_false(cfg.get('preserve_sources_list', False)):
generate_sources_list(cfg, release, mirrors, cloud)
rename_apt_lists(mirrors, target)