ansible/ansible-rulebook

FQCN playbooks do not work on run_playbook action

rcarrillocruz opened this issue · 3 comments

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

Using FQCN playbooks on run_playbook they don't seem to work.
The rulebook process errors out that it cannot find it.

Environment

Fedora 34

Steps to reproduce

  1. Clone ansible/aap-containerized-installer repo
  2. Install it as a collection by running `ansible-galaxy collection install .'
  3. Create a rulebook with a rule with action such as:
      action:
        run_playbook:
          name: ansible.containerized_installer.install

Actual results

When the event gets triggered, I get:

May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]: 2023-05-24 12:43:24,546 - ansible_rulebook.rule_set_runner - ERROR - Error calling run_playbook
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]: Traceback (most recent call last):
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]:   File "/usr/local/lib/python3.11/site-packages/ansible_rulebook/rule_set_runner.py", line 375, in _call_action
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]:     await builtin_actions[action](
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]:   File "/usr/local/lib/python3.11/site-packages/ansible_rulebook/builtin.py", line 303, in run_playbook
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]:     temp_dir, playbook_name = await pre_process_runner(
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]:                               ^^^^^^^^^^^^^^^^^^^^^^^^^
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]:   File "/usr/local/lib/python3.11/site-packages/ansible_rulebook/builtin.py", line 647, in pre_process_runner
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]:     raise PlaybookNotFoundException(msg)
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]: ansible_rulebook.exception.PlaybookNotFoundException: Could not find a playbook for ansible.containerized_installer.install from /home/ec2-user/aap/servicediscovery/etc

However, the playbook looks fine, I can run it with ansible-playbook:

[ec2-user@ip-172-31-17-143 aap-containerized-installer]$ ansible-playbook ansible.containerized_installer.install
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
[WARNING]: running playbook inside collection ansible.containerized_installer

It seems the 'playbooks' folder is not searched within the collection.

Expected results

Action runs playbook using FQCN just fine.

Additional information

No response

Does ansible-galaxy collection list ansible.containerized_installer.install return anything?

This is a bug we are looking for playbooks only in the root directory of the collection we don't look into playbooks. I will fix this shortly

I have the same error trying to run the playbook ansible.eda.hello, even if the playbook is in the root directory of the collection.
I had to create an empty file "ansible.eda.hello" into the directory where I run ansible-rulebook.
When I did this, the playbook ~/.ansible/collections/ansible_collections/ansible/eda/playbooks/hello.yml is found and executed by run_playbook.