Package: cloud-init Version: 18.3-6 Severity: normal Dear Maintainer,
I'm trying to add some other repositories under /etc/apt/sources.list.d using the following 10_fuss.cfg file in /etc/cloud/cloud.cfg.d/: apt: preserve_sources_list: true sources: fuss-buster.list: source: "deb http://archive.fuss.bz.it/ buster main" key: | -----BEGIN PGP PUBLIC KEY BLOCK----- ... it work fine and add the list the first time cloud init is run, but in a later run cloud-init reprocess this file (like after adding a new ssh key for accessing the server) the source line is appended (the same happens also if preserve_sources_list is false). So I got duplicated lines with APT complaining Looking at the logs in cloud-init.log I traced the problem inside the file: /usr/lib/python3/dist-packages/cloudinit/config/cc_apt_configure.py where in the function add_apt_sources, at line 624 there is a: util.write_file(sourcefn, contents, omode="a") that write the file in append, giving a duplicate line. The problem is present also, at the time of writing, in the official upstream sources, here: https://github.com/canonical/cloud-init/blob/master/cloudinit/config/cc_apt_configure.py I think changing the code to omode="w" should solve this problem. -- System Information: Debian Release: 10.3 APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 4.19.0-8-amd64 (SMP w/1 CPU core) Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8), LANGUAGE=it_IT.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages cloud-init depends on: ii cloud-guest-utils 0.29-1 ii fdisk 2.33.1-0.1 ii gdisk 1.0.3-1.1 ii ifupdown 0.8.35 ii locales 2.28-10 ii lsb-base 10.2019051400 ii lsb-release 10.2019051400 ii net-tools 1.60+git20180626.aebd88e-1 ii procps 2:3.3.15-2 ii python3 3.7.3-1 ii python3-configobj 5.0.6-3 ii python3-jinja2 2.10-2 ii python3-jsonpatch 1.21-1 ii python3-jsonschema 2.6.0-4 ii python3-oauthlib 2.1.0-1 ii python3-requests 2.21.0-1 ii python3-six 1.12.0-1 ii python3-yaml 3.13-2 ii util-linux 2.33.1-0.1 Versions of packages cloud-init recommends: ii eatmydata 105-7 ii sudo 1.8.27-1+deb10u2 Versions of packages cloud-init suggests: pn btrfs-progs <none> ii e2fsprogs 1.44.5-1+deb10u3 pn xfsprogs <none> -- Configuration Files: /etc/cloud/cloud.cfg changed: disable_root: false preserve_hostname: false cloud_init_modules: - migrator - seed_random - bootcmd - write-files - growpart - resizefs - disk_setup - mounts - set_hostname - update_hostname - update_etc_hosts - ca-certs - rsyslog - users-groups - ssh cloud_config_modules: - emit_upstart - ssh-import-id - locale - set-passwords - grub-dpkg - apt-pipelining - apt-configure - ntp - timezone - disable-ec2-metadata - runcmd - byobu cloud_final_modules: - package-update-upgrade-install - fan - puppet - chef - salt-minion - mcollective - rightscale_userdata - scripts-vendor - scripts-per-once - scripts-per-boot - scripts-per-instance - scripts-user - ssh-authkey-fingerprints - keys-to-console - phone-home - final-message - power-state-change system_info: # This will affect which distro class gets used distro: debian # Default user name + that default users groups (if added/used) default_user: name: debian lock_passwd: True gecos: Debian groups: [adm, audio, cdrom, dialout, dip, floppy, netdev, plugdev, sudo, video] sudo: ["ALL=(ALL) NOPASSWD:ALL"] shell: /bin/bash # Other config here will be given to the distro class and/or path classes paths: cloud_dir: /var/lib/cloud/ templates_dir: /etc/cloud/templates/ upstart_dir: /etc/init/ package_mirrors: - arches: [default] failsafe: primary: http://deb.debian.org/debian security: http://security.debian.org/ ssh_svcname: ssh -- no debconf information