Skip to content

fact didn't match any rule and has been immediately discarded #837

@wuhaohust

Description

@wuhaohust

I am new to ansible-rulebook, I am trying to use it to collect some info when zabbix alert triggered . I installed below version on SUSE15

ansible-rulebook [1.1.7]
Executable location = /usr/local/bin/ansible-rulebook
Drools_jpy version = 0.3.10
Java home = /usr/lib64/jvm/java-17-openjdk-17
Java version = 17.0.16
Ansible core version = 2.19.1
Python version = 3.11.13
Python executable = /usr/bin/python3.11
Platform = Linux-5.14.21-150500.55.116-default-x86_64-with-glibc2.31

I create a simple rule file with below content:

  • name: Debug Incoming Events
    hosts: all
    sources:

    • ansible.eda.webhook:
      host: 0.0.0.0
      port: 5000

    rules:

    • name: get the top5 CPU processes
      condition: event.payload.event_name is defined
      actions:
      • set_fact:
        fact:
        target_host: "test-server"
        incident_ref: "4560"

      • debug:
        msg: "{{ target_host }}"

      • run_playbook:
        name: top5_cpu_linux.yml
        extra_vars:
        host: "{{ event.target_host }}"

but it always prompt target_host is not defined , and from the log I can see

2025-09-26 21:19:12,282 - ansible_rulebook.rule_generator - DEBUG - callback calling get the top5 CPU processes
2025-09-26 21:19:12,282 - ansible_rulebook.rule_set_runner - DEBUG - None
2025-09-26 21:19:12,283 - ansible_rulebook.rule_set_runner - DEBUG - Creating action task action::set_fact::Debug Incoming Events::get the top5 CPU processes
2025-09-26 21:19:12,283 - ansible_rulebook.rule_set_runner - DEBUG - call_action set_fact
2025-09-26 21:19:12,283 - ansible_rulebook.action.set_fact - DEBUG - set_fact: ruleset=Debug Incoming Events, fact={'target_host': 'dp-ansib-p-v', 'incident_ref': '4560'}
2025-09-26 21:19:12 285 [main] DEBUG org.drools.ansible.rulebook.integration.api.rulesengine.AbstractRulesEvaluator - Fact {"target_host":"test-server1","incident_ref":"4560","meta":{"source":{"name":"set_fact","type":"internal"},"received_at":"2025-09-26T13:19:12.283370Z","uuid":"fde8e901-de3b-411d-af38-4c8bc2ebb7ce"}} didn't match any rule and has been immediately discarded
2025-09-26 21:19:12,285 - ansible_rulebook.rule_set_runner - DEBUG - Task action::set_fact::Debug Incoming Events::get the top5 CPU processes finished, active actions 1
2025-09-26 21:19:12,286 - ansible_rulebook.rule_set_runner - DEBUG - Creating action task action::debug::Debug Incoming Events::get the top5 CPU processes
2025-09-26 21:19:12,286 - ansible_rulebook.rule_set_runner - DEBUG - call_action debug
2025-09-26 21:19:12,288 - ansible_rulebook.rule_set_runner - DEBUG - Task action::debug::Debug Incoming Events::get the top5 CPU processes finished, active actions 1
2025-09-26 21:19:12,288 - ansible_rulebook.rule_set_runner - DEBUG - Task Task-11 finished, active actions 0
2025-09-26 21:19:12,288 - ansible_rulebook.rule_set_runner - ERROR - 'facts' is undefined

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions