diff --git a/elements/rhel/README.md b/elements/rhel/README.md index b7b64a52..f72d0346 100644 --- a/elements/rhel/README.md +++ b/elements/rhel/README.md @@ -16,5 +16,6 @@ Certificate-based Red Hat Subscription Managment (RHSM) is the default registrat Set `DIB_REG_TYPE=rhn` for Red Hat Network (RHN classic) registration. The image building process will register the system to RHN and apply the associated Red Hat Enterprise Linux Server subscription so the latest package updates can be applied. At the end of the image building process, the system will be unregistered from RHN. -* For RHN username/password authentication set DIB_RHSM_USER and DIB_RHSM_PASSWORD. -* Set DIB_RHN_CHANNELS to a space-separated list of RHN channels to add. Example: `DIB_RHN_CHANNELS=rhel-x86_64-server-6 rhel-x86_64-server-6-rhscl-1`. +* For RHN username/password authentication set DIB_RHSM_USER and DIB_RHSM_PASSWORD. To use a Satellite server activation key set DIB_SAT_KEY. If adding RHN channels username and password must be set. +* When registering to Satellite set DIB_SAT_URL to the Satellite server URL and DIB_SAT_CERT_RPM_URL to the Satellite certificate. +* Set DIB_RHN_CHANNELS to a space-separated list of RHN channels to add. Example: `DIB_RHN_CHANNELS=rhel-x86_64-server-6 rhel-x86_64-server-6-rhscl-1`. RHN username/password is required for this. diff --git a/elements/rhel/pre-install.d/00-rhsm b/elements/rhel/pre-install.d/00-rhsm index 9c4438f2..a3338161 100755 --- a/elements/rhel/pre-install.d/00-rhsm +++ b/elements/rhel/pre-install.d/00-rhsm @@ -4,7 +4,22 @@ set -e if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ] then - opts="--force --username ${DIB_RHSM_USER} --password ${DIB_RHSM_PASSWORD}" + opts="--force" + if [[ -n "$DIB_SAT_KEY" ]]; then + opts="$opts --activationkey ${DIB_SAT_KEY}" + else + opts="$opts --username ${DIB_RHSM_USER} --password ${DIB_RHSM_PASSWORD}" + fi + if [[ -n "$DIB_SAT_URL" ]]; then + if [[ "$DIB_REG_TYPE" == "rhn" ]]; then + opts="$opts --serverUrl ${DIB_SAT_URL}" + else + opts="$opts --serverurl ${DIB_SAT_URL} --sslCACert /usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT" + fi + fi + if [[ -n "$DIB_SAT_CERT_RPM_URL" ]]; then + yum install -y ${DIB_SAT_CERT_RPM_URL} + fi if [[ "$DIB_REG_TYPE" == "rhn" ]]; then rhnreg_ks $opts --norhnsd sleep 1