Foreman remote_execution_ssh_keys stripping new line causing invalid conditional

Problem:

An invalid conditional is generated when utilizing the latest remote_execution_ssh_keys template. The new line is stripped and the corresponding fi is concatenated with the previous one which renders as fifi.

This causes everything to render, but fails during the install as an invalid script on kickstart provisioning.

  if [ -f /etc/fedora-release ]; then
    PKG_MANAGER='dnf'
  elif [ -f /etc/redhat-release ] ; then
    if [ "${VERSION_ID%.*}" -gt 7 ]; then
      PKG_MANAGER='dnf'
    else
      PKG_MANAGER='yum'
    fi
  elif [ -f /etc/debian_version ]; then
    PKG_MANAGER='apt-get'
  elif [ -f /etc/arch-release ]; then
    PKG_MANAGER='pacman'
  elif [ x$ID = xopensuse-tumbleweed ]; then
    PKG_MANAGER='zypper'
  fifi

Expected outcome:

Expected conditional:

  if [ -f /etc/fedora-release ]; then
    PKG_MANAGER='dnf'
  elif [ -f /etc/redhat-release ] ; then
    if [ "${VERSION_ID%.*}" -gt 7 ]; then
      PKG_MANAGER='dnf'
    else
      PKG_MANAGER='yum'
    fi
  elif [ -f /etc/debian_version ]; then
    PKG_MANAGER='apt-get'
  elif [ -f /etc/arch-release ]; then
    PKG_MANAGER='pacman'
  elif [ x$ID = xopensuse-tumbleweed ]; then
    PKG_MANAGER='zypper'
  fi
fi

Foreman and Proxy versions:

3.17

Foreman and Proxy plugin versions:

3.17

Distribution and version:

RHEL 9

Other relevant data:

I only noticed this when upgrading from RHEL 8 Foreman version 3.12 to RHEL 9 Foreman version 3.17. Unfortunately, I did not do testing with each intermediate version, but this has been resolved by removing the - on the end of the following conditional. I reviewed the develop branch on github and it looks like the issue still exists:

Lines 32 through 34:

if [ -z "$PKG_MANAGER" ]; then
<%= indent(2) { snippet 'pkg_manager' } -%>
fi

It should actually be the following for a correct render:

if [ -z "$PKG_MANAGER" ]; then
<%= indent(2) { snippet 'pkg_manager' } %>
fi