Project

General

Profile

Actions

Feature #4528

closed

Support Facter 2 structured facts

Added by Greg Sutcliffe about 10 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Facts
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Facter 2 is at RC1, and while it has no structered facts by default, it will have in the future, and people will start writing their own probably even sooner.

I quickly looked into this using the foreman_chef plugin. I came up with this:

1. Add 'plainify' and 'get_key' to node.rb from chef_foreman_handler, and change 'build_body' to call:

{'facts' => plainify(puppet_facts['values'].merge({:_type => 'foreman_chef'})).flatten.inject(&:merge), 'name' => hostname, 'certname' => certname}

2. Add foreman_chef plugin to Foreman
3. Fix https://github.com/theforeman/foreman/blob/develop/app/services/fact_importer.rb#L79 to not drop Integers
4. (optional) Handle changes of fact type. Currently if you upload "foo: bar" and then upload "foo: { "bar" => "quux" }" it won't display properly due to the old string-type fact in the db.

We'll probably want to move the hash-handling code out of foreman_chef and into core. I'd also consider investigating the way we compress and uncompress the facts hash with '::' vs just sending/parsing the whole hash directly.


Related issues 10 (2 open8 closed)

Related to Foreman - Feature #2293: Support structured factsDuplicate03/08/2013Actions
Related to Foreman - Feature #3339: Support for nested facts and specialised pluginsClosedMarek Hulán10/17/2013Actions
Related to Foreman - Feature #7525: Report volume sizes via facterClosedLukas Zapletal09/18/2014Actions
Related to Discovery - Feature #3860: Implement fully automated provisioningClosedLukas Zapletal12/12/2013Actions
Related to Foreman - Tracker #8447: Puppet 4 supportClosed11/19/2014

Actions
Related to Foreman - Feature #15522: Support for array/multi-valued factsNew06/27/2016Actions
Related to Salt - Refactor #15591: Use new structured facts parserNew07/06/2016Actions
Related to Foreman - Bug #16576: Structured facts importer is extremely slowClosedDominic Cleal09/15/2016Actions
Has duplicate Foreman - Bug #6414: structured facts not displayed in foremanDuplicate06/27/2014Actions
Has duplicate Foreman - Feature #12703: Layout aggregated fact value display formatDuplicate12/04/2015Actions
Actions #1

Updated by Dominic Cleal about 10 years ago

  • Subject changed from Support structured facts to Support Facter 2 structured facts
Actions #2

Updated by Dominic Cleal about 10 years ago

Actions #3

Updated by Dominic Cleal about 10 years ago

  • Related to Feature #3339: Support for nested facts and specialised plugins added
Actions #4

Updated by Greg Sutcliffe about 10 years ago

  • Description updated (diff)
Actions #5

Updated by Dominic Cleal over 9 years ago

  • Has duplicate Bug #6414: structured facts not displayed in foreman added
Actions #6

Updated by Stephen Benjamin over 9 years ago

ForemanChef's code "just works" for Salt's structured facts as well (after plainifying). It would be awesome to have a nested fact importer in Core that could just take the hash.

Actions #7

Updated by Marek Hulán over 9 years ago

Let's merge it into core :-) Note that facts should still be scoped by name so we should add ForemanSalt::FactImporter inheriting from ForemanChef::FactImporter or ideally extract the generic part to some new NestedFactImporter class and let inherit both from it. Important methods that would remain importer specific: fact_name_class and support_background. Importer from ForemanChef is also lacking tests at the moment so it should be covered first.

Actions #8

Updated by Stephen Benjamin over 9 years ago

  • Bugzilla link set to 1132402
Actions #9

Updated by Lukas Zapletal over 9 years ago

Actions #10

Updated by Lukas Zapletal over 9 years ago

Guys I need to get some integers in (discovery, hard disk volume sizes), can I post a patch to simply convert the number to string? See the referenced issue.

Actions #11

Updated by Lukas Zapletal over 9 years ago

For the record, I filed a PR to convert non-string values to strings so it prevents from failure. We might want to do something smarter than this in this ticket, but since Staypuft is blocked by this I propose this solution: https://github.com/theforeman/foreman_discovery/pull/90

Actions #12

Updated by Lukas Zapletal over 9 years ago

  • Related to Feature #3860: Implement fully automated provisioning added
Actions #13

Updated by Lukas Zapletal over 9 years ago

Bumping up the priority a bit, if this is implemented, our Discovery rule engine is much more powerful.

Actions #14

Updated by Joshua Hoblitt over 9 years ago

I just smacked into this in 1.6.3. Not even string structured facts are queryable via the gui.

Actions #15

Updated by Jeff Sparrow almost 9 years ago

This has been open for sometime and puppet has really pushed to using structured data facts more often, within their future parser it makes things much easier. Hope this is included very soon as hashes and arrays are fairly common and should be supported

Actions #16

Updated by Sven Milinski over 8 years ago

Hello,

can anyone tell me when Foreman is able to manage facter 2 array/hash values ?
Is it on the roadmap ?

Would be nice if someone can update this issue

Thanks

Actions #17

Updated by Jeff Sparrow over 8 years ago

Any update? Not having structured facts in foreman is getting to be a big hassle to get around. Would be nice to get an update, its been almost a year. Thanks.

Actions #18

Updated by Dominic Cleal over 8 years ago

  • Has duplicate Feature #12703: Layout aggregated fact value display format added
Actions #19

Updated by Anonymous about 8 years ago

Actions #20

Updated by Maxim Burgerhout almost 8 years ago

Doesn't the foreman_ansible implementation by @dLobatog have nice structured facts already? It might be possible to use that same code?

Actions #21

Updated by Daniel Lobato Garcia almost 8 years ago

Yup - it's also partly taken from Salt so hopefully we can provide this from core to all plugins.

Actions #22

Updated by Dominic Cleal over 7 years ago

  • Status changed from New to Assigned
  • Assignee set to Dominic Cleal
Actions #23

Updated by Dominic Cleal over 7 years ago

  • Related to Feature #15522: Support for array/multi-valued facts added
Actions #24

Updated by Dominic Cleal over 7 years ago

Tickets relating to handling of non-structured, non-string facts (ints, bools) which are mentioned above:

  • #7525 changed the importer to handle non-string facts by converting their values to strings, this helps notably with integer facts.
  • #11150 changed fact searching to support integer comparisons, since Foreman stores integers as strings internally.
  • I don't propose changing the storage of non-string facts in Foreman, it's sufficient to store them as strings and convert them when used (e.g. when searching).

Tickets relating to handling of array values:

  • #15522 filed to enable storage of multiple fact values for arrays, instead of storing them as a string (e.g. ["a", "b"])

Tickets relating to handling of structured/nested/hash facts:

  • #3339 added support for structured facts - that is, facts whose value is a hash of more facts
  • This ticket will be used only to update the Puppet fact importer to store structured facts/hashes of facts.
Actions #25

Updated by The Foreman Bot over 7 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3613 added
Actions #26

Updated by Stephen Benjamin over 7 years ago

Actions #27

Updated by Dominic Cleal over 7 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #28

Updated by Dominic Cleal over 7 years ago

  • translation missing: en.field_release set to 160
Actions #29

Updated by Dominic Cleal over 7 years ago

  • Related to Bug #16576: Structured facts importer is extremely slow added
Actions

Also available in: Atom PDF