From charlesreid1

No edit summary
 
(One intermediate revision by the same user not shown)
Line 8: Line 8:


Example:
Example:
'''<code>ansible.cfg</code>''':


<pre>
<pre>
[defaults]
[defaults]
inventory = inventory
inventory = hosts
remote_user = vagrant
remote_user = vagrant
private_key_file = ~/.vagrant.d/insecure_private_key
private_key_file = ~/.vagrant.d/insecure_private_key
host_key_checking = False
host_key_checking = False
</pre>
</pre>
This saves you from having to use the -i flag for inventory and the -u flag for user, and from having to specify the private key in the hosts file.


=References=
=References=

Latest revision as of 19:17, 12 November 2018

This article covers configuration of Ansible using the Ansible configuration file, ansible.cfg.

Note: any configuration option that can be set in ansible.cfg can also be set/overridden with an environment variable.

Overview

The configuration file, like the hosts file, consists of headings in [brackets] followed by key = value values, one per line.

Example:

ansible.cfg:

[defaults]
inventory = hosts
remote_user = vagrant
private_key_file = ~/.vagrant.d/insecure_private_key
host_key_checking = False

This saves you from having to use the -i flag for inventory and the -u flag for user, and from having to specify the private key in the hosts file.

References

There is a comprehensive reference listing all possible options that can be set in this file here: https://docs.ansible.com/ansible/latest/reference_appendices/config.html

Each configuration option can also be set with an environment variable.


Flags