Simplify inserting apt keys into LXC image

Bionic requires a functioning gpg-agent to run apt-key add. This means
that gpg-agent must be working properly in the chroot when the lxc image
preparation script runs.

Previous changes [1] have enabled apt-key to communicate with gpg-agent
during the lxc_hosts role checks, however the cache prep fails almost
every time when lxc_hosts is used within other role checks.

This is not a new issue, debian-installer is affected too [2].

This change adopts the same route as d-i, and simply copies the host
/etc/apt/trusted.gpg.d directory to the LXC image, removing the
need for apt-key and in turn gpg-agent.

[1] https://review.openstack.org/#/c/588629/
[2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=851774

Change-Id: Ia511881f675cd88ecc58360b18531f0dac486b70
This commit is contained in:
Jonathan Rosser 2018-08-05 09:33:02 +01:00
parent 4614d7fd1a
commit e64184a3da
2 changed files with 1 additions and 7 deletions

View File

@ -14,12 +14,6 @@ apt-get remove -y --purge snap* lxc* lxd* resolvconf* || true
apt-get update
apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes gnupg
#start gpg-agent if is is not already running
gpg-connect-agent /bye
apt-key add -v /root/repo.keys
rm /root/repo.keys
apt-get upgrade -y
apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes {{ lxc_cache_distro_packages | join(' ') }}
apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes

View File

@ -22,10 +22,10 @@ _lxc_cache_map:
copy_from_host:
- /etc/apt/sources.list
- /etc/apt/apt.conf.d/
- /etc/apt/trusted.gpg.d
- /etc/apt/preferences.d/
- /etc/environment
- /etc/localtime
- /root/repo.keys
- /etc/protocols
_lxc_cache_prep_template: "prep-scripts/ubuntu_18_prep.sh.j2"