fix rhsm register erroring

This commit is contained in:
Matthew Mosesohn 2013-08-27 19:46:55 +04:00
parent 4ba6ff5aa6
commit 0d803997d7
2 changed files with 12 additions and 6 deletions

View File

@ -1,5 +1,5 @@
node default {
$rh_base_channels = "rhel-6-server-rpms rhel-6-server-optional-rpms rhel-lb-for-rhel-6-server-rpms rhel-rs-for-rhel-6-server-rpms rhel-ha-for-rhel-6-server-rpms rhel-server-ost-6-folsom-rpms"
$rh_base_channels = "rhel-6-server-rpms rhel-6-server-optional-rpms rhel-lb-for-rhel-6-server-rpms rhel-rs-for-rhel-6-server-rpms rhel-ha-for-rhel-6-server-rpms"
$rh_openstack_channel = "rhel-server-ost-6-3-rpms"
$numtries = "3"
$sat_base_channels = "rhel-x86_64-server-6 rhel-x86_64-server-optional-6 rhel-x86_64-server-lb-6 rhel-x86_64-server-rs-6 rhel-x86_64-server-ha-6"

View File

@ -27,7 +27,8 @@ for plugin in $rhsm_plugins; do
done
#Register
rhsmoutput=$(subscription-manager register "--username=<%= rh_username %>" "--password=<%= rh_password %>" --autosubscribe --force 2>&1)
exitcode=0
rhsmoutput=$(subscription-manager register "--username=<%= rh_username %>" "--password=<%= rh_password %>" --autosubscribe --force 2>&1) || exitcode=$?
exitcode=$?
case $exitcode in
0) echo "Register succeeded"
@ -38,12 +39,18 @@ case $exitcode in
exit $exitcode
;;
esac
#Attach to RHOS product
poolid="$(subscription-manager list --available | grep -A2 "OpenStack" | tail -1 | cut -c15- | tr -d ' \t')"
subscription-manager attach "--pool=$poolid"
trap revert_back_to_centos EXIT
#Set releasever and refresh repos
echo 6Server > /etc/yum/vars/releasever
yum clean expire-cache
#Enable channels
for channel in <%= rh_base_channels %> <%= rh_openstack_channel %>; do
yum-config-manager --enable "$channel" &> /dev/null
@ -134,17 +141,15 @@ fi
#Download packages
mkdir -p <%= pkgdir %>/repodata <%= pkgdir %>/Packages
rm -f /etc/yum/vars/releasever
yum-config-manager --disable 'nailgun' &> /dev/null
yum-config-manager --disable 'centos' --disable 'extras' --disable 'updates' &> /dev/null
yum-config-manager --disable 'base' &> /dev/null
echo 6Server > /etc/yum/vars/releasever
echo "Building initial cache. This may take several minutes."
yum --releasever=<%= releasever %> makecache
for tries in $(seq 1 <%= numtries %>); do
#Retry if repotrack fails
/usr/local/bin/repotrack -a x86_64,noarch -p "<%= pkgdir %>/Packages" $(cat /etc/nailgun/required-rpms.txt | xargs echo -en) || continue
/usr/local/bin/repotrack -a x86_64,noarch -p "<%= pkgdir %>/Packages" $(cat /etc/nailgun/required-rpms.txt | xargs echo -en) 2>&1 || continue
status=$?
#Purge any corrupt downloaded RPMs
# FIXME: There is a error with a path substitution
@ -160,7 +165,7 @@ for tries in $(seq 1 <%= numtries %>); do
fi
done
if [ "$status" -ne 0 ]; then
if [ $status -ne 0 ]; then
echo "ERROR: Repotrack did not exit cleanly after <%= numtries %> tries." 1>&2
exit 1
fi
@ -187,3 +192,4 @@ umount /mnt/rhel_iso
rpm -e rhel-boot-image-6.4-20130130.0.el6ost.noarch
exit 0