# Ansible config file in current directory not used

**URL:** <https://forum.ansible.com/t/ansible-config-file-in-current-directory-not-used/33173>\
**Category:** Ansible Project\
**Tags:** galaxy-ng\
**Created:** [June 14, 2020, 5:47pm UTC](https://forum.ansible.com/t/ansible-config-file-in-current-directory-not-used/33173 "2020-06-14T17:47:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Knights](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Guy\_Knights](https://forum.ansible.com/u/Guy_Knights)\
**Post date:** [June 14, 2020, 5:47pm UTC](https://forum.ansible.com/t/ansible-config-file-in-current-directory-not-used/33173/1 "2020-06-14T17:47:20Z")

</div>

According to the docs ([https://docs.ansible.com/ansible/latest/reference\_appendices/config.html#ansible-configuration-settings-locations](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

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [June 14, 2020, 6:39pm UTC](https://forum.ansible.com/t/ansible-config-file-in-current-directory-not-used/33173/2 "2020-06-14T18:39:25Z")

</div>

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](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#avoiding-security-risks-with-ansible-cfg-in-the-current-directory)
