Resource collectors select a group of resources by searching the attributes of each resource in the catalog, even resources which haven’t yet been declared at the time the collector is written. Collectors realize virtual resources, are used in chaining statements, and override resource attributes. Collectors have an irregular syntax that enables them to function as a statement and a value.

A capitalized resource type name. This cannot be Class, and there is no way to collect classes.

<|- An opening angle bracket (less-than sign) and pipe character.

Optionally, a search expression.

|> - A pipe character and closing angle bracket (greater-than sign)

Note: Exported resource collectors have a slightly different syntax; see below.

Using a special expression syntax, collectors search the values of resource titles and attributes. This resembles the normal syntax for Puppet expressions, but is not the same.

Note: Collectors can search only on attributes that are present in the manifests, and cannot read the state of the target system. For example, the collector Package <| provider == yum |> collects only packages whose provider attribute is explicitly set to yum in the manifests. It does not match packages that would default to the yum provider based on the state of the target system.

A collector with an empty search expression matches every resource of the specified resource type.

Use parentheses to improve readability, and to modify the priority and grouping of and and or operators. You can create complex expressions using four operators.

== (equality search)

This operator is non-symmetric:

The left operand (attribute) must be the name of a resource attribute or the word title (which searches on the resource’s title).

Behavior

Note: A collector also collects and realizes any exported resources from the current node. When you use exported resources that you don’t want realized, exclude them from the collector’s search expression.

Collectors function as a value in two places:

In a chaining statement, a collector acts as a proxy for every resource (virtual or not) that matches its search expression.

When given a block of attributes and values, a collector sets and overrides those attributes for every resource (virtual or not) matching its search expression.

Note: Collectors used as values also realize any matching virtual resources. When you use virtualized resources, be careful when chaining collectors or using them for overrides.

Exported resource collectors

An exported resource collector uses a modified syntax that realizes exported resources and imports resources published by other nodes.