Open evonlanthen opened 4 months ago
Synchronizing the directories to the ansible playbook main directory solves the issue:
for TYPE in host group; do
rsync -av inventories/*/${TYPE}_vars/ ${TYPE}_vars/
done
It there a better way?
Hi @evonlanthen Thanks for the report. Indeed I see two different bugs.
I'm going to fix them in https://github.com/ansible/ansible-rulebook/pull/683
Hi @Alex-Izquierdo
Thanks for your investigation and your fix.
Kind regards Elmar
@evonlanthen When you ran the ansible-rulebook command line can you use the directory name for inventory without the file name e.g
ansible-rulebook -i inventories
@evonlanthen When you ran the ansible-rulebook command line can you use the directory name for inventory without the file name e.g
ansible-rulebook -i inventories
If I specify the directory only, no hosts are found anymore. The same happens with:
ansible-rulebook -i inventories/production
@evonlanthen When a directory is set it should take the whole directory as inventory. This is what is going to fix: https://github.com/ansible/ansible-rulebook/pull/684
Please confirm the following
Bug Summary
I have a simple ansible playbook which prints variables defined in host_vars and group_vars files defined in the inventory directory. If I execute the playbook with ansible-playbook (or ansible-runner), the tasks can be executed. If I trigger it by a webhook via ansible-rulebook the variables are not found.
Environment
OS: WSL2, Ubuntu 22.04.3 LTS Ansible:
Ansible-rulebook:
Steps to reproduce
Directory structure:
playbook.yml:
rulebook.yml:
inventories/production/hosts.yml:
inventories/production/group_vars/mygroup.yml:
ansible-playbook command:
ansible-rulebook command:
webhook trigger:
ansible-rulebook output:
Actual results
Ansible-playbook run fails with undefined variable (it doesn't matter if a variable from group_vars or hosts_vars is used first).
Expected results
Successful ansible playbook run.
Additional information
No response