ansible/event-driven-ansible

Exception: Could not find source plugin for ansible.eda.watchdog

shyam-biradar opened this issue · 3 comments

While running ansible.eda.watchdog event listener, it's throwing following error

[root@localhost local-file-dir-example]# ansible-rulebook -r rulebook.yml -i inventory.yml --verbose
2023-04-07 15:43:19,654 - ansible_rulebook.app - INFO - Starting sources
2023-04-07 15:43:19,654 - ansible_rulebook.app - INFO - Starting rules
2023-04-07 15:43:19,654 - ansible_rulebook.engine - INFO - run_ruleset
2023-04-07 15:43:20,438 - ansible_rulebook.engine - INFO - ruleset define: {"name": "Local Test Runner Rules", "hosts": ["all"], "sources": [{"EventSource": {"name": "watchdog", "source_name": "ansible.eda.watchdog", "source_args": {"path": "/opt/test", "recursive": true, "ignore_regexes": [".*\\.pytest.*", ".*__pycache__.*", ".*/.git.*"]}, "source_filters": []}}], "rules": [{"Rule": {"name": "Directory change condition", "condition": {"AllCondition": [{"EqualsExpression": {"lhs": {"Event": "type"}, "rhs": {"String": "DirModifiedEvent"}}}]}, "actions": [{"Action": {"action": "run_playbook", "action_args": {"name": "playbook.yml"}}}], "enabled": true}}, {"Rule": {"name": "File change condition", "condition": {"AllCondition": [{"EqualsExpression": {"lhs": {"Event": "type"}, "rhs": {"String": "FileModifiedEvent"}}}]}, "actions": [{"Action": {"action": "run_playbook", "action_args": {"name": "playbook.yml"}}}], "enabled": true}}, {"Rule": {"name": "print output", "condition": {"AllCondition": [{"IsDefinedExpression": {"Event": "output"}}]}, "actions": [{"Action": {"action": "print_event", "action_args": {"var_root": "output"}}}], "enabled": true}}]}
2023-04-07 15:43:20,457 - ansible_rulebook.engine - INFO - load source
2023-04-07 15:43:21,093 - ansible_rulebook.engine - ERROR - Source error
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/ansible_rulebook/engine.py", line 93, in start_source
    raise Exception(
Exception: Could not find source plugin for ansible.eda.watchdog
2023-04-07 15:43:21,094 - ansible_rulebook.engine - ERROR - Shutting down source: ansible.eda.watchdog error : Could not find source plugin for ansible.eda.watchdog
2023-04-07 15:43:21,095 - ansible_rulebook.engine - INFO - Waiting for all ruleset tasks to end
2023-04-07 15:43:21,095 - ansible_rulebook.rule_set_runner - INFO - Waiting for actions on events from Local Test Runner Rules
2023-04-07 15:43:21,095 - ansible_rulebook.rule_set_runner - INFO - Waiting for events, ruleset: Local Test Runner Rules
2023-04-07 15:43:21,095 - ansible_rulebook.rule_set_runner - INFO - Ruleset: Local Test Runner Rules, received shutdown: Shutdown(message='Shutting down source: ansible.eda.watchdog error : Could not find source plugin for ansible.eda.watchdog', delay=60.0, kind='graceful', source_plugin='ansible.eda.watchdog')
2023-04-07 15:43:21,095 - ansible_rulebook.rule_set_runner - INFO - ruleset: Local Test Runner Rules shutdown no pending work
2023-04-07 15:43:21,095 - ansible_rulebook.rule_set_runner - INFO - Action Plan Task Cancelled for ruleset Local Test Runner Rules
2023-04-07 15:43:21,095 - ansible_rulebook.rule_set_runner - INFO - Cleaning up ruleset Local Test Runner Rules
2023-04-07 15:43:21 097 [drools-async-evaluator-thread] INFO org.drools.ansible.rulebook.integration.api.io.RuleExecutorChannel - Async channel connected
2023-04-07 15:43:21 102 [main] INFO org.drools.ansible.rulebook.integration.api.RulesExecutor - Disposing session with id: 1
2023-04-07 15:43:21,121 - ansible_rulebook.rule_set_runner - INFO - {'asyncResponses': 0,
 'bytesSentOnAsync': 0,
 'end': '2023-04-07T10:13:21.107530673Z',
 'eventsMatched': 0,
 'eventsProcessed': 0,
 'eventsSuppressed': 0,
 'numberOfRules': 3,
 'permanentStorageSize': 0,
 'ruleSetName': 'Local Test Runner Rules',
 'rulesTriggered': 0,
 'sessionId': 1,
 'start': '2023-04-07T10:13:20.434142831Z'}
2023-04-07 15:43:21,121 - ansible_rulebook.engine - INFO - Cancelling all ruleset tasks
2023-04-07 15:43:21,121 - ansible_rulebook.engine - INFO - Waiting on gather
2023-04-07 15:43:21,121 - ansible_rulebook.engine - INFO - Returning from run_rulesets
2023-04-07 15:43:21,121 - ansible_rulebook.app - INFO - Cancelling event source tasks
2023-04-07 15:43:21,124 - ansible_rulebook.app - ERROR - Could not find source plugin for ansible.eda.watchdog
2023-04-07 15:43:21,124 - ansible_rulebook.app - INFO - Main complete
2023-04-07 15:43:21,126 - ansible_rulebook.cli - ERROR - Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/ansible_rulebook/cli.py", line 196, in main
    asyncio.run(app.run(args))
  File "/usr/lib64/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib64/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.9/site-packages/ansible_rulebook/app.py", line 122, in run
    raise Exception("One of the source plugins failed")
Exception: One of the source plugins failed

My rulebook.yaml

---
- name: Local Test Runner Rules
  hosts: all
  sources:
    - name: watchdog
      ansible.eda.watchdog:
        path: "/opt/test"
        recursive: true
        ignore_regexes: ['.*\.pytest.*', '.*__pycache__.*', '.*/.git.*']
  rules:
    - name: Directory change condition
      condition: event.type == "DirModifiedEvent"
      action:
        run_playbook:
          name: playbook.yml
    - name: File change condition
      condition: event.type == "FileModifiedEvent"
      action:
        run_playbook:
          name: playbook.yml
    - name: print output
      condition: event.output is defined
      action:
        print_event:
          var_root: output

Hi,

I am new to even driven ansible. So, most probably I am making some mistake.
webhook plugin is working fine. watchdog plugin is having this issue.

Do we need to explicitly install the plugin? Is it a known issue?

Thanks,
Shyam

Hi Shyam Biradar,

you have exception
Could not find source plugin for ansible.eda.watchdog

most likely you have newer version of ansible.eda, try using ansible.eda.file_watch instead of ansible.eda.watchdog

Best wishes,
Milan

Hi @dimitrijevicm It worked. Thank You.