Foreman Puppet ENC "hostname" and "fqdn" conflict with core Puppet Facts
I apparently created #34965 in the wrong redmine project. Creating a new issue to replace it.
Per #31168, "hostname" and "fqdn" parameters were added to the Puppet ENC YAML produced by Foreman for use in Ansible:
However, those parameter names conflict with the names of some "Core Facts" in Puppet:
- In some but not all cases, the ENC parameters override the Facts. In addition to being inconsistent, this can break things. For example, see #31882
- If someone actually wants both the ENC value and the Fact value for some reason (eg. if they want to use the ENC value as the canonical hostname and reconfigure the system if it doesn't match), there is no reliable way in Puppet code to get both or to determine which one actually configured the variable.
- The ENC parameters cause warning messages in the Puppet logs. For example, see https://community.theforeman.org/t/puppet-the-node-parameter-fqdn-for-node-host-was-already-set-to-host/26543
- This prevents the ENC parameters from being used with other Puppet interfaces. For example, for Puppet Module development/testing purposes, I have a script that retrieves the ENC output, reformats it as a .pp file that sets variables and declares classes, then runs the .pp file with `puppet apply --test --noop test.pp`. The conflicting name causes the puppet agent to fail with a "Cannot reassign variable '$hostname'" error.
Can these parameters be renamed?
Renaming the parameters would avoid all of the above issues in Puppet while still achieving the goal of giving Ansible access to these values.
For example, the names could be changed to "foreman_hostname" and "foreman_fqdn" to emulate other existing Foreman-specific parameters (like "foreman_env").
Alternatively, a structured parameter could be used to emulate "Modern" Core Facts in Puppet. In other words, a "foreman" parameter could be created with sub-parameters named "hostname" and "fqdn". (Or maybe call it "foreman_network" to mimic the "network" Core Fact in Puppet, which also contains "hostname" and "fqdn" sub-parameters.)