RFC: Drop parsing NIC interfaces

I didn’t test the full go binary, but I don’t see why you need the custom fact:

# cat /etc/puppetlabs/facter/facts.d/bla
#!/bin/bash
cat <<EOF
{
  "link": {
    "bond0": {
      "bond": {
        "mode": 1
      },
      "mac": "52:54:00:aa:bb:cc",
      "type": "bond"
    },
    "bond0.10": {
      "mac": "52:54:00:aa:bb:cc",
      "parent": "bond0",
      "type": "vlan",
      "vlan": {
        "id": 10,
        "protocol": 33024
      }
    },
    "enp1s0": {
      "mac": "52:54:00:aa:bb:cc",
      "master": "bond0",
      "slave": "bond",
      "type": "device"
    },
    "enp7s0": {
      "mac": "52:54:00:aa:bb:cc",
      "master": "bond0",
      "slave": "bond",
      "type": "device"
    },
    "lo": {
      "type": "device"
    }
  }
}
EOF
# facter link.bond0
{
  bond => {
    mode => 1
  },
  mac => "52:54:00:aa:bb:cc",
  type => "bond"
}

We are essentially asking all our users to use our custom tooling where in the past we’ve always aimed at collaborating and integrating existing tools. Please reach out to the Facter team, for example by creating an issue to see if this can be done upstream so we don’t have to ship anything.

Well, with facter from Fedora stable I get:

# facter link.bond0
-e: [BUG] Segmentation fault at 0x0000000000000000
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0001 p:0000 s:0003 E:001450 (none) [FINISH]


-- Machine register context ------------------------------------------------
 RIP: 0x00007ffff7e60b83 RBP: 0x0000000000000000 RSP: 0x00007fffffffc560
 RAX: 0x0000000000000000 RBX: 0x000055555597a3e8 RCX: 0x00007ffff7d0a8b8
 RDX: 0x000055555598f0a0 RDI: 0x00007fffffffc610 RSI: 0x0000000000000000
  R8: 0x0000000000000001  R9: 0x00005555559afb00 R10: 0x0000000000000000
 R11: 0x00007ffff7af8a40 R12: 0x000055555597a3f0 R13: 0x00007fffffffc5f0
 R14: 0x00007fffffffc770 R15: 0x00007fffffffc930 EFL: 0x0000000000010246

-- C level backtrace information -------------------------------------------
/usr/lib64/libruby.so.2.6.5(0x7fffe7704399) [0x7fffe7704399]
/usr/lib64/libruby.so.2.6.5(0x7fffe77045cc) [0x7fffe77045cc]
/usr/lib64/libruby.so.2.6.5(0x7fffe75a22d0) [0x7fffe75a22d0]
/usr/lib64/libruby.so.2.6.5(0x7fffe7689966) [0x7fffe7689966]
/lib64/libc.so.6(__restore_rt+0x0) [0x7ffff79726b0]
/lib64/libfacter.so.3.14.2(_ZNK6facter5facts8external18execution_resolver7resolveERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS0_10collectionE+0x163) [0x7ffff7e60b83]
/lib64/libfacter.so.3.14.2(0x7ffff7e56c2f) [0x7ffff7e56c2f]
/lib64/leatherman_file_util.so.1.6.1(0x7ffff74a0aca) [0x7ffff74a0aca]
/lib64/libfacter.so.3.14.2(0x7ffff7e52e6b) [0x7ffff7e52e6b]
/lib64/libfacter.so.3.14.2(_ZN6facter5facts10collection18add_external_factsERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EE+0x80) [0x7ffff7e53110]
facter(main+0x2984) [0x5555555746d4]

-- Other runtime information -----------------------------------------------

* Loaded script: -e

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 rational.so
    3 complex.so
    4 /usr/lib64/ruby/enc/encdb.so
    5 /usr/lib64/ruby/enc/trans/transdb.so
    6 /usr/lib64/ruby/rbconfig.rb
    7 /usr/share/rubygems/rubygems/compatibility.rb
    8 /usr/share/rubygems/rubygems/defaults.rb
    9 /usr/share/rubygems/rubygems/deprecate.rb
   10 /usr/share/rubygems/rubygems/errors.rb
   11 /usr/share/rubygems/rubygems/version.rb
   12 /usr/share/rubygems/rubygems/requirement.rb
   13 /usr/share/rubygems/rubygems/platform.rb
   14 /usr/share/rubygems/rubygems/basic_specification.rb
   15 /usr/share/rubygems/rubygems/stub_specification.rb
   16 /usr/share/ruby/delegate.rb
   17 /usr/share/ruby/uri/rfc2396_parser.rb
   18 /usr/share/ruby/uri/rfc3986_parser.rb
   19 /usr/share/ruby/uri/common.rb
   20 /usr/share/ruby/uri/generic.rb
   21 /usr/share/ruby/uri/file.rb
   22 /usr/share/ruby/uri/ftp.rb
   23 /usr/share/ruby/uri/http.rb
   24 /usr/share/ruby/uri/https.rb
   25 /usr/share/ruby/uri/ldap.rb
   26 /usr/share/ruby/uri/ldaps.rb
   27 /usr/share/ruby/uri/mailto.rb
   28 /usr/share/ruby/uri.rb
   29 /usr/share/rubygems/rubygems/specification_policy.rb
   30 /usr/share/rubygems/rubygems/util/list.rb
   31 /usr/lib64/ruby/stringio.so
   32 /usr/share/rubygems/rubygems/specification.rb
   33 /usr/share/rubygems/rubygems/exceptions.rb
   34 /usr/share/rubygems/rubygems/defaults/operating_system.rb
   35 /usr/share/rubygems/rubygems/util.rb
   36 /usr/share/rubygems/rubygems/bundler_version_finder.rb
   37 /usr/share/rubygems/rubygems/dependency.rb
   38 /usr/share/rubygems/rubygems/core_ext/kernel_gem.rb
   39 /usr/share/ruby/monitor.rb
   40 /usr/share/rubygems/rubygems/core_ext/kernel_require.rb
   41 /usr/share/rubygems/rubygems/core_ext/kernel_warn.rb
   42 /usr/share/rubygems/rubygems.rb
   43 /usr/share/rubygems/rubygems/path_support.rb
   44 /usr/share/gems/gems/did_you_mean-1.3.0/lib/did_you_mean/version.rb
   45 /usr/share/gems/gems/did_you_mean-1.3.0/lib/did_you_mean/core_ext/name_error.rb
   46 /usr/share/gems/gems/did_you_mean-1.3.0/lib/did_you_mean/levenshtein.rb
   47 /usr/share/gems/gems/did_you_mean-1.3.0/lib/did_you_mean/jaro_winkler.rb
   48 /usr/share/gems/gems/did_you_mean-1.3.0/lib/did_you_mean/spell_checker.rb
   49 /usr/share/gems/gems/did_you_mean-1.3.0/lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
   50 /usr/share/gems/gems/did_you_mean-1.3.0/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
   51 /usr/share/gems/gems/did_you_mean-1.3.0/lib/did_you_mean/spell_checkers/name_error_checkers.rb
   52 /usr/share/gems/gems/did_you_mean-1.3.0/lib/did_you_mean/spell_checkers/method_name_checker.rb
   53 /usr/share/gems/gems/did_you_mean-1.3.0/lib/did_you_mean/spell_checkers/key_error_checker.rb
   54 /usr/share/gems/gems/did_you_mean-1.3.0/lib/did_you_mean/spell_checkers/null_checker.rb
   55 /usr/share/gems/gems/did_you_mean-1.3.0/lib/did_you_mean/formatters/plain_formatter.rb
   56 /usr/share/gems/gems/did_you_mean-1.3.0/lib/did_you_mean.rb
   57 /usr/share/gems/gems/did_you_mean-1.3.0/lib/facter.rb

* Process memory map:

555555554000-55555556f000 r--p 00000000 103:03 4326779                   /usr/bin/facter
55555556f000-55555558b000 r-xp 0001b000 103:03 4326779                   /usr/bin/facter
55555558b000-555555595000 r--p 00037000 103:03 4326779                   /usr/bin/facter

But I am fine doing it this way.

Sure, but this will take some time and if we want to merge stuff in core, users need to be able to use it from the day one. So I thought shipping custom/external fact first and then working on getting this integrated could be a way.

Let me first try if this works end to end and then we can open up question of integrating it upstream.

Other duties made me to suspend this effort a bit but I want to get back to it. One thing comes to my mind. Suppose we define some common fact model where we only have one fact to report let’s say OS version. And customer uses RHSM + Puppet:

  • puppet reports “7.7.1234”
  • rhsm reports “7.7”
  • there is a bug (we have missed transformation)

In this case every fact upload would overwrite the value over and over again. How do you think we should solve this?

I really like the idea of common fact model, however this could bring another can of worms. One solution could be defining some kind of importance. Let’s say that puppet < ansible < rhsm. So if rhsm plugin woud report different fact value against already stored different value reported by ansible or puppet, it would be simply dropped.

Ideally we should be able to catch all these special cases since the common model should not be too wide (only selected facts), so this would not happen in the future. But we all know nobody is perfect and there are so many configurations and states.

My biggest concern with this approach of creating a new tool for generating facts is that it requires additional setup by the user to work, and might not be very useful for importing existing hosts in a brown-field setup, which might not have an easy way of installing the new tool on all hosts.
In essence, we would still need to support all the existing fact sources, plus our own custom-made one.
Or as Randall Munroe quite well put it: https://xkcd.com/927/

I don’t follow which tool you refer to. What do you refer as the “standard” tool and the “new” tool?

I’m reffering to ufacter as the new tool and existing sources (puppet/ansible/subman/etc) as the standard tools. While I understand this will give us better facts built just like we want them, it won’t solve the issue of needing to be able to parse facts from the existing sources, and it will require more effort for most users to set up in their environment (assuming most already have some CM tool in place).

This was never considered to be any replacement at any point. I wrote it as a future replacement (maybe) for discovery, but it’s mainly complementary and it would be called from PuppetLabs facter as an external fact.

I did suggest it to the user who asked yesterday in other thread as he literally asked to register a system without puppet. Granted, I extrapolated a bit. However, using a “facter-compatible” tool is something we should not disencourage our users to do. There are probably two dozens of “facter-like” tools floating around.

This could maybe be used for foreman-discovery as well instead of the full-blown facter version.

I do think it would also be nice to know exactly the minimum facts required to register a system. Right now things like ansible just throw the kitchen sink of facts at foreman, and it might be nice to have an option in the ansible plugin to only upload the ‘required’ facts to foreman. I have already thought about working on the foreman plugin in ansible to reduce the amount of stuff it upload to foreman.

That’s exactly what I propose in this thread: CFM - common facts model. I think I am going to start off by defining some basic facts, what the expectations are, the format and start a new thread about it so others can comment on that. I am assuming this would be based on facter3, but we don’t need to stick with everything there - some things are badly designed in facter as I described above. E.g. uptime is reported incorrectly, we can fix that in the CFM easily.

https://tickets.puppetlabs.com/browse/FACT-2554 looks very similar. Looks like an issue in Fedora’s facter packages.