Skip to content

Filters

Jake Callahan edited this page Mar 17, 2023 · 2 revisions

Filters

Note: Broker's filters will be radically changing in Broker 0.3

Inventory Filters

Broker's inventory filters are based on what is stored in its local inventory file. Therefore, only properties in that file are filterable. Nested properties are annotated with a . notation. For example, a top-level property hostname can be accessed by itself. However, a nested property of _broker_args called version would be accessed by _broker_args.version.

Results Filters

This type of filter is used against the output of some of Broker's commands where a list of results is passed in. The filter will be matched against each item in the list and only those matching the filter will be returned.

Filter Syntax

Filters take the form "(property)(condition)(value)". Filters have several possible conditions:

  • < means "in" or that the filter value exists within the actual value
  • = means "equals"
  • { means "starts with"
  • } means "ends with"

Furthermore, putting a ! before the condition inverts the filter. So != means "not equals" and !< means "not in".

You can also chain multiple filters together by separating them with a comma. These are additive AND filters where each filter condition must match.

Example filters:

Inventory Filters

--filter 'hostname<test' The string test should exist somewhere in the hostname value --filter '_broker_args.template{deploy-sat' The template should start with the string "deploy-sat" --filter 'name<test,_broker_args.provider!=RHV' The host's name should have "test" in it and the provider should not equal "RHV".

Results Filters

--results-filter 'res<test' Each result in the list must contain the string "test" '--results-filter 'res}example'` Each result in the list must end with the string "example"

Note: Due to shell expansion, it is recommended to wrap a filter in single quotes.

Clone this wiki locally