Project

General

Profile

Bug #35326

Foreman Puppet ENC "hostname" and "fqdn" conflict with core Puppet Facts

Added by Paul Donohue 6 months ago. Updated about 2 months ago.

Status:
Closed
Priority:
High
Assignee:
Category:
External Nodes
Target version:

Description

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:
https://github.com/theforeman/foreman/pull/8103
https://github.com/theforeman/foreman/pull/8134

However, those parameter names conflict with the names of some "Core Facts" in Puppet:
https://puppet.com/docs/puppet/7/core_facts.html#hostname
https://puppet.com/docs/puppet/7/core_facts.html#fqdn

Unfortunately, this causes a number of problems 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.)


Related issues

Related to Foreman - Bug #31168: Show host name in ENC output Closed

Associated revisions

Revision dd9f24f4 (diff)
Added by Paul Donohue about 2 months ago

Fixes #35326 - Rename hostname/fqdn ENC vars to avoid conflicts

History

#1 Updated by The Foreman Bot 6 months ago

  • Assignee set to Paul Donohue
  • Status changed from New to Ready For Testing

#2 Updated by Ewoud Kohl van Wijngaarden about 2 months ago

  • Target version set to 3.5.0
  • Category set to External Nodes

#3 Updated by The Foreman Bot about 2 months ago

  • Fixed in Releases 3.6.0 added

#4 Updated by Ewoud Kohl van Wijngaarden about 2 months ago

  • Related to Bug #31168: Show host name in ENC output added

#5 Updated by The Foreman Bot about 2 months ago

  • Pull request https://github.com/theforeman/foreman-documentation/pull/1883 added

#6 Updated by Anonymous about 2 months ago

  • Status changed from Ready For Testing to Closed

#7 Updated by The Foreman Bot about 2 months ago

  • Pull request https://github.com/theforeman/foreman/pull/9555 added

#8 Updated by The Foreman Bot about 2 months ago

  • Fixed in Releases 3.5.0 added

#9 Updated by Ewoud Kohl van Wijngaarden about 2 months ago

  • Fixed in Releases deleted (3.6.0)

Also available in: Atom PDF