Can’t find the config file in “/etc/ansible/” on Mac OS X

Solution 1:

From what I know the Ansible config file (ansible.cfg) might be located here for user-level configuration settings:

~/.ansible.cfg

As well as the system-wide config located here; where you state you can’t find any such file:

 /etc/ansible/ansible.cfg

If somehow you have multiple users on your system, perhaps there is a ~/.ansible.cfg floating in one of their user directories you have forgotten about?

You state you might have installed it using pip, but checking the Homebrew formula for Ansible, it was only recently bumped from version 1.9.2 to 1.9.3 on September 4th. So perhaps you installed it via Homebrew?

And your main concern seems to be whether the ansible.cfg is necessary:

Ansible works as far as I can tell (without a local ansible.cfg, and there’s nothing in the ansible folder in the user dir), but I’m confounded.

Can someone please explain what I’m not getting here?

Yes, it should work fine without a configuration. For most pieces of software all a config file does is override the core system defaults. So if ansible.cfg is missing, Ansible would still work but only be using the core system defaults. As explained in Ansible’s official documentation:

Certain settings in Ansible are adjustable via a configuration file. The stock configuration should be sufficient for most users, but there may be reasons you would want to change them.

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

Solution 2:

The homebrew formula replaces the string /etc/ansible in constants.py with /usr/local/etc/ansible. Seems like bad juju to me.

I did not have /usr/local/etc/ansible after brew install ansible. However, I did confirm that if you put a valid ansible.cfg there, it will be honored (for now).

My recommendations:

  1. Don't use brew to install Ansible.
  2. Be explicit about your config don't depend upon system environment globals, such as /etc/ansible/ansible.cfg.

Code Refs:

brew ansible formula replacement #475: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/ansible.rb#L475

ansible constants.py #61: https://github.com/ansible/ansible/blob/v1.9.3-1/lib/ansible/constants.py#L61