theforeman / foreman_puppet

https://theforeman.org/plugins/foreman_puppet/
GNU General Public License v3.0
7 stars 24 forks source link

ENC should use valid Puppet variable names #129

Closed ezr-ondrej closed 11 months ago

ezr-ondrej commented 3 years ago

Currently the Puppet ENC output from Foreman simply takes host parameters as defined, and pushes them into the parameters hash without modification.

The Puppet documentation states: "If present, the value of the parameters key must be a hash of valid variable names and associated values". https://puppet.com/docs/puppet/7.5/nodes_external.html#enc_output_format-section_rbt_2vm_thb

It is currently possible to use dashes in host parameter names, which are then populated into the ENC output; however, variables may not contain dashes in Puppet. As a result, host parameters containing dashes are not accessible within Puppet. (Note: they were previously accessible using the getvar function in Puppet 5, but this no longer works in Puppet 6+).

While it is possible to work around this issue manually by simply not using dashes in host parameters, there are some dashed host parameters that are used in provisioning templates (such as http-proxy), which are useful in Puppet as well. A current workaround is to define the value twice, once for the templates and one for the ENC value for Puppet, but this is inconvenient and prone to accidental drift.

The Foreman ENC output should convert dashes to underscores for host parameter names containing dashes.

ezr-ondrej commented 3 years ago

This is from https://projects.theforeman.org/issues/32222