]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Continued with installation of RHEL 9
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 23 Aug 2023 16:01:53 +0000 (18:01 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 23 Aug 2023 16:01:53 +0000 (18:01 +0200)
files/repos-el9/epel.repo [new file with mode: 0644]
kickstart/profile.rhel-9.2.develop.ks
snippets/tpl.110.register-rhel.sh [new file with mode: 0644]
snippets/tpl.190.repos_rhel9.sh [new file with mode: 0644]

diff --git a/files/repos-el9/epel.repo b/files/repos-el9/epel.repo
new file mode 100644 (file)
index 0000000..688b33d
--- /dev/null
@@ -0,0 +1,8 @@
+[epel]
+name=Extra Packages for Enterprise Linux 9 - $basearch
+baseurl=https://repo02.pixelpark.com/Linux/yum/epel/9/Everything/$basearch
+enabled=1
+gpgcheck=1
+repo_gpgcheck=0
+gpgkey=https://repo02.pixelpark.com/repo/gpg/RPM-GPG-KEY-EPEL-9
+
index 847ff426765f26b1876212e7553f00fa5946ad06..eace506a9c262f2c403e2f30c66928a5246aff4d 100644 (file)
@@ -214,6 +214,10 @@ export mac_address_eth0="$mac_address_eth0"
 export system_status="${SYSTEM_STATUS}"
 export ws_rel_filesdir="${WS_REL_FILESDIR}"
 export cobbler_url="${COBBLER_URL}"
+export rhsm_user="${RHSM_USER}"
+export rhsm_pwd="${RHSM_PWD}"
+export rhsm_system_id="${RHSM_SYSTEM_ID}"
+export rhsm_registred=''
 
 #raw
 echo
@@ -228,6 +232,9 @@ echo "MAC address eth0:     '${mac_address_eth0}'"
 echo "System status:        '${system_status}'"
 echo "Ws relative filesdir: '${ws_rel_filesdir}'"
 echo "Cobbler URL:          '${cobbler_url}'"
+echo
+echo "RedHat SubscriptionManager User:      '${rhsm_user}'"
+echo "RedHat SubscriptionManager System ID: '${rhsm_system_id}'"
 #end raw
 
 ###############################################################################
@@ -283,6 +290,16 @@ echo
 echo "Using snippet $this_snippet"
 $SNIPPET($this_snippet)
 
+#set $this_snippet= "per_status/" + $SYSTEM_STATUS + "/tpl.110.register-rhel.sh"
+echo
+echo "Using snippet $this_snippet"
+$SNIPPET($this_snippet)
+
+#set $this_snippet= "per_status/" + $SYSTEM_STATUS + "/tpl.190.repos_rhel9.sh"
+echo
+echo "Using snippet $this_snippet"
+$SNIPPET($this_snippet)
+
 #set $this_snippet= "per_status/" + $SYSTEM_STATUS + "/tpl.195.repos_el9.sh"
 echo
 echo "Using snippet $this_snippet"
diff --git a/snippets/tpl.110.register-rhel.sh b/snippets/tpl.110.register-rhel.sh
new file mode 100644 (file)
index 0000000..77ea16d
--- /dev/null
@@ -0,0 +1,57 @@
+## !/bin/bash
+#raw
+
+#-----------------------------------------------------------
+register_rhel() {
+
+    echo -e "\e[0Ksection_start:$( date +%s ):ks_register_rhel[collapsed=true]\r\e[0KRegistering at RedHat Subscription Management ..."
+    echo
+    echo "${HASH_LINE}"
+    echo
+    log "Registring system at RedHat Subscription Management ..."
+
+    local rhsm='/usr/sbin/subscription-manager'
+    local err_msg=
+    local fqdn=$( hostname -f )
+    local cmd="${rhsm} register --no-progress-messages --username '${rhsm_user}' --password '${rhsm_pwd}' "
+    cmd+="--auto-attach --name '${fqdn}'"
+
+    if [[ -z "${rhsm_user}" || -z "${rhsm_pwd}" ]] ; then
+        err_msg="Either RHSM_USER or RHSM_PWD are not defined as meta variables."
+    else
+        if [[ -x "${rhsm}" ]] ; then
+            if [[ -n "${rhsm_system_id}" ]] ; then
+                if eval ${cmd} --consumerid "${rhsm_system_id}" ; then
+                    rhsm_registred='y'
+                fi
+            fi
+            if [[ -z "${rhsm_registred}" ]] ; then
+                if eval ${cmd} ; then
+                    rhsm_registred='y'
+                else
+                    err_msg="Unexpected error."
+                fi
+            fi
+        else
+            err_msg="Did not found executable '${rhsm}'."
+        fi
+    fi
+
+    if [[ "${rhsm_registred}" ]] ; then
+        log "System '${fqdn}' successful registred at RedHat Subscription Management."
+        echo
+        echo "Subscription Management Idendity:"
+        ${rhsm} identity
+        echo
+        ${rhsm} list --consumed
+    else
+        log "Could not register system '$( hostname -f )' at RedHat Subscription Management: ${err_msg}"
+    fi
+
+    echo -e "\e[0Ksection_end:$( date +%s ):ks_register_rhel\r\e[0K"
+}
+
+register_rhel
+
+#end raw
+## vim: ts=4 et list
diff --git a/snippets/tpl.190.repos_rhel9.sh b/snippets/tpl.190.repos_rhel9.sh
new file mode 100644 (file)
index 0000000..6dcb1fb
--- /dev/null
@@ -0,0 +1,48 @@
+## !/bin/bash
+#raw
+
+#-----------------------------------------------------------
+get_repos_rhel9() {
+
+    echo
+    echo "${HASH_LINE}"
+    echo "Calling get_repos_rhel9() ..."
+    echo
+    # local base_url="${cobbler_url}/${ws_rel_filesdir}/${system_status}/repos/el9"
+    local rhsm='/usr/sbin/subscription-manager'
+
+    log "Installing repositories for RHEL 9."
+
+    if [[ -z "${rhsm_registred}" ]] ; then
+        echo "Cannot generate RedHat repo, system is not registred at RedHat Subscription Management."
+        return
+    fi
+
+    local serial=$( ${rhsm} list --no-progress-messages --consumed | grep -i '^Serial:' | awk '{print $2}' )
+    if [[ -z "${serial}" ]] ; then
+        echo "Cannot generate RedHat repo, did not found subscription serial number."
+        return
+    fi
+
+    log "Found subscription serial number: '${serial}'."
+
+#    local -a repos=('pixelpark' 'puppet')
+
+#    local repo=
+#    local url=
+#    local tmp_file=
+#    for repo in "${repos[@]}" ; do
+#        echo "Ensuring repo '${repo}.repo'..."
+#        url="${base_url}/${repo}.repo"
+#        tmp_file=$( mktemp )
+#        wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" || true
+#        if [[ -s "${tmp_file}" ]] ; then
+#            mv -v "${tmp_file}" "/etc/yum.repos.d/${repo}.repo"
+#        fi
+#        rm -fv "${tmp_file}"
+#    done
+
+}
+get_repos_rhel9
+
+#end raw