ansible / ansible-rulebook

Apache License 2.0
194 stars 77 forks source link

got `Expected end of text, found '('` when trying out example snippet from doc #495

Open tarilabs opened 1 year ago

tarilabs commented 1 year ago

Please confirm the following

Bug Summary

I'm trying a variation of this snippet example from the doc:

https://github.com/ansible/ansible-rulebook/blob/34d60eb61aa78b41ca2fc20f1174089399896fde/docs/conditions.rst?plain=1#L246-L253

Accounting for https://github.com/ansible/ansible-rulebook/pull/493 Using webhook instead of generic source (see also https://github.com/ansible/ansible-rulebook/issues/494)

So the example I'm trying in full reads as:

---
- name: Delayed comparison
  hosts: all
  sources:
    - ansible.eda.webhook:
        host: 0.0.0.0
        port: 5050 # use 5050 as on Mac OSX the 5000 is already reserved by default OS
  rules:
    - name: r1
      condition:
        all:
          - event.request.type == "Delete"
          - event.friend_list.names is select("search",  events.m_0.request.friend_name)
      action:
        print_event:
          pretty: true

but I get

ansible_rulebook.exception.ConditionParsingException: Error parsing: event.friend_list.names is select("search",  events.m_0.request.friend_name). Expected end of text, found '('  (at char 33), (line:1, col:34)

Environment

$ ansible-rulebook --version
__version__ = '0.11.0'

Steps to reproduce

  1. assume the example is in a file named example.yml
  2. run with ansible-rulebook --rulebook example.yml --verbose

Actual results

ansible_rulebook.exception.ConditionParsingException: Error parsing: event.friend_list.names is select("search",  events.m_0.request.friend_name). Expected end of text, found '('  (at char 33), (line:1, col:34)

Expected results

not an error 🙃 since it's copied from the docs

Additional information

I'm possibly doing something wrong, hope these details help to ultimately triage if there is some bugs or it's my fault (in that case sorry I raised this)

Alex-Izquierdo commented 1 year ago

Can you try with the latest version v.0.13.0, v0.11.0 does't support it.