> I feel like most people run their Ansible scripts from the Ansible root 
directory and mentally treat that as the directory that Ansible should be 
searching for vars/roles/inventory/etc, _especially_ since the 
`ansible.cfg` is located there.

Your last two years must've been bloody awful. 

On Monday, February 26, 2018 at 12:31:42 PM UTC+5:30, Percy Grunwald wrote:
>
> I've decided to drop my two cents in here as well since I have spent the 
> past hour trawling Google for advice about this issue and found nothing 
> that I consider to be an acceptable solution.
>
> In my opinion, Ansible's behavior when moving playbooks into a 
> subdirectory (but still running them from the root directory) is 
> unintuitive and doesn't seem to match how other programs work. I could 
> enumerate all of the things that stop working, but I think it's sufficient 
> to say that the expected behavior for the majority of people would be as 
> follows:
>
> Given that my directory structure is exactly the same as the layout shown 
> in 
> http://docs.ansible.com/ansible/latest/playbooks_best_practices.html#directory-layout,
>  
> and I am running my scripts from the Ansible root directory like:
>
> ```
> cd /path/to/project/ansible
> ansible-playbook site.yml
> ```
>
> If I copy `site.yml` into any subdirectory of the Ansible root folder:
>
> ```
> mkdir -p playbooks/subdir
> cp site.yml playbooks
> cp site.yml playbook/subdir
> ```
>
> Then the following commands should all be **identical**:
>
> ```
> ansible-playbook site.yml
> ansible-playbook playbooks/site.yml
> ansible-playbook playbooks/subdir/site.yml
> ```
>
> In the 2+ years I have been using Ansible, I haven't encountered a 
> situation where the current default behavior would have been beneficial 
> compared to the behavior I outlined above. I feel like most people run 
> their Ansible scripts from the Ansible root directory and mentally treat 
> that as the directory that Ansible should be searching for 
> vars/roles/inventory/etc, _especially_ since the `ansible.cfg` is located 
> there.
>
> It would be really great if there was a setting that would make Ansible 
> behave in the way I have outlined. I would suggest a boolean variable 
> called something like `lock_working_dir` or `lock_base_dir` that would 
> "lock" Ansible to the `pwd` when searching for vars/roles/inventory/etc.
>
> This would be a huge boon for organization. I'm happy to have a go at this 
> if this is something that would get considered for PR.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a236b777-d220-485a-8f05-aa2cfa95422c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to