Logical¶
Summary
Combines other conditions with and, or and not. They can be nested as deeply as needed.
Example¶
rules:
# Match in December or January, but not on weekends, while VLC is running
- name: "Winter weekday with VLC"
conditions:
and:
- or: #(1)!
- datetime:
month:
- "December"
- datetime:
month:
- "January"
- not:
datetime:
weekday:
- "Saturday"
- "Sunday"
- process:
name: "vlc" #(2)!
exists: true
actions:
- run: "echo Winter weekday with VLC"
-
Using
orlike this is a more elaborate way of writing:but you get the idea.
-
Consider using
containsorregexmatching for different platforms.
Options¶
| Option | Takes | Matches when |
|---|---|---|
and |
list of at least two conditions | all conditions match. |
or |
list of at least two conditions | at least one condition matches. |
not |
exactly one condition | the condition does not match. |
Details¶
- A condition defines exactly one of
and,or,notor a single condition type. andandorevaluate their conditions in order and stop at the first decisive result. In other words, if anandcondition finds a non-matching condition, it stops and returnsfalse. If anorcondition finds a matching condition, it stops and returnstrue.notonly negates the result. If the inner condition cannot be evaluated, the evaluation still stops.
Related¶
-
Continuous evaluation and
--dry-run. -
Run commands when a rule matches.
-
Detect modifications of policies and scripts.