ansible config file not found; using defaults

Viewed 12144

I have created venv called ansible and installed ansible using pip3 install ansible. Now while checking ansible version config file = None

ansible --version
ansible 2.9.12
  config file = None
  configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ansible/ansible/lib/python3.7/site-packages/ansible
  executable location = /home/ansible/ansible/bin/ansible
  python version = 3.7.4 (default, Aug 18 2019, 12:04:45) [GCC 5.4.0 20160609]

When I run ansible command it says No config file found; using defaults but which is that defaults file and where it can be found ?

3 Answers

Q: "Which is that defaults file and where it can be found."

A: Short answer: There doesn't have to be any configuration file. In this case the hardcoded defaults will apply.

Quoting from Getting the latest configuration

"If installing Ansible from a package manager, the latest ansible.cfg file should be present in /etc/ansible..."

See The configuration file. Ansible searches configuration files in this order

  1. ansible.cfg (in the current directory)
  2. ~/.ansible.cfg (in the home directory)
  3. /etc/ansible/ansible.cfg

If there isn't any configuration file the defaults will apply. See the hardcoded defaults in Ansible Configuration Settings. The output of the below command will show you where each configuration option comes from

shell> ansible-config dump
  • It's not wise to name your virtual environment ansible I suggest to rename it.
  • Please share the command which you used to create the virtual environment (because you should activate it, I do not see it from what you have shared)
  • If you want a quick fix for your issue , you could declare a environment variable named ANSIBLE_CONFIG with the location of your desired configuration.

Ansible looks for the config file in this order:

ANSIBLE_CONFIG (env var)
ansible.cfg (in the current directory)
~/.ansible.cfg (in the home directory)
/etc/ansible/ansible.cfg

ansible configuration file is only created automatically during the installation if you perform the installation with package managers like yum or apt-get. If you installed ansible using pip you should create the configuration file manually.

Related