Problem:
The first host that I kickstart with foreman will not complete the content host registration process.
When I say registration process, I am referring to the script that is generated from “hosts/register”
I’ll show the complete registration script to better make the point (I’m unconcerned with the credentials this is a throwaway test host
#!/bin/sh
# Rendered with following template parameters:
# User: [admin]
# Organization: [Default Organization]
# Location: [Default Location]
# Operating system: [CentOS_Linux 8]
# Update packages: [false]
# Lifecycle environment id: [2]
# Activation keys: [CentOS8]
if ! [ $(id -u) = 0 ]; then
echo "Please run as root"
exit 1
fi
if [ -f /etc/os-release ] ; then
. /etc/os-release
fi
SSL_CA_CERT=$(mktemp)
cat << EOF > $SSL_CA_CERT
-----BEGIN CERTIFICATE-----
MIIHCDCCBPCgAwIBAgIUH4VMUW00f5W6HyMreDlDEBl3TwMwDQYJKoZIhvcNAQEL
BQAwgYQxCzAJBgNVBAYTAlVTMRcwFQYDVQQIDA5Ob3J0aCBDYXJvbGluYTEQMA4G
A1UEBwwHUmFsZWlnaDEQMA4GA1UECgwHS2F0ZWxsbzEUMBIGA1UECwwLU29tZU9y
Z1VuaXQxIjAgBgNVBAMMGWxhYjBsMjUudmlydHVhbC5ob21lLmFycGEwHhcNMjEw
OTE1MjAzMTMzWhcNMzgwMTE3MjAzMTMzWjCBhDELMAkGA1UEBhMCVVMxFzAVBgNV
BAgMDk5vcnRoIENhcm9saW5hMRAwDgYDVQQHDAdSYWxlaWdoMRAwDgYDVQQKDAdL
YXRlbGxvMRQwEgYDVQQLDAtTb21lT3JnVW5pdDEiMCAGA1UEAwwZbGFiMGwyNS52
aXJ0dWFsLmhvbWUuYXJwYTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
ANnGPxgATuehWlB+Mwd6xgSgRdfHJIxcXnd0iDVjJAqs8hUCXzekjpe5KbZAOrr4
x8kLAU8HtLyBR3w9Xk7YPZcf0qVl1vSO24HriLYIRFbdyu22v0I1D0RjYrnXUC5J
EaMkI8NhYlwneiVm1VRmxzZnBV2xR3GRX1fGzHW443jxF8z9noQtiHnITtcYK44U
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WGudDinp2zVnqcaOvQ1kxP+LpV4Uaf2ND2IVX0G8wRuA
PX7FKhCS+KU2C7vhRLH9H/n0/RbUPB+sCVPiqdh/yV9MBau1xZhYDK7GPLMzo+o8
BvhNEGT8P93ZF3Wh+sZNCeig+eIrK4QxlZokInA+xR6wT6NojnrdzJDqZlz/ee/M
hKLg251YCJCLDYAj3K8FdrGuik8Dnon9JwvttaCVgmRyFr3DKYbs9KsXDExon3rO
MbAyeQ7Sz85Aqpse+KPqV9m4BQRV4HYCDPJLCQIcn/Bt0kIFk3OIwHGymp7IDTH2
rSDNN59yRioJWwIQiI/hMahaZyYHyfyuW8V978UDk74lE/TI1goKJ9T3IMCfaaj+
Ej7g70C5qbpj0t8nWQqLsVhadZNC9MCN31+HvIsIiv2NS/h1JrJvDmyYIQJ2NlKU
e4r71uMxIj+K1z++CZ7FfAnY7GTIwcy0MX1axK66t7OSwTabH+rl2uiLid4lZEXS
fqxqHj+/TY6uTCBdjUYRJK4i7HPjepWINUeuGhIMrztgLxg8ka+l89nmh7exTIQv
Iqz/TlKeF+AITjsEVD3KtSYcNzgdlCvKLWIsQHET7scQTdceM84zA1KcGJV6nTAx
lgymgrkVDFEorKgwyPoXJfimSBSMBxhcPu8Y2w==
-----END CERTIFICATE-----
EOF
register_host() {
curl --silent --show-error --cacert $SSL_CA_CERT --request POST https://lab0l25.virtual.home.arpa:9090/register \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0LCJpYXQiOjE2MzE3NDgyNDgsImp0aSI6IjFmNWNkMDBhZGVjZjFkNWY1NDQwYTEwZDZkMjY2ZTE2NGYzMDAwNDc3NDVhOWFlMTk0YzM4Nzk0ZjYxMDI1ZDUiLCJleHAiOjE2MzE3NjI2NDgsInNjb3BlIjoicmVnaXN0cmF0aW9uI2dsb2JhbCByZWdpc3RyYXRpb24jaG9zdCJ9._up0suoZrVH0n2MYRl4o55lAdAxcx3c93GVpS4-gvSg' \
--data "host[name]=$(hostname --fqdn)" \
--data "host[build]=false" \
--data "host[managed]=false" \
--data 'host[organization_id]=1' \
--data 'host[location_id]=2' \
--data 'host[operatingsystem_id]=2' \
--data 'update_packages=false' \
}
echo "#"
echo "# Running registration"
echo "#"
if [ x$ID = xrhel ] || [ x$ID = xcentos ] || [ x$ID = xol ]; then
register_katello_host(){
UUID=$(subscription-manager identity | head -1 | awk '{print $3}')
curl --silent --show-error --cacert $SSL_CA_CERT --request POST "https://lab0l25.virtual.home.arpa:9090/register" \
--data "uuid=$UUID" \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0LCJpYXQiOjE2MzE3NDgyNDgsImp0aSI6IjFmNWNkMDBhZGVjZjFkNWY1NDQwYTEwZDZkMjY2ZTE2NGYzMDAwNDc3NDVhOWFlMTk0YzM4Nzk0ZjYxMDI1ZDUiLCJleHAiOjE2MzE3NjI2NDgsInNjb3BlIjoicmVnaXN0cmF0aW9uI2dsb2JhbCByZWdpc3RyYXRpb24jaG9zdCJ9._up0suoZrVH0n2MYRl4o55lAdAxcx3c93GVpS4-gvSg' \
--data 'host[organization_id]=1' \
--data 'host[location_id]=2' \
--data 'host[lifecycle_environment_id]=2' \
--data 'update_packages=false' \
}
# rhn-client-tools conflicts with subscription-manager package
# since rhn tools replaces subscription-manager, we need to explicitly
# install subscription-manager after the rhn tools cleanup
if [ x$ID = xol ]; then
yum remove -y rhn-client-tools
yum install -y --setopt=obsoletes=0 subscription-manager
fi
CONSUMER_RPM=$(mktemp --suffix .rpm)
curl --silent --show-error --output $CONSUMER_RPM http://lab0l25.virtual.home.arpa/pub/katello-ca-consumer-latest.noarch.rpm
# Workaround for systems with enabled FIPS,
# where installation of RPM generated on RHEL7 cause 'no digest' error
# See https://projects.theforeman.org/issues/32068
if [ "$(cat /proc/sys/crypto/fips_enabled)" = "1" ]; then
rpm -ivh --nodigest --nofiledigest $CONSUMER_RPM
else
yum localinstall $CONSUMER_RPM -y
fi
rm -f $CONSUMER_RPM
subscription-manager register \
--org='Default_Organization' \
--activationkey=CentOS8 || exit 1
register_katello_host | bash
else
register_host | bash
fi
The problem is this part of the script
“register_katello_host | bash”
The script is trying to pipe this to bash
echo “ERROR: There was an error rendering the Linux host_init_config default template: undefined method `full_path’ for nil:NilClass”;
So of course you actually get this:
bash: line 1: unexpected EOF while looking for matching ``’
bash: line 3: syntax error: unexpected end of file
Please keep in mind that this only happens for the first host that I am kickstarting
When the second host is kickstarted it does not encounter this same problem.
If I go into the the GUI and select the new host to look at the templates I see an error for every template:
For example at this link: https://lab0l25.virtual.home.arpa/unattended/finish?hostname=lab0l29.virtual.home.arpa
It will return:
There was an error rendering the Kickstart default finish template: undefined method `full_path’ for nil:NilClass
It’s trivial to reproduce here are the steps:
Build new CentOS 8 host / Disable SELINUX / Firewall wide open
Install foreman/katello
Sync CentOS 8 BaseOS/AppStream to a product
Create a content view
Create an LCE
Publish the Content View to the LCE
Create an Activation key
Add a subscription for the content view to the Activation Key
Create a new host using synced content to kickstart the host, use default templates
Login to new host ensure networking is up
Generate a registration script with Hosts > Register Host
Copy and Paste to registration script on the new host
If it helps this is the foreman-installer command I used
foreman-installer --scenario katello --foreman-proxy-tftp true --foreman-proxy-dhcp true --foreman-proxy-dhcp-nameservers 192.168.122.1
Expected outcome:
I expect the content host to complete the registration process without seeing bash errors.
When i review the templates for a host, I do not expect to see an error
If the first host I kickstart has this issue I would expect the second host to have the same problem.
Foreman and Proxy versions:
foreman-3.0.0-1.el8.noarch
foreman-proxy-3.0.0-1.el8.noarch
katello-4.2.0.rc1-1.el8.noarch
Foreman and Proxy plugin versions:
I haven’t installed any plugins
Distribution and version:
CentOS Linux release 8.4.2105
Other relevant data: