Search empty/null fields custom facts

hi all

I need to know how I can search for null values or empty fields…

Like example "myproject_version ", I tried the commands "facts.myproject_version != “”
" and “not has facts.smartdesk_version” but doesn’t work.

Anyone can help me?

Foreman uses scoped_search for searching. The query language is described here.

null? facts.smartdesk_version sounds like the thing you’re looking for

1 Like

thanks for your answer @aruzicka its also possible it the variable is empty?

Is what possible? Use null? to check for empty strings? No, an empty string is still a value so if you want to filter out values which are either null or empty string, you will have to combine them together.

1 Like

that was the key :slight_smile:
thank you @aruzicka

I try this:

facts.myproject_version != “” or facts.myproject_version != null but it doesnt work!

That’s not really what I suggested, is it? If you want “all hosts which have myproject_version fact set to a non-empty value”, then something like this could work.

set? facts.myproject_version and facts.myproject_version != ""