Node filters
A node filter is a search expression used to identify a set of nodes using SQL-like expressions on any namespace and attribute. You can create node filters that include or exclude nodes based on specific pattern sets.
When the filter is evaluated, Chef Courier creates a node list from the set of registered nodes at the time that the filter is evaluated.
Create a node filter
Create a node filter payload in a JSON file:
{ "name": "<FILTER_NAME>", "constraints": { "attributes": [{ "name": "<ATTRIBUTE_NAME>", "operator": "<OPERATOR>", "value": ["<ATTRIBUTE_VALUE>"], "namespace": ["<NAMESPACE_NAME>"] }] } }Replace:
<FILTER_NAME>with a name for the filter<ATTRIBUTE_NAME>with an attribute to filter by<OPERATOR>with an filter operator. The supported operators are:MATCHESCONTAINS=!=
<ATTRIBUTE_VALUE>with the attribute value filter operator matches against<NAMESPACE_NAME>with the namespace to search in. The following namespaces are supported:agentfor node attributes collected from the Node Management Agentgohaifor node attributes collected by the Gohai skillawsfor AWS-specific attributes collected by the Gohai skillazurefor Azure-specific attributes collected by the Gohai skilltagsfor tags applied to nodes using Node Management
Create and save a node filter:
chef-node-management-cli management filter create-filter --body-file <FILTER_FILENAME>The response is similar to the following:
{ "item": { "filterId": "ab38aed7-f35a-4e44-90f5-ef9ea11e6464" } }
Get nodes from a filter
To get nodes from an adhoc filter, use the filter run-adhocFilter subcommand:
chef-node-management-cli management filter run-adhocFilter --body-file <FILTER_FILENAME>
To get nodes from a saved filter, use the filter run-savedFilter subcommand:
chef-node-management-cli management filter run-savedFilter --filterId <FILTER_ID>