Ansible/Configuration: Difference between revisions
From charlesreid1
(Created page with "You can configure how Ansible works in the ansible.cfg file There is a comprehensive reference listing all possible options that can be set in this file here: https://docs.an...") |
|||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
This article covers configuration of [[Ansible]] using the Ansible configuration file, <code>ansible.cfg</code>. | |||
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 <code><nowiki>[brackets]</nowiki></code> followed by <code>key = value</code> values, one per line. | |||
Example: | |||
'''<code>ansible.cfg</code>''': | |||
<pre> | |||
[defaults] | |||
inventory = hosts | |||
remote_user = vagrant | |||
private_key_file = ~/.vagrant.d/insecure_private_key | |||
host_key_checking = False | |||
</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= | |||
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 | 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. | Each configuration option can also be set with an environment variable. | ||
=Flags= | |||
{{AnsibleFlag}} | |||
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