Template code not being applied to new host

I have a subscription snippet that connects a new host to either our Foreman master or proxies depending on an if condition. see: ERB code help - #8 by chatlow

The code works perfectly in the preview section when applying it to 2 hosts that use 2 different proxies.
Unfortunately the snippet code fails when building a new host due to the wrong code being passed to it. The correct code is showing in the new hosts legacy UI template info, but anaconda shows differently.

Any idea if this is a previously known bug?

1 Like

Since this is about provisioning, maybe @lstejska or @nofaralfasi could help? Perhaps there is already a redmine if there is a bug here.

Also, to tie loose ends, which category of template is this, Kickstart? Which version of Foreman are you using?

Was using 3.6 but yesterday I upgraded it to 3.10 (with katello). Same result with this version.
And just to be clear this is a snippet that I’m linking into my main kickstart.

If @nofaralfasi or @lstejska can help at all, that would be great :slight_smile:

I’ve pasted the code here as well rather than having to open the linked page:

<% if foreman_url(‘provision’) == ‘http://sv-prod-foreman01.mydomain.com/unattended/provision’ -%>
curl --insecure --output katello-ca-consumer-latest.noarch.rpm https://sv-prod-foreman01.mydomain.com/pub/katello-ca-consumer-latest.noarch.rpm
rpm -Uvh katello-ca-consumer-latest.noarch.rpm
subscription-manager register --org=“mine” --activationkey=“EL8-LIBRARY” --force
subscription-manager register --org=“mine” --activationkey=“EL8-LIBRARY”

yum install -y katello-host-tools katello-host-tools-tracer
katello-tracer-upload

<% else -%>
curl --insecure --output katello-ca-consumer-latest.noarch.rpm https://<%= foreman_url(‘provision’).gsub(/http://(.):./, ‘\1’) %>/pub/katello-ca-consumer-latest.noarch.rpm
rpm -Uvh katello-ca-consumer-latest.noarch.rpm
subscription-manager register --org=“mine” --activationkey=“EL8-LIBRARY” --force
subscription-manager register --org=“mine” --activationkey=“EL8-LIBRARY”

yum install -y katello-host-tools katello-host-tools-tracer
katello-tracer-upload

The else part works perfectly, the hardcoded url does not. Although the preview shows that it would.

Many thanks,