Search boolean fields

Is there a specific method for searching boolean params?

string search like so work fine…
hammer --no-headers host list --fields=‘name,operating system’ --search ‘params.itar = yes’

when i try to search on boolean fields I don’t get any response…
hammer --no-headers host list --fields=‘name,operating system’ --search ‘params.p1_severity = false’

Am i missing something?

1 Like

Hi, can someone on the Foreman team chime in on this? This seems like a really simple thing, but for the life of me I can’t figure out what the correct syntax is for searching based off of boolean parameters.

If I search on the “Hosts” page for params.chrony_server = t, it correctly pulls up all of my hosts with the boolean parameter “chrony_server” set to true. However, if I search for params.chrony_server = f, the search results in every host listed including the hosts with “chrony_server” set to true. What is the correct way to search for hosts with a parameter set to false?

Also, before it gets asked, I’ve tried searching for params.chrony_server != t and that also lists every host.

I have just tested with foreman 3.4/katello 4.6.

Added a new host parameter to one host: name “org_test”, type “boolean”, value “true”.

Then on the all hosts page ( I have enter params.org_test = t and it finds exactly this one host. If I enter params.org_test = f it find no hosts.

If I change the value on the host from “true” to “false”. The search params.org_test = t returns no hosts and params.org_test = f returns the host.

Even != works as expected. Only not params.org_test = t returns all hosts with no host parameter value set and hosts if org_test = f.

So it seem to work for me.

Thanks, @gvde . Can you try one more thing for me? Can you try setting that parameter to “true” on a hostgroup and the same parameter to “false” on another hostgroup (with a different host assigned to each hostgroup) and report if your results are the same?

HostgroupA => params.org_test = t
 -> HostA
HostgroupB => params.org_test = f
 -> HostB

Oh, and I should have mentioned. Would you also remove the parameters from the hosts themselves (so they’re only set on the hostgroups)?