voxpupuli / puppet-network

Types and providers to manage network interfaces
https://forge.puppet.com/puppet/network
Apache License 2.0
66 stars 107 forks source link

Puppet facts not populating after 61b10ea7fc1861bd334f14aad456d3027592e68f #274

Closed sboyd-m closed 2 years ago

sboyd-m commented 2 years ago

Affected Puppet, Ruby, OS and module versions/distributions

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

Simply try and read the fact network_primary_interface

What are you seeing

Fact returns the empty string.

What behaviour did you expect instead

Not the empty string.

puppet@box:~$ /opt/puppetlabs/puppet/bin/facter -j -p networking.primary
{
  "networking.primary": "eth0"
}
puppet@box:~$ /opt/puppetlabs/puppet/bin/facter -j -p network_primary_interface
{
  "network_primary_interface": ""
}
puppet@box:~$ /opt/puppetlabs/puppet/bin/facter /opt/puppetlabs/puppet/cache/lib/facter/network.rb

puppet@box:~$ /opt/puppetlabs/puppet/bin/facter -j -p networking.primary
{
  "networking.primary": "eth0"
}
puppet@box:~$ /opt/puppetlabs/puppet/bin/facter -j -p network_primary_interface
{
  "network_primary_interface": ""
}
puppet@box:~$ md5sum /opt/puppetlabs/puppet/cache/lib/facter/network.rb
6d9bca1d4813ea164f4a46b654fa0f66  /opt/puppetlabs/puppet/cache/lib/facter/network.rb
sboyd-m commented 2 years ago

We use this fact internally as hiera like so:

nat_gateway::public_interface: "%{::network_primary_interface}"

I confirmed by viewing puppet logs that this fact stopped working exactly when this commit happened, and I also verified the hashes of the file before and after based on the puppet logs: content changed '{md5}9164ece59c43998af1efb392c0023ff6' to '{md5}6d9bca1d4813ea164f4a46b654fa0f66'

Curiously, I patched our hiera to use the networking.primary fact, and now the module fact shows up, albeit under a different name:

root@box:~$ facter -j -p ':network_primary_interface'
{
  ":network_primary_interface": "eth0"
}

root@box:~$ facter -j -p 'network_primary_interface'
{
  "network_primary_interface": ""
}

I do not know what the root cause issue is.

sboyd-m commented 2 years ago

Ahh, I didn't notice at first, but that commit added colons to the beginnings of all the facts that used to exist...

Why? Why break things?

EDIT: Were you trying to use ruby symbols instead of strings?

kenyon commented 2 years ago

https://github.com/voxpupuli/puppet-network/commit/61b10ea7fc1861bd334f14aad456d3027592e68f was in #268.

yakatz commented 2 years ago

Right, facts are being generated with names with leading colons:

image

alexjfisher commented 2 years ago

EDIT: Were you trying to use ruby symbols instead of strings?

This seems very likely.

alexjfisher commented 2 years ago

Fixed in https://github.com/voxpupuli/puppet-network/pull/278