Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source generic is not released in Ansible EDA hence rulebook example fails #494

Open
3 tasks done
tarilabs opened this issue Apr 27, 2023 · 5 comments
Open
3 tasks done

Comments

@tarilabs
Copy link
Contributor

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

This source is mentioned in the doc:

sources:
- generic:
payload:

The generic source (in my understanding formally ansible.eda.generic), is not available in the 1.3.3/(galaxy 1.3.4) from EDA:

https://github.com/ansible/event-driven-ansible/tree/v1.3.3?search=1

but it's only available from main branch: https://github.com/ansible/event-driven-ansible/blob/main/extensions/eda/plugins/event_source/generic.py

which is NOT yet released.

Hence, a user (like me 😅 ) trying out the example from the documentation fails as described below.

Environment

latests of all collections:

ansible.eda       1.3.4

(even if I cannot find it on github 🤔 )

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

Steps to reproduce

  1. copy-paste snippet example from doc
  2. account for fix invalid yaml in doc #493
  3. use simpler condition as condition: event.request is defined

Actual results

2023-04-27 08:29:42,245 - ansible_rulebook.engine - ERROR - Source error
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/ansible_rulebook/engine.py", line 93, in start_source
raise Exception(
Exception: Could not find source plugin for generic

Expected results

simple example from doc to be working

Additional information

No response

@ttuffin
Copy link
Contributor

ttuffin commented Apr 27, 2023

Hi @tarilabs, we just added the generic source plugin to the collection a couple of days ago and we need to get a new release up on Galaxy. I'll see if we can get it done this week.

In the interim, you can clone the event-driven-ansible collection repo and from there run: ansible-galaxy collection install .
You may need to include the --force arg to overwrite your existing collection.

@Alex-Izquierdo
Copy link
Contributor

Hi, there is no need to clone the repo. You can run just

ansible-galaxy collection install git+https://github.com/ansible/event-driven-ansible.git --force

@tarilabs
Copy link
Contributor Author

duly noted ✍️ thank you for all your feedbacks. I would suggest keeping this issue open until new EDA release, also for Google/SEO purposes in case someone else stumbles on the same issue.

@tarilabs
Copy link
Contributor Author

tarilabs commented May 2, 2023

fyi I have tried per #494 (comment)

but it does not work:

$ ansible-galaxy collection install git+https://github.com/ansible/event-driven-ansible.git --force
Cloning into '/Users/mmortari/.ansible/tmp/ansible-local-4300uq5kaeu1/tmp_fbly964/event-driven-ansiblerqnade2u'...
remote: Enumerating objects: 125, done.
remote: Counting objects: 100% (125/125), done.
remote: Compressing objects: 100% (104/104), done.
remote: Total 125 (delta 6), reused 70 (delta 2), pack-reused 0
Receiving objects: 100% (125/125), 43.73 KiB | 2.08 MiB/s, done.
Resolving deltas: 100% (6/6), done.
Your branch is up to date with 'origin/main'.
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Installing 'ansible.eda:1.3.5' to '/Users/mmortari/.ansible/collections/ansible_collections/ansible/eda'
Created collection for ansible.eda:1.3.5 at /Users/mmortari/.ansible/collections/ansible_collections/ansible/eda
ansible.eda:1.3.5 was installed successfully

$ cat empirico1.rulebook.yml 
- name: empirico1
  hosts: all
  sources:
    - ansible.eda.generic:
        payload:
          - kind: Pod
            apiVersion: v1
            metadata:
              name: hello-pvdf
              namespace: default
              uid: 6cd445f4-227d-4e81-957f-88ab08ee0a6c
              resourceVersion: '35203'
              creationTimestamp: '2023-04-26T14:50:54Z'
              labels:
                app.kubernetes.io/name: hello-pvdf
                app.kubernetes.io/version: 1.47-SNAPSHOT
  rules:
    - name: r1
      condition: event.payload.metadata.name == "hello-pvdf"
      action:
        debug:
          msg: "Received: {{ event.payload.metadata.uid }}"

$ ansible-rulebook -i inventory.yml --rulebook empirico1.rulebook.yml 
2023-05-02 09:25:48,744 - ansible_rulebook.engine - ERROR - Source error
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/ansible_rulebook/engine.py", line 93, in start_source
    raise Exception(
Exception: Could not find source plugin for ansible.eda.generic
2023-05-02 09:25:48,745 - ansible_rulebook.engine - ERROR - Shutting down source: ansible.eda.generic error : Could not find source plugin for ansible.eda.generic
2023-05-02 09:25:48,765 - ansible_rulebook.app - ERROR - Could not find source plugin for ansible.eda.generic
2023-05-02 09:25:48,766 - ansible_rulebook.cli - ERROR - Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/ansible_rulebook/cli.py", line 196, in main
    asyncio.run(app.run(args))
  File "/usr/local/Cellar/[email protected]/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/Cellar/[email protected]/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.10/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

@seulsale
Copy link

Hitting same issue as @tarilabs while trying to use the ansible.eda.watchdog source.
Ansible-rulebook version is 0.13.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants