Ansible config file in current directory not used

According to the docs (https://docs.ansible.com/ansible/latest/reference_appendices/config.html#ansible-configuration-settings-locations), Ansible is supposed to use ansible.cfg from the current directory as the second option if the env var ANSIBLE_CONFIG isn’t defined. However it doesn’t appear to be working for me.

I’m in the process of creating a collection and I have a virtual env set up in the current directory, with Ansible 2.9 installed. When I run Ansible however, it is going straight to the .ansible.cfg file in my user’s home directory and ignores the ansible.cfg file I created in the collection dir. The folder layout is as follows:

ansible.cfg docs env galaxy.yml hosts.yml playbooks plugins README.md requirements.txt roles

My venv is enabled and when I run ansible it shows the following:

(env) root@DESKTOP-JH6A27J:~/work/knightsg/dkron# ansible --version ansible 2.9.9 config file = /root/.ansible.cfg configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /mnt/c/Users/guy/Documents/Work/knightsg/dkron/env/lib/python3.6/site-packages/ansible executable location = /mnt/c/Users/guy/Documents/Work/knightsg/dkron/env/bin/ansible python version = 3.6.5 (default, May 3 2018, 10:08:28) [GCC 5.4.0 20160609]

As you can see, it’s using /root/.ansible.cfg.

If I supply ANSIBLE_CONFIG then it uses the ansible.cfg file in the current folder:

(env) root@DESKTOP-JH6A27J:~/work/knightsg/dkron# ANSIBLE_CONFIG=./ansible.cfg ansible --version ansible 2.9.9 config file = /mnt/c/Users/guy/Documents/Work/knightsg/dkron/ansible.cfg configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /mnt/c/Users/guy/Documents/Work/knightsg/dkron/env/lib/python3.6/site-packages/ansible executable location = /mnt/c/Users/guy/Documents/Work/knightsg/dkron/env/bin/ansible python version = 3.6.5 (default, May 3 2018, 10:08:28) [GCC 5.4.0 20160609]

Any idea why Ansible isn’t selecting the correct config file by default?

Thanks,
Guy

This could be the case if the directory the config file is in, is
world writable.
The path you use ( /mnt/c/Users/guy) indicates this is some sort of
Windows filesystem. Could it be that this is mounted is a way that
causes it directory in question to be world writable?

See also https://docs.ansible.com/ansible/latest/reference_appendices/config.html#avoiding-security-risks-with-ansible-cfg-in-the-current-directory