From 6e97a37744d0d94489000ab105c4b927deb59e79 Mon Sep 17 00:00:00 2001 From: Bernard Cafarelli Date: Thu, 23 Jun 2016 16:04:19 +0200 Subject: [PATCH] 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 --- diskimage-create/README.rst | 37 ++++++++++++++++++- diskimage-create/diskimage-create.sh | 19 ++++++++-- elements/centos-mirror/README.rst | 2 +- elements/fedora-mirror/README.rst | 2 +- .../finalise.d/99-disable-resolv-conf | 15 ++++++-- 5 files changed, 65 insertions(+), 10 deletions(-) diff --git a/diskimage-create/README.rst b/diskimage-create/README.rst index 1c2ec56b4e..ea5aa83396 100644 --- a/diskimage-create/README.rst +++ b/diskimage-create/README.rst @@ -93,7 +93,7 @@ Command syntax: [-b **haproxy** ] [-c **~/.cache/image-create** | ] [-h] - [-i **ubuntu** | fedora | centos ] + [-i **ubuntu** | fedora | centos | rhel ] [-o **amphora-x64-haproxy** | ] [-r ] [-s **5** | ] @@ -159,9 +159,42 @@ ELEMENTS_REPO_PATH OCTAVIA_REPO_PATH - Directory containing octavia - - + - Default: - 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: + /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: + /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='' REG_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="" + + $ export REG_SAT_URL="" REG_ORG="" + + Container Support ================= The Docker command line required to import a tar file created with this script diff --git a/diskimage-create/diskimage-create.sh b/diskimage-create/diskimage-create.sh index 010d6b5913..908f987d5e 100755 --- a/diskimage-create/diskimage-create.sh +++ b/diskimage-create/diskimage-create.sh @@ -24,7 +24,7 @@ usage() { echo " [-b **haproxy** ]" echo " [-c **~/.cache/image-create** | ]" echo " [-h]" - echo " [-i **ubuntu** | fedora | centos ]" + echo " [-i **ubuntu** | fedora | centos | rhel ]" echo " [-o **amphora-x64-haproxy** | ]" echo " [-r ]" echo " [-s **5** | ]" @@ -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 diff --git a/elements/centos-mirror/README.rst b/elements/centos-mirror/README.rst index 676d5f72be..3f67789e73 100644 --- a/elements/centos-mirror/README.rst +++ b/elements/centos-mirror/README.rst @@ -6,4 +6,4 @@ variable. .. code:: bash - $ export UBUNTU_MIRROR=http:/// + $ export CENTOS_MIRROR=http:/// diff --git a/elements/fedora-mirror/README.rst b/elements/fedora-mirror/README.rst index f2a48ee1d5..b51c99fb46 100644 --- a/elements/fedora-mirror/README.rst +++ b/elements/fedora-mirror/README.rst @@ -6,4 +6,4 @@ variable. .. code:: bash - $ export UBUNTU_MIRROR=http:/// + $ export FEDORA_MIRROR=http:/// diff --git a/elements/no-resolvconf/finalise.d/99-disable-resolv-conf b/elements/no-resolvconf/finalise.d/99-disable-resolv-conf index 2675b8ecf0..72c04a15a2 100755 --- a/elements/no-resolvconf/finalise.d/99-disable-resolv-conf +++ b/elements/no-resolvconf/finalise.d/99-disable-resolv-conf @@ -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