Ensure that modified files are kept when installing/upgrading

In a situation where the LXC cache and the apt mirror used do
not have matching package versions, or where the host and the
LXC cache have mismatches, the 'apt-get upgrade' and/or
'apt-get install' actions can fail due to dpkg asking what to
do about the config file mismatches.

This patch ensures that dpkg knows what to do, which is to
keep the existing in-place file (the file copied from the
host). This ensures that whatever apt configuration was
implemented on the host is definitely used in the containers.

Change-Id: I1f8bc785a8acdac71f46eff0e0d9573ba5c62ab3
This commit is contained in:
Jesse Pretorius 2016-05-26 16:23:28 +01:00
parent 81d904bc78
commit c2266350c8
2 changed files with 12 additions and 4 deletions

View File

@ -58,7 +58,7 @@ lxc_cache_map:
apt-key add /root/repo.keys
rm /root/repo.keys
{{ lxc_cache_install_command }} {{ lxc_cache_packages | join(' ') }}
apt-get -y upgrade
apt-get upgrade -y {{ lxc_cache_install_debconf }}
rm -f /usr/bin/python
ln -s /usr/bin/python2.7 /usr/bin/python
mkdir -p /root/.ssh
@ -66,7 +66,11 @@ lxc_cache_map:
userdel --force --remove ubuntu || true
apt-get clean
lxc_cache_install_command: "export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -y"
lxc_cache_install_command: "export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -y {{ lxc_cache_install_debconf }}"
# This forces any modified configurations to remain, and any unmodified configs to be replaced
# ref: http://serverfault.com/questions/259226/automatically-keep-current-version-of-config-files-when-apt-get-install
lxc_cache_install_debconf: '-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes'
lxc_cache_packages:
- apt-transport-https

View File

@ -61,7 +61,7 @@ lxc_cache_map:
apt-key add /root/repo.keys
rm /root/repo.keys
{{ lxc_cache_install_command }} {{ lxc_cache_packages | join(' ') }}
apt-get -y upgrade
apt-get upgrade -y {{ lxc_cache_install_debconf }}
rm -f /usr/bin/python
ln -s /usr/bin/python2.7 /usr/bin/python
mkdir -p /root/.ssh
@ -69,7 +69,11 @@ lxc_cache_map:
userdel --force --remove ubuntu || true
apt-get clean
lxc_cache_install_command: "export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -y"
lxc_cache_install_command: "export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -y {{ lxc_cache_install_debconf }}"
# This forces any modified configurations to remain, and any unmodified configs to be replaced
# ref: http://serverfault.com/questions/259226/automatically-keep-current-version-of-config-files-when-apt-get-install
lxc_cache_install_debconf: '-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes'
lxc_cache_packages:
- apt-transport-https