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

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/71e2fe59-d1ba-4cdb-a799-fe3d8bb6658fo%40googlegroups.com.

Reply via email to