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

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

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


On OSX, I had installed ansible using pip and found that ansible.cfg is not present in /etc/ansible or in my home directory.

Source: https://github.com/ansible/ansible/issues/18512

pip doesn't generally install configuration files and pip with ansible is no different. If you just want to try out ansible, it generally works without an ansible.cfg file. (You do need to specify some inventory but you can do that on the command line rather than a file if you want). If you want to get a sample config file to adapt, you can get it from the tarball or the source repository here: https://github.com/ansible/ansible/blob/devel/examples/ansible.cfg

Inventory files are explained here: http://docs.ansible.com/ansible/intro_inventory.html To specify hosts for inventory on the command line instead just do something like this:

ansible -i 'host1,host2,host3'  all -m command -a 'hostname'

If you want to specify a single host via the command line use a trailing comma in the inventory string:

ansible -i 'host1,' all -m command -a 'hostname'

Tags:

Macos

Ansible