← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~smoser/cloud-init:bug/1675185-no-apt-on-snappy into cloud-init:master

 

Scott Moser has proposed merging ~smoser/cloud-init:bug/1675185-no-apt-on-snappy into cloud-init:master.

Commit message:
apt_configure: run only when needed.

the apt_configure module would fail to run on snappy as it
tries to write to unwritable paths.  Additionally, there is no apt 
there, so no point.

This skips running on ubuntu core by 'is_snappy', because the check
for apt will pass as there is a wrapper that prints out a warning
there.

LP: #1675185

Requested reviews:
  cloud init development team (cloud-init-dev)
Related bugs:
  Bug #1675185 in cloud-init: "cannot disable apt_configure via cloud-config"
  https://bugs.launchpad.net/cloud-init/+bug/1675185

For more details, see:
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/321218
-- 
Your team cloud init development team is requested to review the proposed merge of ~smoser/cloud-init:bug/1675185-no-apt-on-snappy into cloud-init:master.
diff --git a/cloudinit/config/cc_apt_configure.py b/cloudinit/config/cc_apt_configure.py
index 7f09c91..c2bbad1 100644
--- a/cloudinit/config/cc_apt_configure.py
+++ b/cloudinit/config/cc_apt_configure.py
@@ -280,13 +280,21 @@ def handle(name, ocfg, cloud, log, _):
 
     LOG.debug("handling apt (module %s) with apt config '%s'", name, cfg)
 
+    apply_debconf_selections(cfg, target)
+
+    if util.system_is_snappy():
+        LOG.debug("No apt configuration on snappy.")
+        return
+
+    if (not util.which('apt-get') or util.which('apt')):
+        LOG.debug("No apt-get or apt, not configuring apt")
+        return
+
     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)

References