--- /dev/null
+[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
+
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
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
###############################################################################
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"
--- /dev/null
+## !/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
--- /dev/null
+## !/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