Closed mooky31 closed 3 months ago
@mooky31 ansible playbook filters are not supported in ansible-rulebook. There is support for builtin in Jinja filters. e.g.
- name: Replace Jinja filter
hosts: all
sources:
- ansible.eda.generic:
payload:
- msg: hello_world
rules:
- name: Say Hello
condition: true
action:
debug:
msg: "This is a replace example {{ event.msg|replace('_','-') }}"
Or the other option to do is use the filter in the playbook vars section. All the event data would be passed into the playbook under ansible_eda. as extra vars and there you can apply the ansible playbook filters. Example (https://github.com/ansible/ansible-rulebook/blob/857ce658cae1b6dea4e05e87f384907c5b793793/tests/e2e/files/playbooks/print_event.yml#L7)
Ok thanks I understand I'll figure out something. Are there any plan to support them ?
Hi @mooky31 There are no official plans to include it at this time. You can open a feature request. If we see traction we may consider it as a higher priority.
I close this issue since it is not a bug.
Please confirm the following
Bug Summary
When I try to manipulate some data I want to sent to the playbook in extra_vars using ansible builtin filters, it fails
Environment
Centos stream 9
Steps to reproduce
$ ansible-rulebook --rulebook rule-test.yml -i inventory.yaml
$ curl -k --header "Content-Type: application/json" --data '{ "hostname": "ABC_Hostname" }' http://localhost:8081
Actual results
2024-06-05 18:02:09,481 - ansible_rulebook.rule_set_runner - ERROR - Error calling action run_playbook, err No filter named 'ansible.builtin.regex_replace'.
Expected results
Playbook starting with
testfilter1: Hostname
in extra_varsAdditional information
No response