puppet-telegraf icon indicating copy to clipboard operation
puppet-telegraf copied to clipboard

Broken $hostname default value when fact['networking'] is null

Open brabiega opened this issue 4 years ago • 1 comments

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 5.4.0
  • Ruby: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
  • Distribution: Server - Ubuntu Bionic, Agent - Ubuntu Trusty
  • Module version: v3.0.0

How to reproduce (e.g Puppet code you use)

I have quite specific setup - I'm running puppet in some old, long running docker containers. Probably due to that the "networking" fact is empty on such nodes which causes:

{"message":"Server Error: Evaluation Error: Operator '[]' is not applicable to an Undef Value. (file: /etc/puppet/environments/production/modules/telegraf/manifests/params.pp, line: 37, column: 29) 

This line is the problem:

$hostname               = $facts['networking']['hostname']

Even when I pass the $hostname directly when I initialize telegraf module the default value can't be fetched from facts and whole catalog fails.

What are you seeing

mon-01-59c36840-1d9d-4ec4-a4e8-317b19e83d3c:~ # facter -p networking -j
{
  "networking": null
}

What behaviour did you expect instead

That's a good question. The catalog compilation shouldn't fail when $hostname is provided and default value cannot be resolved.

Output log

mon-01-59c36840-1d9d-4ec4-a4e8-317b19e83d3c:~ # facter -p networking -j
{
  "networking": null
}

Any additional information you'd like to impart

brabiega avatar Mar 04 '20 08:03 brabiega

This is due to version of facter.

The version shipped with Puppet package All In One (aka AIO) provided by Puppet Inc. is not the same one that version shipped by Puppet package provided by packagers of GNU/Linux distribs.

Unfortunately we can not gives requirement about facter in the metadata.json file, only about Puppet.

Fewer and fewer legacy facts (not structured) are removed from modules.

We use and tests VP modules with AIO packages. My advice is to use the same than us.

Dan33l avatar Mar 04 '20 09:03 Dan33l