Hello,
First. I’m a newcomer in Ansible, but i feel it’s very attractive regarding other solutions that i benched before (chef and puppet).
I started to read on Ansible 3 days ago, and forked the repo and installed from source 2 days ago.
I’m pretty new then, but still have common sens of what’s going on since i’ve been working before with others CM tools.
I’m still very curious about the typical working directory structure. I’m not sure about the hosts and playbooks being in the same root directory.
I was thinking it looked a little messy at first sight, and so my journey begun in trying to put hosts in a inventories/ folder, and playbooks in a playbooks/ folder, then go further with making my working directory fit my needs :
I almost succeeded in the first one using the ansible.cfg file that would eventually help to specify a default hostsfile (rather than a default directory) (note that i could also use -i with ansible-playbook, but then some path related side effects would occur regarding vars).
Playbooks would be called directly from command-line, no way to work around that ; but then if in a subfolder some errors would appear : the roles/ folder implicitly had to be at the same level than the running playbook (wherever this one is). I successfully patched this by the definition of roles_path in the ansible.cfg file.
Then, vars. At first i was not sure about why the group_vars and host_vars have this naming convention ; mostly i get it, but i’d rather have a vars/host/ and vars/group/ structure instead, and i’m surprised such configuration is not available in the ansible.cfg file, along with the existing role_path and hostfile.
More than some fashion, the way i patched this need would also allow global (/etc/ansible/) and user (~/.ansible) scope definition for group and host vars by the use of utils.path_dwim in the group_vars loading process and host_vars loading process. Such would be useful for user-sandboxing vars, as for each user could share a common role in /etc/ansible, and would only need to edit the configuration ~/.ansible/vars/host/ to write their own user credentials to connect to a server (for example - that’s a thing we’re currently thinking about in the organization i’m in).
I do agree that the use of utils.path_dwim might totally justify the need for customization of vars directory structure, but it’s still doable, done and default values wouldn’t change the current behavior in other ways than the enhancements i just told before.
My demonstration is a bit off-topic, but it’s mainly to justify the asking of : “why can’t i choose how i shape my working directory ?”
Thanks for reading, and answering,
Regards,
Julien