Created
January 24, 2023 14:32
-
-
Save mkanoor/e925f34687f39c97dab92f72fa5e6491 to your computer and use it in GitHub Desktop.
Using vars in a rulebook similar to playbook
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
| --- | |
| - name: Vars in rulebook | |
| hosts: all | |
| vars: | |
| person: | |
| age: 45 | |
| name: Fred Flintstone | |
| active: true | |
| reliability: 86.9 | |
| address: | |
| street: 123 Any Street | |
| city: Bedrock | |
| state: NJ | |
| years_active: | |
| - 2001 | |
| - 2002 | |
| - 2003 | |
| - 2004 | |
| sources: | |
| - generic: | |
| payload: | |
| - name: Fred Flintstone | |
| address: | |
| street: 123 Any Street | |
| city: Bedrock | |
| state: NJ | |
| - year: 2003 | |
| - active: true | |
| - threshold: 34.56 | |
| - age: 45 | |
| rules: | |
| - name: str_test | |
| condition: event.address.street == vars.person.address.street | |
| action: | |
| echo: | |
| message: String comparison works | |
| - name: list_test | |
| condition: event.year in vars.person.address.years_active | |
| action: | |
| echo: | |
| message: List in works | |
| - name: bool_test | |
| condition: event.active == vars.person.active | |
| action: | |
| echo: | |
| message: Boolean works | |
| - name: int_test | |
| condition: event.age == vars.person.age | |
| action: | |
| echo: | |
| message: Int works | |
| - name: float_test | |
| condition: event.threshold < vars.person.reliability | |
| action: | |
| echo: | |
| message: Float works |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment