-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AAP-7562] Added support for searching an array of objects in conditi…
…ons (#325) https://issues.redhat.com/browse/AAP-7562 Using the guidelines from selectattr and select in Ansible and Jinja we can write conditions that would check if the select/selectattr yields one or more objects to pass the condition. The result of the selectattr and select is a boolean value. It can only answer if in the array of objects there is an object that satisfies the condition, the data can be further processed in the playbook if need be. Needs a new version of drools_jpy 0.2.0 This also conforms to the ansible playbook guidelines of tests having either a **is** or **is not** e.g. levels is an array of integers ``` event.levels is select('>', 25) ``` addresses is an array of strings ``` event.addresses is select('regex', 'Main St') ``` addresses is an array of strings ``` event.addresses is not select('regex', 'Wall St') ``` event.people is an array of person objects, where the attribute we are checking is person.age and checking if the age is > 30. ``` event.people is selectattr('person.age', '>', 30) ``` event.people is an array of person objects, where the attribute we are checking is person.name and checking if the name is either Barney or Fred ``` event.people is selectattr('person.name', 'regex', 'Barney|Fred') ```
- Loading branch information
Showing
13 changed files
with
556 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
- name: 61 select 1 | ||
hosts: all | ||
sources: | ||
- generic: | ||
payload: | ||
- name: Fred | ||
age: 54 | ||
levels: | ||
- 10 | ||
- 20 | ||
- 30 | ||
- name: Barney | ||
age: 53 | ||
levels: | ||
- 11 | ||
- 15 | ||
- 16 | ||
- name: Wilma | ||
age: 53 | ||
levels: | ||
- 1 | ||
- 5 | ||
- 6 | ||
rules: | ||
- name: r1 | ||
condition: event.levels is select('>', 25) | ||
action: | ||
echo: | ||
message: Found a player with level greater than 25 |
Oops, something went wrong.