Skip to content

Commit

Permalink
Merge branch 'bugfix/retry-rhsm-registry' into tmp/octopus/w/2.5/bugf…
Browse files Browse the repository at this point in the history
…ix/retry-rhsm-registry
  • Loading branch information
bert-e committed May 13, 2020
2 parents 3d1b364 + 1d77bcf commit 98da2f9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
5 changes: 5 additions & 0 deletions eve/workers/openstack-single-node-rhel/terraform/bootstrap.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ resource "openstack_compute_instance_v2" "bootstrap" {
provisioner "remote-exec" {
inline = [
"sudo bash scripts/rhsm-register.sh '${var.rhsm_username}' '${var.rhsm_password}'",
]
}

provisioner "remote-exec" {
inline = [
"sudo bash scripts/bootstrap-config.sh",
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,28 @@

declare -r RHSM_USERNAME=$1
RHSM_PASSWORD=$2
RETRIES=${3:-5}
WAIT=${4:-2}

subscription-manager register --username "$RHSM_USERNAME" \
--password "$RHSM_PASSWORD" --auto-attach
subscription-manager repos --enable=rhel-7-server-extras-rpms \
--enable=rhel-7-server-optional-rpms
# We retry $RETRIES times in case of transient network issues.
for (( try=0; try <= RETRIES; ++try )); do
if subscription-manager register --username "$RHSM_USERNAME" \
--password "$RHSM_PASSWORD" --auto-attach; then
echo "Successfully registered to RHSM"
if subscription-manager repos --enable=rhel-7-server-extras-rpms \
--enable=rhel-7-server-optional-rpms; then
echo "Yum repositories successfully enabled"
break
fi
fi
echo "Subscription failed, retrying in $WAIT seconds" 1>&2
subscription-manager unregister
sleep "$WAIT"
done

if ! subscription-manager status; then
echo "Unable to register this host to RHSM after $RETRIES retries." \
"Here is the content of /var/log/rhsm.log:" 1>&2
cat /var/log/rhsm/rhsm.log 1>&2
exit 1
fi

0 comments on commit 98da2f9

Please sign in to comment.