cloud-init mangles sources.lists if mirror can't be found

Bug #1145215 reported by Ben Howard on 2013-03-04
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init (Ubuntu)

Bug Description

On freshly build non-EC2 boot the system came up with out a useable apt sources.list.

Mar 4 20:54:02 vhost0761 [CLOUDINIT][DEBUG]: Wrote /etc/apt/apt.conf.d/90cloud-init-pipelining with APT pipeline setting
Mar 4 20:54:02 vhost0761 [CLOUDINIT][DEBUG]: handling apt-update-upgrade with freq=None and args=[]
Mar 4 20:54:02 vhost0761 [CLOUDINIT][DEBUG]: Traceback (most recent call last):#012 File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/", line 261, in find_apt_mirror_info#012 pmirrors = cfg['system_info']['package_mirrors']#012KeyError: 'system_info'
Mar 4 20:54:02 vhost0761 [CLOUDINIT][WARNING]: Failed to get mirror info, falling back to default
Mar 4 20:54:02 vhost0761 [CLOUDINIT][DEBUG]: mirror info: {'mirror': '', 'primary': '', 'ubuntu': {'security': '', 'primary': ''}}
Mar 4 20:54:02 vhost0761 [CLOUDINIT][WARNING]: Traceback (most recent call last):#012 File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/", line 117, in run_cc_modules#012 cc.handle(name, run_args, freq=freq)#012 File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/", line 78, in handle#012 [name, self.cfg,, cloudinit.log, args])#012 File "/usr/lib/python2.7/dist-packages/cloudinit/", line 326, in sem_and_run#012 func(*args)#012 File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/", line 51, in handle#012 generate_sources_list(release, mirrors)#012 File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/", line 157, in generate_sources_list#012 util.render_to_file('sources.list', '/etc/apt/sources.list', params)#012 File "/usr/lib/python2.7/dist-packages/cloudinit/", line 245, in render_to_file#012 f.write(t.respond())#012 File "", line 230, in respond#012NotFound: cannot find 'security'
Mar 4 20:54:02 vhost0761 [CLOUDINIT][ERROR]: config handling of apt-update-upgrade, None, [] failed
Mar 4 20:54:02 vhost0761 [CLOUDINIT][DEBUG]: handling landscape with freq=None and args=[]

Ben Howard (darkmuggle) wrote :

root@vhost0761:/etc/apt# ll
total 64
drwxr-xr-x 6 root root 4096 Mar 4 20:59 ./
drwxr-xr-x 87 root root 4096 Mar 4 20:53 ../
drwxr-xr-x 2 root root 4096 Mar 4 07:06 apt.conf.d/
drwxr-xr-x 2 root root 4096 Apr 20 2012 preferences.d/
-rw-r--r-- 1 root root 0 Mar 4 20:54 sources.list
drwxr-xr-x 2 root root 4096 Mar 4 19:38 sources.list.d/
-rw-r--r-- 1 root root 261 Mar 4 19:38
-rw------- 1 root root 1200 Mar 4 07:04 trustdb.gpg
-rw-r--r-- 1 root root 12698 Mar 4 19:38 trusted.gpg
-rw-r--r-- 1 root root 12335 Mar 4 07:04 trusted.gpg~

Scott Moser (smoser) wrote :

--- cloudinit/CloudConfig/ 2013-01-16 22:19:13 +0000
+++ cloudinit/CloudConfig/ 2013-03-04 21:23:28 +0000
@@ -221,10 +221,8 @@

     # this is used if cfg['system_info']['package_mirrors'] is not present
     def_mirror_info = {
- 'ubuntu': {
- 'primary': "",
- 'security': ""
- }
+ 'primary': "",
+ 'security': ""
     mirror = None

That looks like the fix, but I suspect that your /etc/cloud/cloud.cfg has been locally modified as the packaged version should provide a ['system_info']['package_mirrors'] entry that would make the above code irrelevant (which is why it doesn't fail elsewhere, i think).

Scott Moser (smoser) on 2013-03-12
Changed in cloud-init (Ubuntu):
status: New → Fix Released
Changed in cloud-init (Ubuntu Precise):
status: New → Triaged
importance: Undecided → Low
Changed in cloud-init (Ubuntu):
importance: Undecided → Medium

Hello Ben, or anyone else affected,

Accepted cloud-init into precise-proposed. The package will build now and be available at in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at . Thank you in advance!

Changed in cloud-init (Ubuntu Precise):
status: Triaged → Fix Committed
tags: added: verification-needed
Ben Howard (darkmuggle) wrote :

Marking verification done. Verified that is fixed.

tags: added: verification-done
removed: verification-needed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-init - 0.6.3-0ubuntu1.6

cloud-init (0.6.3-0ubuntu1.6) precise-proposed; urgency=low

  * debian/patches/rework-mirror-selection.patch: update patch to
    address issue if package_mirrors is missing from cloud.cfg (LP: #1145215)
  * debian/patches/lp-1202202-azure-datasource.patch: add azure datasource
    backported from trunk (LP: #1202202)
  * debian/patches/future_utils.patch: pull back some upstream 'util' functions
    for use in the azure datasource.
  * debian/cloud-init.templates: add 'Azure' to the list of choices
    for cloud-init/datasources.
 -- Scott Moser <email address hidden> Wed, 14 Aug 2013 14:36:41 -0400

Changed in cloud-init (Ubuntu Precise):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers