Support RHEL base image in DIB

This adds a rhel type and gives some pointers on needed environment
variables for base image, registration, needed subscriptions.

no-resolvconf is also updated to work on rhel-type systems

Depends-On: Icb0e20b01479fea345e01309fc4bf3f7f639900c
Change-Id: Ic452feaf32fe7699ebd072f21dd630a2ac93bb5f
This commit is contained in:
Bernard Cafarelli 2016-06-23 16:04:19 +02:00
parent a3803ad68b
commit 6e97a37744
5 changed files with 65 additions and 10 deletions

View File

@ -93,7 +93,7 @@ Command syntax:
[-b **haproxy** ]
[-c **~/.cache/image-create** | <cache directory> ]
[-h]
[-i **ubuntu** | fedora | centos ]
[-i **ubuntu** | fedora | centos | rhel ]
[-o **amphora-x64-haproxy** | <filename> ]
[-r <root password> ]
[-s **5** | <size in GB> ]
@ -159,9 +159,42 @@ ELEMENTS_REPO_PATH
OCTAVIA_REPO_PATH
- Directory containing octavia
- <directory above the script location>
- Default: <directory above the script location>
- Reference: https://github.com/openstack/octavia
RHEL specific variables
------------------------
Building a RHEL-based image requires:
- a RHEL 7 base cloud image, manually download from the
Red Hat Customer Portal. Set the DIB_LOCAL_IMAGE variable
to point to the file. More details at:
<DIB_REPO_PATH>/elements/rhel7
- a Red Hat subscription for the matching Red Hat OpenStack Platform
repository. Set the needed registration parameters depending on your
configuration. More details at:
<DIB_REPO_PATH>/elements/rhel-common
Here is an example with Customer Portal registration and OSP 8 repository:
.. code:: bash
$ export DIB_LOCAL_IMAGE='/tmp/rhel-guest-image-7.2-20160302.0.x86_64.qcow2'
$ export REG_METHOD='portal' REG_REPOS='rhel-7-server-openstack-8-rpms'
$ export REG_USER='<user>' REG_PASSWORD='<password>' REG_AUTO_ATTACH=true
This example uses registration via a Satellite (the activation key must enable
an OSP repository):
.. code:: bash
$ export DIB_LOCAL_IMAGE='/tmp/rhel-guest-image-7.2-20160302.0.x86_64.qcow2'
$ export REG_METHOD='satellite' REG_ACTIVATION_KEY="<activation key>"
$ export REG_SAT_URL="<satellite url>" REG_ORG="<satellite org>"
Container Support
=================
The Docker command line required to import a tar file created with this script

View File

@ -24,7 +24,7 @@ usage() {
echo " [-b **haproxy** ]"
echo " [-c **~/.cache/image-create** | <cache directory> ]"
echo " [-h]"
echo " [-i **ubuntu** | fedora | centos ]"
echo " [-i **ubuntu** | fedora | centos | rhel ]"
echo " [-o **amphora-x64-haproxy** | <filename> ]"
echo " [-r <root password> ]"
echo " [-s **5** | <size in GB> ]"
@ -88,7 +88,8 @@ while getopts "a:b:c:hi:o:t:r:s:vw:" opt; do
AMP_BASEOS=$OPTARG
if [ $AMP_BASEOS != "ubuntu" ] && \
[ $AMP_BASEOS != "fedora" ] && \
[ $AMP_BASEOS != "centos" ]; then
[ $AMP_BASEOS != "centos" ] && \
[ $AMP_BASEOS != "rhel" ]; then
echo "Error: Unsupported base OS " $AMP_BASEOS " specified"
exit 3
fi
@ -194,6 +195,15 @@ fi
export CLOUD_INIT_DATASOURCES=${CLOUD_INIT_DATASOURCES:-"ConfigDrive"}
# Additional RHEL environment checks
if [ "${AMP_BASEOS}" = "rhel" ]; then
if [ -z "${DIB_LOCAL_IMAGE}" ]; then
echo "DIB_LOCAL_IMAGE variable must be set and point to a RHEL 7 base cloud image. Exiting."
echo "For more information, see the README file in ${DIB_ELEMENTS_PATH}/elements/rhel7"
exit 1
fi
fi
# Find out what platform we are on
if [ -e /etc/os-release ]; then
platform=$(head -1 /etc/os-release)
@ -206,7 +216,7 @@ else
fi
if [ "$AMP_ROOTPW" ] && [ "$platform" != 'NAME="Ubuntu"' ]; then
if [ "$(getenforce)" != "Disabled" ]; then
if [ "$(getenforce)" == "Enforcing" ]; then
echo "A root password cannot be enabled for images built on this platform while SELinux is enabled."
exit 1
fi
@ -321,6 +331,9 @@ elif [ "$AMP_BASEOS" = "centos" ]; then
AMP_element_sequence="$AMP_element_sequence centos-mirror"
export CENTOS_MIRROR="$BASE_OS_MIRROR"
fi
elif [ "$AMP_BASEOS" = "rhel" ]; then
AMP_element_sequence=${AMP_element_sequence:-"base vm rhel7"}
AMP_element_sequence="$AMP_element_sequence $AMP_BACKEND"
fi
if [ "$AMP_ROOTPW" ]; then

View File

@ -6,4 +6,4 @@ variable.
.. code:: bash
$ export UBUNTU_MIRROR=http://<local mirror hostname>/<path to mirror>
$ export CENTOS_MIRROR=http://<local mirror hostname>/<path to mirror>

View File

@ -6,4 +6,4 @@ variable.
.. code:: bash
$ export UBUNTU_MIRROR=http://<local mirror hostname>/<path to mirror>
$ export FEDORA_MIRROR=http://<local mirror hostname>/<path to mirror>

View File

@ -1,7 +1,16 @@
#!/bin/bash
echo "" > /etc/resolv.conf
echo "" > /etc/resolv.conf.ORIG
echo "#!/bin/sh
if [ -d /etc/dhcp/dhclient-enter-hooks.d ]
then
# Debian/Ubuntu
echo "#!/bin/sh
make_resolv_conf() { : ; }" > /etc/dhcp/dhclient-enter-hooks.d/noresolvconf
chmod +x /etc/dhcp/dhclient-enter-hooks.d/noresolvconf
rm -f /etc/dhcp/dhclient-enter-hooks.d/resolvconf
chmod +x /etc/dhcp/dhclient-enter-hooks.d/noresolvconf
rm -f /etc/dhcp/dhclient-enter-hooks.d/resolvconf
else
# RHEL/CentOS/Fedora
echo "#!/bin/sh
make_resolv_conf() { : ; }" > /etc/dhclient-enter-hooks
chmod +x /etc/dhclient-enter-hooks
fi