Skip to content

Commit aa690bd

Browse files
authored
Merge pull request #27 from stackhpc/centos7-vault
Element for building previous releases of CentOS 7
2 parents d5e501a + fe92053 commit aa690bd

9 files changed

Lines changed: 166 additions & 0 deletions

File tree

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ This repository provides the following DIB elements:
2828
Ironic Python Agent (IPA) ramdisk image.
2929
* ``nvidia-cuda``: Installs Nvidia CUDA repo and packages for GPU support.
3030
* ``centos-linkup-extra``: Allows extra time for slow network links to come up.
31+
* ``centos7-vault``: Deploy older releases of CentOS 7

elements/centos7-vault/README.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
=============
2+
centos7-vault
3+
=============
4+
5+
Based on the standard centos7 element with minimal changes.
6+
7+
Use previous (but still available) versions of CentOS 7 cloud images as
8+
the baseline for built disk images.
9+
10+
DIB_CENTOS7_VERSION:
11+
:Required: No
12+
:Default: 7.6
13+
:Description: Set a version, from 7.1 to 7.7 (inclusive) and the last-known
14+
public locations for package repos and cloud images will be used.
15+
16+
DIB_CENTOS7_MIRROR_VERSION:
17+
:Required: No
18+
:Default: 7.6.1810
19+
:Description: Set a fully-qualified version for a build of CentOS.
20+
A sensible last-known default value is set according to
21+
``DIB_CENTOS7_VERSION``. This value also overwrites
22+
``$releasever`` in a standard ``CentOS-Base`` yum repo.
23+
24+
DIB_CENTOS7_CLOUDIMAGE_VERSION:
25+
:Required: No
26+
:Default: GenericCloud-1811
27+
:Description: Set a fully-qualified version for a cloud image build.
28+
A sensible last-known default value is set according to
29+
``DIB_CENTOS7_VERSION``.
30+
31+
DIB_CENTOS7_MIRROR:
32+
:Required: No
33+
:Default: ``http://vault.centos.org``
34+
:Description: A default value is the CentOS vault repo URL.
35+
It must have a subdirectory which is the CentOS mirror version.
36+
:Example: ``DIB_DISTRIBUTION_MIRROR=http://mirror.local/centos``
37+
38+
DIB_CENTOS7_CLOUDIMAGE_REPO:
39+
:Required: No
40+
:Default: ``https://cloud.centos.org/centos/7/images``
41+
:Description: URL to a folder for fetching the cloud image.
42+
43+
DIB_CENTOS7_CLOUDIMAGE:
44+
:Required: No
45+
:Default: ``https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-$DIB_CENTOS7_CLOUDIMAGE_VERSION.qcow2.xz``
46+
:Description: Set the desired fully-qualified URL to fetch the cloud image from.
47+
:Example: ``DIB_CLOUD_IMAGES=/path/to/my/centos/7/CentOS-7-x86_64-GenericCloud.qcow2.xz``
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cache-url
2+
redhat-common
3+
rpm-distro
4+
source-repositories
5+
yum
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
operating-system
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
export DISTRO_NAME=centos7
2+
export DIB_RELEASE=7
3+
4+
# Useful for elements that work with fedora (dnf) & centos
5+
export YUM=${YUM:-yum}
6+
7+
# At the time of writing CentOS 7.7 is still current and the vault content is incomplete.
8+
export DIB_CENTOS7_VERSION=${DIB_CENTOS7_VERSION:-"7.6"}
9+
case "$DIB_CENTOS7_VERSION" in
10+
7.7)
11+
DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.7.1908"}
12+
DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1907"}
13+
;;
14+
7.6)
15+
DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.6.1810"}
16+
DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1811"}
17+
;;
18+
7.5)
19+
DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.5.1804"}
20+
DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1805"}
21+
;;
22+
7.4)
23+
DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.4.1708"}
24+
DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1708"}
25+
;;
26+
7.3)
27+
DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.3.1611"}
28+
DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1611"}
29+
;;
30+
7.2)
31+
DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.2.1511"}
32+
DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1511"}
33+
;;
34+
7.1)
35+
DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.1.1503"}
36+
DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1503"}
37+
;;
38+
*)
39+
echo "CentOS 7 version \"$DIB_CENTOS7_VERSION\" is not recognised"
40+
exit -1
41+
;;
42+
esac
43+
export DIB_CENTOS7_MIRROR_VERSION DIB_CENTOS7_CLOUDIMAGE_VERSION
44+
45+
[ -n "$ARCH" ]
46+
47+
if [[ "amd64 x86_64" =~ "$ARCH" ]]; then
48+
ARCH="x86_64"
49+
export DIB_CENTOS7_CLOUDIMAGE_REPO=${DIB_CENTOS7_CLOUDIMAGE_REPO:-"https://cloud.centos.org/centos/7/images"}
50+
elif [[ "arm64 aarch64" =~ "$ARCH" ]]; then
51+
ARCH="aarch64"
52+
export DIB_CENTOS7_CLOUDIMAGE_REPO=${DIB_CENTOS7_CLOUDIMAGE_REPO:-http://cloud.centos.org/altarch/7/images/aarch64}
53+
elif [[ "ppc64le" =~ "$ARCH" ]]; then
54+
export DIB_CENTOS7_CLOUDIMAGE_REPO=${DIB_CENTOS7_CLOUDIMAGE_REPO:-http://cloud.centos.org/altarch/7/images/ppc64le}
55+
else
56+
echo 'centos7-vault root element only supports the x86_64, aarch64 and ppc64le values for $ARCH'
57+
exit -2
58+
fi
59+
60+
export DIB_CENTOS7_MIRROR=${DIB_CENTOS7_MIRROR:-"http://vault.centos.org"}
61+
export DIB_CENTOS7_CLOUDIMAGE_FILE=${DIB_CENTOS7_CLOUDIMAGE_FILE:-CentOS-7-${ARCH}-${DIB_CENTOS7_CLOUDIMAGE_VERSION}.qcow2.xz}
62+
export DIB_CENTOS7_CLOUDIMAGE=${DIB_CENTOS7_CLOUDIMAGE:-${DIB_CENTOS7_CLOUDIMAGE_REPO}/${DIB_CENTOS7_CLOUDIMAGE_FILE}}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
4+
set -x
5+
fi
6+
set -eu
7+
set -o pipefail
8+
9+
10+
# Only set the mirror for the Base, Extras, Updates and CentOSPlus repositories
11+
# This assumes a fair amount about the structure of the CentOS-Base repo file.
12+
# Would be nice to use -E "s/^\[(base|updates|extras|centosplus)\]/\[\1_$DIB_CENTOS7_MIRROR_VERSION\]/g"
13+
14+
sed -e "s|^#baseurl=http[s]*://mirror.centos.org/centos|baseurl=$DIB_CENTOS7_MIRROR|" \
15+
-e "/^mirrorlist=/d" \
16+
-e "s/^\[base\]/\[base_$DIB_CENTOS7_MIRROR_VERSION\]/g" \
17+
-e "s/^\[updates\]/\[updates_$DIB_CENTOS7_MIRROR_VERSION\]/g" \
18+
-e "s/^\[extras\]/\[extras_$DIB_CENTOS7_MIRROR_VERSION\]/g" \
19+
-e "s/^\[centosplus\]/\[centosplus_$DIB_CENTOS7_MIRROR_VERSION\]/g" \
20+
-e "s/\$releasever\>/$DIB_CENTOS7_MIRROR_VERSION/g" /etc/yum.repos.d/CentOS-Base.repo > /etc/yum.repos.d/CentOS-Vault.repo
21+
22+
yum clean all
23+
yum-config-manager --disable base updates extras centosplus
24+
yum-config-manager --enable {base,updates,extras,centosplus}_$DIB_CENTOS7_MIRROR_VERSION
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
4+
set -x
5+
fi
6+
set -eu
7+
set -o pipefail
8+
9+
[ -n "$TARGET_ROOT" ]
10+
11+
DIB_LOCAL_IMAGE=${DIB_LOCAL_IMAGE:-}
12+
13+
if [ -n "$DIB_LOCAL_IMAGE" ]; then
14+
# No need to copy a local image into the cache directory, so just specify
15+
# the cached path as the original path.
16+
CACHED_IMAGE=$DIB_CENTOS7_CLOUDIMAGE
17+
else
18+
CACHED_IMAGE=$DIB_IMAGE_CACHE/$DIB_CENTOS7_CLOUDIMAGE_FILE
19+
fi
20+
21+
BASE_IMAGE_TAR=$DIB_CENTOS7_CLOUDIMAGE_FILE.tgz
22+
23+
$TMP_HOOKS_PATH/bin/extract-image $DIB_CENTOS7_CLOUDIMAGE_FILE $BASE_IMAGE_TAR $DIB_CENTOS7_CLOUDIMAGE $CACHED_IMAGE

elements/centos7-vault/test-elements/build-succeeds/README.rst

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
base
2+
epel
3+
openstack-ci-mirrors

0 commit comments

Comments
 (0)