Writing node group rules

To create a dynamic node group rule, you must specify a Fact, Operator, and Value.

These three fields are required to Dynamically add nodes to a node group.

The Fact field specifies the fact you want to the rule to use. You can select from the dropdown list of known facts, enter part of a string to filter the list, or use structured or trusted facts. For structured and trusted facts, select the initial value from the dropdown list, then type the rest of the fact:

  • To descend into a hash, use periods (.) to designate path segments, such as os.release.major or trusted.certname.
  • To specify an item in an array, put square brackets around the item's numerical index, such as processors.models[0] or mountpoints./.options[0].
  • To identify path segments that have periods, dashes, spaces, or UTF characters, put single or double quotes around the segment, such as trusted.extensions."1.3.6.1.4.1.34380.1.2.1".
  • To use trusted.extensions short names, append the short name after a second period, such as trusted.extensions.pp_role.
When you enter structured and trusted facts, PE doesn't provide suggestions as you type (except for the top-level name key), nor does it verify that the facts exist. After you add a rule that uses a structured or trusted fact, check the number of Node matches to verify that the fact is generating matches and was entered correctly.

The Operator field describes the relationship between the Fact and the Value. It defines how the rule uses the fact (inclusively, exclusively, exactly, minimum, maximum, and so on).

The following table shows the operator symbols together with their respective meanings and the data types they can relate to.

Operator Meaning Supported data types
= Is equal to string, numeric, Boolean
!= Is not equal to string, numeric, Boolean
~ Matches regular expression in string
!~ Does not match regular expression in string
> Is greater than numeric
>= Is greater than or equal to numeric
< Is less than numeric
<= Is less than or equal to numeric
<: Array contains string, numeric, Boolean
/: Array does not contain string, numeric, Boolean

The >, >=, <, and <= operators require facts that have numeric values, such as dates, times, or version numbers.

The ~ and !~ operators require a regular expression (regex) Value and are useful for matching highly-specific node facts (for example, you want to find nodes with UUIDs starting with 9999*).

The <: and /: operators require facts with array values.

The Value field describes the relevant Fact value. Depending on the Fact and Operator, the Value can be a string, number, or regular expression.

Together these fields create a logical rule that PE uses to find matching nodes. If you have multiple dynamic rules for one node group, you can choose whether Nodes must match all rules or if Nodes may match any rule to be added to the group.