Ansible: path to ansible.cfg

Question:

I have this known issue. So I try to fix it but I don’t see where I have to create my ansible.cfg (or does it already exist)? I tried it in my homedirectory but it still did not work.

I read a lot about /etc/ansible but on my system it isn’t there.
I’m on Mac El Capitan. I’ve installed ansible by using pip.

Answer:

From the docs:

Changes can be made and used in a configuration file which will be processed in the following order:

  • ANSIBLE_CONFIG (an environment variable)
  • ansible.cfg (in the current directory)
  • .ansible.cfg (in the home directory)
  • /etc/ansible/ansible.cfg

I’m not sure this does 100% apply to 1.9.4. Ansible is terrible in versioning their documentation. (=there only is one version and not always the version a feature was introduced or changed is mentioned)

But I am sure everything except ~/.ansible.cfg works in 1.x as I have tried that before.

So if you have created ~/.ansible.cfg and it is not being used, check if the environment var ANSIBLE_CONFIG is set or there is one file in the directory from where you call ansible. The first one found will be used. processed in the following order does not mean they will be merged in that order. First one found wins.

I read a lot about /etc/ansible but on my system it isn’t there.

Yeah, that depends on how Ansible was installed. If it’s not there you could just create it but if you do not need it, no need to create it. I actually deleted mine as I see no use for it.

Leave a Reply