Workaround for RHEL registration as "localhost"
authorJames Slagle <jslagle@redhat.com>
Thu, 17 Aug 2017 18:27:30 +0000 (14:27 -0400)
committerJames Slagle <jslagle@redhat.com>
Thu, 17 Aug 2017 18:27:30 +0000 (14:27 -0400)
Workaround systems getting registered as "localhost" during
RHEL registration if they don't have a fqdn set by first
rm'ing the /etc/rhsm/facts directory. When the directory does not
exist, the katello-rshm-consumer which runs when installing
the katello-ca-consumer will not set the hostname.override fact to
"localhost".

Change-Id: Ia29aa9c775f715f9745bb7e1e4022cc395a7d092
Partial-Bug: #1711435

extraconfig/pre_deploy/rhel-registration/scripts/rhel-registration
releasenotes/notes/workaround-unset-fqdn-for-rhel-reg-be9c4620146096be.yaml [new file with mode: 0644]

index d14ed73..487857e 100644 (file)
@@ -235,11 +235,25 @@ case "${REG_METHOD:-}" in
         if [ "$satellite_version" = "6" ]; then
             repos="$repos --enable ${satellite_repo}"
             curl --retry ${retry_max_count} --retry-delay 10 --max-time 30 -L -k -O "$REG_SAT_URL/pub/katello-ca-consumer-latest.noarch.rpm"
+
+            # https://bugs.launchpad.net/tripleo/+bug/1711435
+            # Delete the /etc/rhsm/facts directory entirely so that the
+            # %post script from katello-ca-consumer does not override the
+            # hostname with $(hostname -f) if there is no fqdn set
+            fqdn=$(hostname -f)
+            if [ "$fqdn" = "localhost" -o "$fqdn" = "localhost.localdomain" ]; then
+                rm -rf /etc/rhsm/facts
+            fi
+
             rpm -Uvh katello-ca-consumer-latest.noarch.rpm || true
             retry subscription-manager register $opts
             retry subscription-manager $repos
             retry yum install -y katello-agent || true # needed for errata reporting to satellite6
             katello-package-upload
+
+            # https://bugs.launchpad.net/tripleo/+bug/1711435
+            # recreate the facts dir just in case we rm'd it earlier
+            mkdir -p /etc/rhsm/facts
         else
             pushd /usr/share/rhn/
             curl --retry ${retry_max_count} --retry-delay 10 --max-time 30 -k -O $REG_SAT_URL/pub/RHN-ORG-TRUSTED-SSL-CERT
diff --git a/releasenotes/notes/workaround-unset-fqdn-for-rhel-reg-be9c4620146096be.yaml b/releasenotes/notes/workaround-unset-fqdn-for-rhel-reg-be9c4620146096be.yaml
new file mode 100644 (file)
index 0000000..04b21fb
--- /dev/null
@@ -0,0 +1,8 @@
+---
+fixes:
+  - Workaround systems getting registered as "localhost" during
+    RHEL registration if they don't have a fqdn set by first
+    rm'ing the /etc/rhsm/facts directory. When the directory does not
+    exist, the katello-rshm-consumer which runs when installing
+    the katello-ca-consumer will not set the hostname.override fact to
+    "localhost". See https://bugs.launchpad.net/tripleo/+bug/1711435