Problem:
I am trying to retrieve all the facts about a specific host via API. But for some reason for some values I just get null, e.g.
"mountpoints::/run": null,
"os::distro": null,
"ssh::ecdsa::fingerprints": null,
"os::selinux": null,
"mountpoints": null,
"load_averages": null,
"os": null,
"networking": null,
This is the case with all hosts. Most facts have the correct values, some have null.
Expected outcome:
Get values for these facts which are not null. What baffles me even more is that in the web interface I have no problem looking up the values for the above facts.
Foreman and Proxy versions:
Foreman version: 1.22
Proxy version: 1.22
Logs:
2019-06-26T10:00:31 [I|app|46841221] Started GET "/api/v2/hosts/$HOST/facts" for $IP at 2019-06-26 10:00:31 +0200
2019-06-26T10:00:31 [I|app|46841221] Processing by Api::V2::FactValuesController#index as JSON
2019-06-26T10:00:31 [I|app|46841221] Parameters: {"apiv"=>"v2", "host_id"=>"$HOST"}
2019-06-26T10:00:31 [I|app|46841221] Authorized user admin(Admin User)
2019-06-26T10:00:31 [I|app|46841221] Current user set to admin (admin)
2019-06-26T10:00:31 [I|app|46841221] Rendering api/v2/fact_values/index.json.rabl within api/v2/layouts/index_layout
2019-06-26T10:00:31 [I|app|46841221] Rendered api/v2/fact_values/index.json.rabl within api/v2/layouts/index_layout (1.0ms)
2019-06-26T10:00:31 [I|app|46841221] Completed 200 OK in 60ms (Views: 5.8ms | ActiveRecord: 9.9ms)
I just discovered the same problem, for me the reason was the ‘per_page’ attribute which defaults to 100 which is not enough to collect all my facts. If I increase the ‘per_page’ parameter it works.
Example with curl:
curl -u myuser "https://foreman.example.com/api/hosts/host.example.com/facts?per_page=1000"
This actually solved my problem, thank you very much, sir!
But I still have some keys which have no values, namely those right here:
partitions null
ssh::ed25519::fingerprints null
ruby null
processors null
mountpoints::/run/lock null
mountpoints::/sys/fs/cgroup null
partitions::/dev/sda1 null
os::selinux null
os::release null
os::distro::release null
os::distro null
os null
networking::interfaces null
networking::interfaces::ens192 null
networking null
augeas null
disks::sda null
disks null
disks::sr0 null
dmi::bios null
dmi null
dmi::board null
dmi::chassis null
dmi::product null
hypervisors::vmware null
hypervisors null
identity null
load_averages null
memory::swap null
memory null
memory::system null
mountpoints::/ null
mountpoints null
mountpoints::/dev/shm null
mountpoints::/run null
system_uptime null
ssh::rsa null
ssh::rsa::fingerprints null
ssh null
ssh::ed25519 null
Can you confirm that on your system?
Aren’t those hash keys in a structured fact?
For example:
os:
|->family: ‘RedHat’
|->architecture: ‘x86_64’
So ‘os’ is the key and has no value, and the Foreman API then returns ‘null’. But you should have values for ‘os::family’
Yes, this is exactly what I mean.