diff --git a/README.rst b/README.rst index cdd11b4..6bf9452 100644 --- a/README.rst +++ b/README.rst @@ -28,3 +28,4 @@ This repository provides the following DIB elements: Ironic Python Agent (IPA) ramdisk image. * ``nvidia-cuda``: Installs Nvidia CUDA repo and packages for GPU support. * ``centos-linkup-extra``: Allows extra time for slow network links to come up. +* ``centos7-vault``: Deploy older releases of CentOS 7 diff --git a/elements/centos7-vault/README.rst b/elements/centos7-vault/README.rst new file mode 100644 index 0000000..5dea4e3 --- /dev/null +++ b/elements/centos7-vault/README.rst @@ -0,0 +1,47 @@ +============= +centos7-vault +============= + +Based on the standard centos7 element with minimal changes. + +Use previous (but still available) versions of CentOS 7 cloud images as +the baseline for built disk images. + +DIB_CENTOS7_VERSION: + :Required: No + :Default: 7.6 + :Description: Set a version, from 7.1 to 7.7 (inclusive) and the last-known + public locations for package repos and cloud images will be used. + +DIB_CENTOS7_MIRROR_VERSION: + :Required: No + :Default: 7.6.1810 + :Description: Set a fully-qualified version for a build of CentOS. + A sensible last-known default value is set according to + ``DIB_CENTOS7_VERSION``. This value also overwrites + ``$releasever`` in a standard ``CentOS-Base`` yum repo. + +DIB_CENTOS7_CLOUDIMAGE_VERSION: + :Required: No + :Default: GenericCloud-1811 + :Description: Set a fully-qualified version for a cloud image build. + A sensible last-known default value is set according to + ``DIB_CENTOS7_VERSION``. + +DIB_CENTOS7_MIRROR: + :Required: No + :Default: ``http://vault.centos.org`` + :Description: A default value is the CentOS vault repo URL. + It must have a subdirectory which is the CentOS mirror version. + :Example: ``DIB_DISTRIBUTION_MIRROR=http://mirror.local/centos`` + +DIB_CENTOS7_CLOUDIMAGE_REPO: + :Required: No + :Default: ``https://cloud.centos.org/centos/7/images`` + :Description: URL to a folder for fetching the cloud image. + +DIB_CENTOS7_CLOUDIMAGE: + :Required: No + :Default: ``https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-$DIB_CENTOS7_CLOUDIMAGE_VERSION.qcow2.xz`` + :Description: Set the desired fully-qualified URL to fetch the cloud image from. + :Example: ``DIB_CLOUD_IMAGES=/path/to/my/centos/7/CentOS-7-x86_64-GenericCloud.qcow2.xz`` diff --git a/elements/centos7-vault/element-deps b/elements/centos7-vault/element-deps new file mode 100644 index 0000000..1bc6150 --- /dev/null +++ b/elements/centos7-vault/element-deps @@ -0,0 +1,5 @@ +cache-url +redhat-common +rpm-distro +source-repositories +yum diff --git a/elements/centos7-vault/element-provides b/elements/centos7-vault/element-provides new file mode 100644 index 0000000..a72e049 --- /dev/null +++ b/elements/centos7-vault/element-provides @@ -0,0 +1 @@ +operating-system diff --git a/elements/centos7-vault/environment.d/10-centos7-distro-name.bash b/elements/centos7-vault/environment.d/10-centos7-distro-name.bash new file mode 100644 index 0000000..5800bbb --- /dev/null +++ b/elements/centos7-vault/environment.d/10-centos7-distro-name.bash @@ -0,0 +1,62 @@ +export DISTRO_NAME=centos7 +export DIB_RELEASE=7 + +# Useful for elements that work with fedora (dnf) & centos +export YUM=${YUM:-yum} + +# At the time of writing CentOS 7.7 is still current and the vault content is incomplete. +export DIB_CENTOS7_VERSION=${DIB_CENTOS7_VERSION:-"7.6"} +case "$DIB_CENTOS7_VERSION" in + 7.7) + DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.7.1908"} + DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1907"} + ;; + 7.6) + DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.6.1810"} + DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1811"} + ;; + 7.5) + DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.5.1804"} + DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1805"} + ;; + 7.4) + DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.4.1708"} + DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1708"} + ;; + 7.3) + DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.3.1611"} + DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1611"} + ;; + 7.2) + DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.2.1511"} + DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1511"} + ;; + 7.1) + DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.1.1503"} + DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1503"} + ;; + *) + echo "CentOS 7 version \"$DIB_CENTOS7_VERSION\" is not recognised" + exit -1 + ;; +esac +export DIB_CENTOS7_MIRROR_VERSION DIB_CENTOS7_CLOUDIMAGE_VERSION + +[ -n "$ARCH" ] + +if [[ "amd64 x86_64" =~ "$ARCH" ]]; then + ARCH="x86_64" + export DIB_CENTOS7_CLOUDIMAGE_REPO=${DIB_CENTOS7_CLOUDIMAGE_REPO:-"https://cloud.centos.org/centos/7/images"} +elif [[ "arm64 aarch64" =~ "$ARCH" ]]; then + ARCH="aarch64" + export DIB_CENTOS7_CLOUDIMAGE_REPO=${DIB_CENTOS7_CLOUDIMAGE_REPO:-http://cloud.centos.org/altarch/7/images/aarch64} +elif [[ "ppc64le" =~ "$ARCH" ]]; then + export DIB_CENTOS7_CLOUDIMAGE_REPO=${DIB_CENTOS7_CLOUDIMAGE_REPO:-http://cloud.centos.org/altarch/7/images/ppc64le} +else + echo 'centos7-vault root element only supports the x86_64, aarch64 and ppc64le values for $ARCH' + exit -2 +fi + +export DIB_CENTOS7_MIRROR=${DIB_CENTOS7_MIRROR:-"http://vault.centos.org"} +export DIB_CENTOS7_CLOUDIMAGE_FILE=${DIB_CENTOS7_CLOUDIMAGE_FILE:-CentOS-7-${ARCH}-${DIB_CENTOS7_CLOUDIMAGE_VERSION}.qcow2.xz} +export DIB_CENTOS7_CLOUDIMAGE=${DIB_CENTOS7_CLOUDIMAGE:-${DIB_CENTOS7_CLOUDIMAGE_REPO}/${DIB_CENTOS7_CLOUDIMAGE_FILE}} diff --git a/elements/centos7-vault/pre-install.d/01-set-centos-mirror b/elements/centos7-vault/pre-install.d/01-set-centos-mirror new file mode 100755 index 0000000..c3d6866 --- /dev/null +++ b/elements/centos7-vault/pre-install.d/01-set-centos-mirror @@ -0,0 +1,24 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + + +# Only set the mirror for the Base, Extras, Updates and CentOSPlus repositories +# This assumes a fair amount about the structure of the CentOS-Base repo file. +# Would be nice to use -E "s/^\[(base|updates|extras|centosplus)\]/\[\1_$DIB_CENTOS7_MIRROR_VERSION\]/g" + +sed -e "s|^#baseurl=http[s]*://mirror.centos.org/centos|baseurl=$DIB_CENTOS7_MIRROR|" \ + -e "/^mirrorlist=/d" \ + -e "s/^\[base\]/\[base_$DIB_CENTOS7_MIRROR_VERSION\]/g" \ + -e "s/^\[updates\]/\[updates_$DIB_CENTOS7_MIRROR_VERSION\]/g" \ + -e "s/^\[extras\]/\[extras_$DIB_CENTOS7_MIRROR_VERSION\]/g" \ + -e "s/^\[centosplus\]/\[centosplus_$DIB_CENTOS7_MIRROR_VERSION\]/g" \ + -e "s/\$releasever\>/$DIB_CENTOS7_MIRROR_VERSION/g" /etc/yum.repos.d/CentOS-Base.repo > /etc/yum.repos.d/CentOS-Vault.repo + +yum clean all +yum-config-manager --disable base updates extras centosplus +yum-config-manager --enable {base,updates,extras,centosplus}_$DIB_CENTOS7_MIRROR_VERSION diff --git a/elements/centos7-vault/root.d/10-centos7-cloud-image b/elements/centos7-vault/root.d/10-centos7-cloud-image new file mode 100755 index 0000000..6f370d2 --- /dev/null +++ b/elements/centos7-vault/root.d/10-centos7-cloud-image @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +[ -n "$TARGET_ROOT" ] + +DIB_LOCAL_IMAGE=${DIB_LOCAL_IMAGE:-} + +if [ -n "$DIB_LOCAL_IMAGE" ]; then + # No need to copy a local image into the cache directory, so just specify + # the cached path as the original path. + CACHED_IMAGE=$DIB_CENTOS7_CLOUDIMAGE +else + CACHED_IMAGE=$DIB_IMAGE_CACHE/$DIB_CENTOS7_CLOUDIMAGE_FILE +fi + +BASE_IMAGE_TAR=$DIB_CENTOS7_CLOUDIMAGE_FILE.tgz + +$TMP_HOOKS_PATH/bin/extract-image $DIB_CENTOS7_CLOUDIMAGE_FILE $BASE_IMAGE_TAR $DIB_CENTOS7_CLOUDIMAGE $CACHED_IMAGE diff --git a/elements/centos7-vault/test-elements/build-succeeds/README.rst b/elements/centos7-vault/test-elements/build-succeeds/README.rst new file mode 100644 index 0000000..e69de29 diff --git a/elements/centos7-vault/test-elements/build-succeeds/element-deps b/elements/centos7-vault/test-elements/build-succeeds/element-deps new file mode 100644 index 0000000..3a391e3 --- /dev/null +++ b/elements/centos7-vault/test-elements/build-succeeds/element-deps @@ -0,0 +1,3 @@ +base +epel +openstack-ci-mirrors