Make host copying more selective
The host copy process was taking too much, this makes that process more selective. Change-Id: Ic25559d9b68b6208ffdbed020cc79bd6b3d52fdd Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
f0ab1108c7
commit
d520e80462
@ -131,6 +131,12 @@ nspawn_copy_from_host: "{{ nspawn_default_copy_from_host | union(_nspawn_copy_fr
|
|||||||
# - /etc/apt/preferences.d/
|
# - /etc/apt/preferences.d/
|
||||||
nspawn_container_cache_files_from_host: []
|
nspawn_container_cache_files_from_host: []
|
||||||
|
|
||||||
|
# Default list of packages to install within the build container cache. These
|
||||||
|
# packages are installed first, before running anything else within the image.
|
||||||
|
# nspawn_container_distro_required_packages:
|
||||||
|
# - gnupg
|
||||||
|
nspawn_container_distro_required_packages: "{{ _nspawn_container_distro_required_packages | default([]) }}"
|
||||||
|
|
||||||
# Default list of packages to install within the build container cache.
|
# Default list of packages to install within the build container cache.
|
||||||
# nspawn_container_distro_packages:
|
# nspawn_container_distro_packages:
|
||||||
# - curl
|
# - curl
|
||||||
|
@ -56,3 +56,8 @@
|
|||||||
- name: Reload systemd-daemon
|
- name: Reload systemd-daemon
|
||||||
systemd:
|
systemd:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
|
- name: Remove generated apt keys
|
||||||
|
file:
|
||||||
|
path: /root/repo.keys
|
||||||
|
state: absent
|
||||||
|
@ -66,18 +66,33 @@
|
|||||||
when:
|
when:
|
||||||
- nspawn_image_cache_refresh | bool
|
- nspawn_image_cache_refresh | bool
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Generate apt keys from host for the container cache
|
||||||
|
command: "apt-key exportall"
|
||||||
|
changed_when: false
|
||||||
|
register: _apt_exportall
|
||||||
|
|
||||||
|
- name: Write exported keys to file
|
||||||
|
copy:
|
||||||
|
content: "{{ _apt_exportall.stdout }}"
|
||||||
|
dest: "/var/lib/machines/{{ nspawn_container_base_name }}/root/repo.keys"
|
||||||
|
notify:
|
||||||
|
- Remove generated apt keys
|
||||||
|
when:
|
||||||
|
- ansible_pkg_mgr == 'apt'
|
||||||
|
|
||||||
- name: Cached image preparation script
|
- name: Cached image preparation script
|
||||||
template:
|
template:
|
||||||
src: "prep-scripts/nspawn_{{ nspawn_cache_map.distro }}_prep.sh.j2"
|
src: "prep-scripts/nspawn_{{ nspawn_cache_map.distro }}_prep.sh.j2"
|
||||||
dest: "/var/lib/machines/{{ nspawn_container_base_name }}/usr/local/bin/cache-prep-commands.sh"
|
dest: "/var/lib/machines/{{ nspawn_container_base_name }}/usr/local/bin/cache-prep-commands.sh"
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
|
|
||||||
# This task runs several commands against the cached image to speed up the
|
|
||||||
# nspawn_container_create playbook.
|
|
||||||
- name: Prepare cached image setup commands
|
- name: Prepare cached image setup commands
|
||||||
shell: "chroot /var/lib/machines/{{ nspawn_container_base_name }} /usr/local/bin/cache-prep-commands.sh > /var/log/nspawn-cache-prep-commands.log 2>&1"
|
shell: "chroot /var/lib/machines/{{ nspawn_container_base_name }} /usr/local/bin/cache-prep-commands.sh > /var/log/nspawn-cache-prep-commands.log 2>&1"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
# This task runs several commands against the cached image to speed up the
|
||||||
|
# nspawn_container_create playbook.
|
||||||
- name: Sync files from the host into the container cache
|
- name: Sync files from the host into the container cache
|
||||||
shell: |
|
shell: |
|
||||||
if [[ -e "{{ item }}" ]]; then
|
if [[ -e "{{ item }}" ]]; then
|
||||||
|
@ -27,7 +27,7 @@ rpm --import /etc/pki/rpm-gpg/*
|
|||||||
which dnf &>/dev/null && RHT_PKG_MGR='dnf' || RHT_PKG_MGR='yum'
|
which dnf &>/dev/null && RHT_PKG_MGR='dnf' || RHT_PKG_MGR='yum'
|
||||||
# Create yum/dnf transaction file and run it all at once
|
# Create yum/dnf transaction file and run it all at once
|
||||||
echo "update" > /tmp/package-transaction.txt
|
echo "update" > /tmp/package-transaction.txt
|
||||||
echo "install {{ nspawn_container_distro_packages | join(' ') }}" >> /tmp/package-transaction.txt
|
echo "install {{ (nspawn_container_distro_packages | union(nspawn_container_distro_required_packages) | unique) | join(' ') }}" >> /tmp/package-transaction.txt
|
||||||
echo "run" >> /tmp/package-transaction.txt
|
echo "run" >> /tmp/package-transaction.txt
|
||||||
$RHT_PKG_MGR -y shell /tmp/package-transaction.txt
|
$RHT_PKG_MGR -y shell /tmp/package-transaction.txt
|
||||||
yum-complete-transaction --cleanup-only
|
yum-complete-transaction --cleanup-only
|
||||||
|
@ -34,7 +34,7 @@ fi
|
|||||||
|
|
||||||
# Key import
|
# Key import
|
||||||
zypper --gpg-auto-import-keys -n dup --force-resolution -l
|
zypper --gpg-auto-import-keys -n dup --force-resolution -l
|
||||||
zypper --gpg-auto-import-keys -n in --force-resolution -l {{ nspawn_container_distro_packages | join(' ') }}
|
zypper --gpg-auto-import-keys -n in --force-resolution -l {{ (nspawn_container_distro_packages | union(nspawn_container_distro_required_packages) | unique) | join(' ') }}
|
||||||
|
|
||||||
rm -f /usr/bin/python || true
|
rm -f /usr/bin/python || true
|
||||||
ln -s /usr/bin/python2.7 /usr/bin/python
|
ln -s /usr/bin/python2.7 /usr/bin/python
|
||||||
|
@ -24,8 +24,15 @@ set -e
|
|||||||
|
|
||||||
# Update base distribution
|
# Update base distribution
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
apt-get remove -y --purge snap* nspawn* lxd* resolvconf || true
|
apt-get remove -y --purge snap* nspawn* lxd* resolvconf || true
|
||||||
apt-get update
|
apt-get update
|
||||||
|
apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes {{ nspawn_container_distro_required_packages | join(' ') }}
|
||||||
|
|
||||||
|
if [[ -f "/root/repo.keys" ]]; then
|
||||||
|
apt-key add /root/repo.keys
|
||||||
|
fi
|
||||||
|
|
||||||
apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes {{ nspawn_container_distro_packages | join(' ') }}
|
apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes {{ nspawn_container_distro_packages | join(' ') }}
|
||||||
apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes
|
apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes
|
||||||
apt-get clean
|
apt-get clean
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
connection: local
|
connection: local
|
||||||
become: true
|
become: true
|
||||||
vars:
|
vars:
|
||||||
|
bridges: []
|
||||||
nspawn_networks:
|
nspawn_networks:
|
||||||
nspawn_address:
|
nspawn_address:
|
||||||
bridge: "nspawn0"
|
bridge: "nspawn0"
|
||||||
|
@ -59,4 +59,5 @@ _nspawn_cache_map:
|
|||||||
|
|
||||||
_nspawn_copy_from_host:
|
_nspawn_copy_from_host:
|
||||||
- /etc/pki/rpm-gpg/
|
- /etc/pki/rpm-gpg/
|
||||||
|
- /etc/yum/pluginconf.d/fastestmirror.conf
|
||||||
- /etc/yum.repos.d/
|
- /etc/yum.repos.d/
|
||||||
|
@ -54,7 +54,8 @@ _nspawn_cache_map:
|
|||||||
release: "{{ hostvars[physical_host]['ansible_distribution_version'] }}"
|
release: "{{ hostvars[physical_host]['ansible_distribution_version'] }}"
|
||||||
|
|
||||||
_nspawn_copy_from_host:
|
_nspawn_copy_from_host:
|
||||||
- /etc/zypp
|
- /etc/zypp/repos.d/repo-oss.repo
|
||||||
|
- /etc/zypp/repos.d/repo-update.repo
|
||||||
|
|
||||||
## Set default mirror for openSUSE repositories
|
## Set default mirror for openSUSE repositories
|
||||||
# NOTE(hwoarang): Ensure that the full path to the 'opensuse' directory is used.
|
# NOTE(hwoarang): Ensure that the full path to the 'opensuse' directory is used.
|
||||||
|
@ -28,6 +28,9 @@ _nspawn_hosts_distro_packages:
|
|||||||
- pxz
|
- pxz
|
||||||
- systemd-container
|
- systemd-container
|
||||||
|
|
||||||
|
_nspawn_container_distro_required_packages:
|
||||||
|
- gnupg
|
||||||
|
|
||||||
_nspawn_container_distro_packages:
|
_nspawn_container_distro_packages:
|
||||||
- apt-transport-https
|
- apt-transport-https
|
||||||
- ca-certificates
|
- ca-certificates
|
||||||
|
@ -28,6 +28,9 @@ _nspawn_hosts_distro_packages:
|
|||||||
- pxz
|
- pxz
|
||||||
- systemd-container
|
- systemd-container
|
||||||
|
|
||||||
|
_nspawn_container_distro_required_packages:
|
||||||
|
- gnupg
|
||||||
|
|
||||||
_nspawn_container_distro_packages:
|
_nspawn_container_distro_packages:
|
||||||
- apt-transport-https
|
- apt-transport-https
|
||||||
- ca-certificates
|
- ca-certificates
|
||||||
|
Loading…
Reference in New Issue
Block a user