Using Short Host Names with Puppet

Greetings, I have been struggling with this for a while. I use foreman to
provision but NOT ENC. Foreman sets the short host name in the puppet.conf
for a new VM. Foreman also is set to use_short_name_for_vms.

After the provision, 3 host entries are created:

  • short name
  • FQDN.1 (using the private network interface)
  • FQDN.2 (using a different network interface) — this is the only one
    that gets reports from puppet

What do I need to change to force foreman to use ONLY the short host name?

Additional Details
I am also using the external_node_v2.rb and foreman-report_v2.rb on my
puppet server

From external_node_v2.rb
" hostname = puppet_facts['values']['fqdn'] || certname"
Which seems that it will always get the long FQDN from puppet

I don't see any traces of fqdn in foreman-report

Rational
I want to use the short host name is that puppet also manages the
puppet.conf. Puppet would have no way of knowing which FQDN foreman choose
to use*. S*o it seems that the cleanest and best solution for me is to use
hostname not to mention, having FQDN's really muddies the UI.

> Greetings, I have been struggling with this for a while. I use foreman to
> provision but NOT ENC. Foreman sets the short host name in the puppet.conf
> for a new VM. Foreman also is set to use_short_name_for_vms.
>

To clarify, the shortname is used for the certname in puppet.conf?

> After the provision, 3 host entries are created:
>
> - short name
> - FQDN.1 (using the private network interface)
> - FQDN.2 (using a different network interface) — this is the only
> one that gets reports from puppet
>
> What do I need to change to force foreman to use ONLY the short host name?
>

That's immediately after provisioning, with zero puppet runs so far? I'd
find that pretty odd, even accounting for weirdness in the puppet importer.

> Additional Details
> I am also using the external_node_v2.rb and foreman-report_v2.rb on my
> puppet server
>
> From external_node_v2.rb
> " hostname = puppet_facts['values']['fqdn'] || certname"
> Which seems that it will always get the long FQDN from puppet
>

External_node is the script for fetching the enc data - its
foreman_report.rb that handles the upload. In that file, we use the host
object as Puppet holds it, which should be via the certname.

Could you enable debug logging and then tail
/var/log/foreman/production.log while a report is being upload? It should
give more info about what's happening

··· On 13 April 2016 at 03:05, Michael Speth wrote:

I have 'fixed' my problem by doing the following:

  • Set the cert name to the host.name in puppet.conf provisioning template
  • Set the hostname to short name (so that I can still use short
    hostnames in hiera)
  • Add long and short hostname in /etc/hosts (foreman template) — IE
    127.0.0.1 hostname.com hostname
  • Changed certname in puppet agent module
    <https://bitbucket.org/fullflavour/puppet-agent> that manages
    puppet.conf to append the FQDN to short hostname

So this was the problem with Foreman 1.10.

I just upgraded to Foreman 1.11 hoping this would fix the problem. But it
introduced a new problem.

On provision, PuppetCA autosign is using the FQDN instead of the short host
name. So when puppet run on the client, it's cert doesn't get
automatically added! So I can't troubleshoot the previous error until I
get this one fixed.