Improve LXC cache preparation process
Without this patch, any errors that happen during the 'apt-get update' execution will cause the 'apt-get install' execution to never happen. This patch implements the following: - It sets the cache prep script to exit on error to ensure that the task fails if there is an error. - It splits the upgrade and install command on to different lines to ensure that each command's success can be determined individually. - It removes the clearing of the archive metadata introduced in https://review.openstack.org/310091 as this also removes apt lock files and other things which should not be removed. Removing all this is unnecessary with the new cache prep process and the 'apt-get clean' execution later clears the cache before it is packaged. - It removes the copy of /etc/apt/sources.list.d/ from the host to prevent a situation where a host apt source requires additional packages to be installed (for example curl) and those packages can't be installed due to the 'apt-get update' command failing because the package to update the index is missing. Change-Id: I07a864e4125a7fc076cbf5bf7380a8e34e6d2d7c
This commit is contained in:
parent
179063d597
commit
a5e5567369
@ -52,7 +52,7 @@
|
||||
copy:
|
||||
content: |
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
set -e -x
|
||||
{{ lxc_cache_map.cache_prep_commands }}
|
||||
dest: "/var/lib/lxc/LXC_NAME/rootfs/usr/local/bin/cache-prep-commands.sh"
|
||||
mode: "0755"
|
||||
|
@ -47,15 +47,13 @@ lxc_cache_map:
|
||||
- /etc/pki/rpm-gpg/
|
||||
- /etc/resolv.conf
|
||||
cache_prep_commands: |
|
||||
{{ lxc_cache_install_command }} {{ lxc_cache_packages | join(' ') }}
|
||||
yum install -y {{ lxc_cache_packages | join(' ') }}
|
||||
rm -f /usr/bin/python
|
||||
ln -s /usr/bin/python2.7 /usr/bin/python
|
||||
/usr/bin/wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -O /tmp/epel-release-latest-7.noarch.rpm
|
||||
/usr/bin/rpm -ivh /tmp/epel-release-latest-7.noarch.rpm || true
|
||||
yum clean all
|
||||
|
||||
lxc_cache_install_command: "yum install -y"
|
||||
|
||||
lxc_cache_packages:
|
||||
- ca-certificates
|
||||
- openssh-server
|
||||
|
@ -42,17 +42,17 @@ lxc_cache_map:
|
||||
release: trusty
|
||||
copy_from_host:
|
||||
- /etc/apt/sources.list
|
||||
- /etc/apt/sources.list.d/
|
||||
- /etc/apt/apt.conf.d/
|
||||
- /run/resolvconf/
|
||||
- /etc/resolvconf/
|
||||
- /etc/resolv.conf
|
||||
- /root/repo.keys
|
||||
cache_prep_commands: |
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
apt-key add /root/repo.keys
|
||||
rm /root/repo.keys
|
||||
{{ lxc_cache_install_command }} {{ lxc_cache_packages | join(' ') }}
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update
|
||||
apt-get install -y {{ lxc_cache_install_debconf }} {{ lxc_cache_packages | join(' ') }}
|
||||
apt-get upgrade -y {{ lxc_cache_install_debconf }}
|
||||
rm -f /usr/bin/python
|
||||
ln -s /usr/bin/python2.7 /usr/bin/python
|
||||
@ -61,8 +61,6 @@ 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_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'
|
||||
|
@ -46,17 +46,17 @@ lxc_cache_map:
|
||||
- openssh-server
|
||||
copy_from_host:
|
||||
- /etc/apt/sources.list
|
||||
- /etc/apt/sources.list.d/
|
||||
- /etc/apt/apt.conf.d/
|
||||
- /run/resolvconf/
|
||||
- /etc/resolvconf/
|
||||
- /etc/resolv.conf
|
||||
- /root/repo.keys
|
||||
cache_prep_commands: |
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
apt-key add /root/repo.keys
|
||||
rm /root/repo.keys
|
||||
{{ lxc_cache_install_command }} {{ lxc_cache_packages | join(' ') }}
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update
|
||||
apt-get install -y {{ lxc_cache_install_debconf }} {{ lxc_cache_packages | join(' ') }}
|
||||
apt-get upgrade -y {{ lxc_cache_install_debconf }}
|
||||
rm -f /usr/bin/python
|
||||
ln -s /usr/bin/python2.7 /usr/bin/python
|
||||
@ -65,8 +65,6 @@ 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_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'
|
||||
|
Loading…
Reference in New Issue
Block a user