Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
47 changes: 47 additions & 0 deletions elements/centos7-vault/README.rst
Original file line number Diff line number Diff line change
@@ -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``
5 changes: 5 additions & 0 deletions elements/centos7-vault/element-deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cache-url
redhat-common
rpm-distro
source-repositories
yum
1 change: 1 addition & 0 deletions elements/centos7-vault/element-provides
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
operating-system
62 changes: 62 additions & 0 deletions elements/centos7-vault/environment.d/10-centos7-distro-name.bash
Original file line number Diff line number Diff line change
@@ -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}}
24 changes: 24 additions & 0 deletions elements/centos7-vault/pre-install.d/01-set-centos-mirror
Original file line number Diff line number Diff line change
@@ -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|" \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the alternative is to include a current version of CentOS-Vault.repo and update it when there is a new release which you currently need to do anyway due to the switch on DIB_CENTOS7_VERSION.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a CentOS-Vault.repo file published on vault.centos.org? If not I don't think there's a clear advantage that way. This way we can also cope with (eg) internal mirrors or other CentOS repos.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly, but you can get it from the latest centos-release package, e.g: http://mirror.centos.org/centos/7/os/x86_64/Packages/centos-release-7-7.1908.0.el7.centos.x86_64.rpm. Like you say though, there probably isn't a massive advantage though.

-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
23 changes: 23 additions & 0 deletions elements/centos7-vault/root.d/10-centos7-cloud-image
Original file line number Diff line number Diff line change
@@ -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
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
base
epel
openstack-ci-mirrors