My ansible.cfg does not setup inventory, so I do not use /etc/ansible/hosts to decide inventory.
said Ansible determines variables based on precedence. But to do that, Ansible needs to first find the variable files, and then understand what types the files are, only after that it can determine the precedence right? so my questions are:
1/ if there are multiple sub-folders under the main ansible playbook folder, how does Ansible know where to find the variable files? Or maybe it simply collects all files under the main folder?
2/ How does Ansible know the type of a variable file, i.e. whether they are inventory group_vars/all, playbook group_vars/all, inventory host_vars/*, etc? Note Ansible needs to know the types of the files in order to determined the variable precedence.
I have these questions because I work on a Ansible playbook, its current layout is:
main_playbook.yaml
inventories/dev/rds/group_vars/all.yaml
inventories/dev/rds/group_vars/rds_something.yaml
Although Ansible playbook does not mention path, the Ansible magically knows the variables defined in all the variable files.
If Ansible can magically collect all these files, then how do I design the project so that it will know when to collect which files under different environments? Currently it only has dev environment but I plan to have test environment as well. But I do not know where to put variable files about test environment.