I have a puppet fact which returns a puppet structured fact: cs_addevicegroups => ["GSD-ALL-00-OB_GBL_Provisioning", "GSD_test"] However is satellite this is a concatenated string: (call to https://usl10149341.am.hedani.net/api/v2/hosts/15) "facts" : { <--snip--> "cs_addevicegroups": "GSD-ALL-00-OB_GBL_ProvisioningGSD_test" } I also see this behavior for puppet standard facts (processors and system_uptime for example): processors => {"models"=>["Intel(R) Xeon(R) CPU E5-2697 v2 @ 2.70GHz"], "physicalcount"=>1, "count"=>1} system_uptime => {"days"=>33, "uptime"=>"33 days", "hours"=>805, "seconds"=>2900888} "facts" : { <--snip--> "processors": "count1modelsIntel(R) Xeon(R) CPU E5-2697 v2 @ 2.70GHzphysicalcount1", "system_uptime": "seconds2900497hours805days33uptime33 days" } I'd expect to be able to: a) search within a structured fact (?search=facts.structured_fact_name = GSD_test does not return any entries. ?search=facts.structured_fact_name ~ GSD_test works BUT would capture GSD_test_hosts etc. Too fuzzy. ?search=facts.structured_fact_name ^ GSD_test fails completely (probably unsurprising!) b) view the fact via the api in its original structure (I'd expect to do <value>.class or <value>.is_a?(Hash) etc)
Thanks for the report Karl, I don't see any private information in the BZ, could you please publish it? The support for structured facts was merged upstream in Foreman 1.13. I'm not sure I understand part b), our API responds in JSON format, how would you call #class or #is_a?(Hash) on it?
I'll defer to Andrew Schofield on that question as he is the one who filed the issue with us. Cheers, Karl
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/4528 has been resolved.
(In reply to Marek Hulan from comment #2) > Thanks for the report Karl, I don't see any private information in the BZ, > could you please publish it? The support for structured facts was merged > upstream in Foreman 1.13. I'm not sure I understand part b), our API > responds in JSON format, how would you call #class or #is_a?(Hash) on it? Marek - with regards to (b) I'm asking that, using the API, I can run something like JSON.parse converting into ruby objects then call to identify the format of the fact from there. So long as the original value of the structured fact is being returned via the API.
Thanks for explanation. That's currently not possible, we only list facts as key value combination and constructing of all composed values might be performance issue for multiple facts. Maybe we could add this if users asks for specific fact only, in other words add a show action for signle fact, if you're interested, please open a separate RFE for this. Today you could write a simple script that combines facts loaded through API and constructs the composite value for you. This class might be useful - https://github.com/theforeman/foreman_chef/blob/d460134c221ccb7cd38c2df6eafcaade7457fdf2/app/models/foreman_chef/fact_importer.rb#L110-L129 With class like it you'd just load all facts into a hash and then call something like this: Sparser.new.unsparse({'a::b::c' => 'x', 'a::b::d' => 'y'}, :separator => '::') This results in {"a"=>{"b"=>{"c"=>"x", "d"=>"y"}}}
Build: Satellite 6.3 snap 17 /api/fact_values?search=name+%3D+partitions Returned structured facts "results": {"nikb39237be-87ca-4705-b7b2-500eee158fe5.sat.com":{"partitions":"{\"sda1\"=>{\"uuid\"=>\"41baa60f-8ed1-476f-80b2-138b5a888d21\", \"size\"=>\"2097152\", \"mount\"=>\"/boot\", \"filesystem\"=>\"xfs\"}, \"sda2\"=>{\"size\"=>\"39843840\", \"filesystem\"=>\"LVM2_member\"}}"},"nika7da3a2c-842a-4528-b16c-9a3b1a6ed4c5.sat.com":{"partitions":"{\"sda1\"=>{\"uuid\"=>\"c4effd3e-74cf-4d57-94ed-74df5b8b7b9d\", \"size\"=>\"2097152\", \"mount\"=>\"/boot\", \"filesystem\"=>\"xfs\"}, \"sda2\"=>{\"size\"=>\"39843840\", \"filesystem\"=>\"LVM2_member\"}}"},"nik8fe0d0c1-4350-42ef-ade4-592a02db25d1.sat.com":{"partitions":"{\"sda1\"=>{\"uuid\"=>\"ed7d5292-52ef-4739-aad5-e643cfa0f689\", \"size\"=>\"2097152\", \"mount\"=>\"/boot\", \"filesystem\"=>\"xfs\"}, \"sda2\"=>{\"size\"=>\"39843840\", \"filesystem\"=>\"LVM2_member\"}}"},"nik5d814a9e-7b49-47f5-be7c-ecedc4cbb22f.sat.com":{"partitions":"{\"sda1\"=>{\"uuid\"=>\"f6c7f405-f1bd-432c-bfca-6e6efa2e30da\", \"size\"=>\"2097152\", \"mount\"=>\"/boot\", \"filesystem\"=>\"xfs\"}, \"sda2\"=>{\"size\"=>\"39843840\", \"filesystem\"=>\"LVM2_member\"}}"},"todd-lolar.sat.com":{"partitions":"{\"vda1\"=>{\"uuid\"=>\"17eb29dd-a0c5-43f5-856c-c0d48d8734bd\", \"size\"=>\"2097152\", \"mount\"=>\"/boot\", \"filesystem\"=>\"xfs\"}, \"vda2\"=>{\"size\"=>\"18872320\", \"filesystem\"=>\"LVM2_member\"}}"}} } Also, UI , lists the structured facts in correct format. However I ran into issue while searching in structured facts with IN operator Tracking here https://bugzilla.redhat.com/show_bug.cgi?id=1496322
Created attachment 1331293 [details] UI struct facts
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2018:0336