Using filters to control discovery and addressing is a key concept in mcollective. You can use facts, classes, agents and server identities in filters and combine to narrow down what hosts you will affect.
To determine if your client support filters use the –help option:
If you see a section as above then the client supports filters, this is the default for all clients using SimpleRPC.
All filters support Regular Expressions and some support comparisons like greater than or less than.
Filters are applied in a combined manner, if you supply 5 filters they must all match your nodes.
Filtering on facts require that you’ve correctly set up a FactPlugin. The examples below show common fact filters.
Install the ZSH package on machines with the fact country=de:
Install the ZSH package on machines where the country fact starts with the letter d:
Install the ZSH package on machines with more than 2 CPUs, other available operators include ==, <=, >=, <, >, !=. For facts where the comparison and the actual fact is numeric it will do a numerical comparison else it wil do alphabetical:
Note that filtering on structured facts such as
os.family requires the use of
These filters all work on the same basic pattern, they just support equality or regular expressions:
Install ZSH on machines with hostnames starting with web:
Install ZSH on machines with hostnames web1.example.com:
As a short-hand you can combine Fact and Class filters into a single filter:
Install ZSH on machines in Germany that has classes matching /apache/: