Created
September 25, 2023 20:43
-
-
Save mkanoor/2782410ed2872ac1b321bda2edac5aef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # yaml-language-server: $schema=https://raw.githubusercontent.com/mkanoor/ansible-rulebook/condition_ast/ansible_rulebook/schema/ruleset_schema.json | |
| - hosts: localhost | |
| name: demo | |
| sources: | |
| - ansible.eda.generic: | |
| payload: | |
| - zebra: false | |
| - i: 3 | |
| - msg: Hello World | |
| - f: 3.14159 | |
| - item: 20 | |
| - missing_item: 200 | |
| - citem: 30 | |
| - ncitem: 300 | |
| - xyz: 300 | |
| - mylist: | |
| - 10 | |
| - 300 | |
| - my_str: Fred Flintstone | |
| - my_other_str: Barney Rubble | |
| - nested: | |
| i: 3 | |
| k: 42 | |
| nested: | |
| m: 65 | |
| g: 74 | |
| - b_or: | |
| x: 1 | |
| y: 34 | |
| - string_expr: "One line condition" | |
| rules: | |
| - name: testrule1 | |
| condition: | |
| all: | |
| - ItemInListExpression: | |
| rhs: | |
| - Integer: 10 | |
| - Integer: 6 | |
| lhs: | |
| Event: i | |
| action: | |
| debug: | |
| msg: This is a test message | |
| - name: stringrule | |
| enabled: true | |
| condition: event.string_expr == "One line condition" | |
| action: | |
| debug: | |
| msg: "Old one line condition" | |
| - name: stringrule2 | |
| enabled: false | |
| condition: | |
| all: | |
| - EqualsExpression: | |
| lhs: | |
| Event: string_expr | |
| rhs: | |
| String: | |
| "One line condition" | |
| action: | |
| debug: | |
| msg: "AST expression works" | |
| - enabled: true | |
| name: r41 | |
| condition: | |
| all: | |
| - AssignmentExpression: | |
| lhs: | |
| Events: varname | |
| rhs: | |
| EqualsExpression: | |
| lhs: | |
| Event: xyz | |
| rhs: | |
| Integer: 300 | |
| - ItemInListExpression: | |
| lhs: | |
| Events: varname | |
| rhs: | |
| Event: mylist | |
| action: | |
| debug: | |
| msg: Assignment works | |
| - enabled: true | |
| name: r51 | |
| condition: | |
| all: | |
| - ListContainsItemExpression: | |
| lhs: | |
| - Integer: 10 | |
| - Integer: 20 | |
| - Integer: 30 | |
| rhs: | |
| Event: citem | |
| action: | |
| debug: | |
| msg: List does not contain an item | |
| - enabled: true | |
| name: r511 | |
| condition: | |
| all: | |
| - IsDefinedExpression: | |
| Event: zebra | |
| action: | |
| debug: | |
| msg: Zebra is defined | |
| - enabled: true | |
| name: r5112 | |
| condition: | |
| all: | |
| - IsNotDefinedExpression: | |
| Event: okapi | |
| action: | |
| debug: | |
| msg: Okapi is not defined | |
| - enabled: true | |
| name: r55 | |
| condition: | |
| all: | |
| - ListNotContainsItemExpression: | |
| lhs: | |
| - Integer: 10 | |
| - Integer: 20 | |
| - Integer: 30 | |
| rhs: | |
| Event: ncitem | |
| action: | |
| debug: | |
| msg: List contains an item | |
| - enabled: true | |
| name: r11 | |
| condition: | |
| all: | |
| - ItemInListExpression: | |
| lhs: | |
| Event: item | |
| rhs: | |
| - Integer: 10 | |
| - Integer: 20 | |
| - Integer: 30 | |
| action: | |
| debug: | |
| msg: Found item in list | |
| - enabled: true | |
| name: r23 | |
| condition: | |
| all: | |
| - ItemNotInListExpression: | |
| lhs: | |
| Event: missing_item | |
| rhs: | |
| - Integer: 10 | |
| - Integer: 20 | |
| - Integer: 30 | |
| action: | |
| debug: | |
| msg: Not Found item in list | |
| - enabled: true | |
| name: r1 | |
| condition: | |
| all: | |
| - EqualsExpression: | |
| lhs: | |
| Event: i | |
| rhs: | |
| Integer: 3 | |
| action: | |
| debug: | |
| msg: Testing for 3 | |
| - enabled: true | |
| name: r2 | |
| condition: | |
| all: | |
| - EqualsExpression: | |
| lhs: | |
| Event: f | |
| rhs: | |
| Float: 3.14159 | |
| action: | |
| debug: | |
| msg: Testing for pi in float | |
| - enabled: true | |
| name: r3 | |
| condition: | |
| all: | |
| - EqualsExpression: | |
| lhs: | |
| Event: msg | |
| rhs: | |
| String: Hello World | |
| action: | |
| debug: | |
| msg: Testing for Hello World | |
| - enabled: true | |
| name: r33 | |
| condition: | |
| all: | |
| - SearchMatchesExpression: | |
| lhs: | |
| Event: my_str | |
| rhs: | |
| SearchType: | |
| kind: | |
| String: search | |
| options: | |
| - name: | |
| String: ignorecase | |
| value: | |
| Boolean: true | |
| - name: | |
| String: multiline | |
| value: | |
| Boolean: true | |
| pattern: | |
| String: Fred | |
| action: | |
| debug: | |
| msg: Search Match works | |
| - enabled: true | |
| name: r334 | |
| condition: | |
| all: | |
| - SearchNotMatchesExpression: | |
| lhs: | |
| Event: my_other_str | |
| rhs: | |
| SearchType: | |
| kind: | |
| String: regex | |
| options: | |
| - name: | |
| String: ignorecase | |
| value: | |
| Boolean: true | |
| - name: | |
| String: multiline | |
| value: | |
| Boolean: true | |
| pattern: | |
| String: Flintstone | |
| action: | |
| debug: | |
| msg: Search Not Match works | |
| - enabled: true | |
| name: r3345 | |
| condition: | |
| all: | |
| - AndExpression: | |
| lhs: | |
| AndExpression: | |
| lhs: | |
| EqualsExpression: | |
| lhs: | |
| Event: nested.nested.m | |
| rhs: | |
| Integer: 65 | |
| rhs: | |
| EqualsExpression: | |
| lhs: | |
| Event: nested.nested.g | |
| rhs: | |
| Integer: 74 | |
| rhs: | |
| EqualsExpression: | |
| lhs: | |
| Event: nested.k | |
| rhs: | |
| Integer: 42 | |
| action: | |
| debug: | |
| msg: And works | |
| - enabled: true | |
| name: r3346 | |
| condition: | |
| all: | |
| - OrExpression: | |
| lhs: | |
| GreaterThanExpression: | |
| lhs: | |
| Event: b_or.x | |
| rhs: | |
| Integer: 10 | |
| rhs: | |
| ItemInListExpression: | |
| rhs: | |
| - Integer: 10 | |
| - Integer: 40 | |
| - Integer: 34 | |
| lhs: | |
| Event: b_or.y | |
| action: | |
| debug: | |
| msg: Or works | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment