Part 5 – Ansible Config

Ansible config file has the default settings that most users are ok to run with. However the settings can be modified like the number of parallel tasks to run at a time, default location of inventory, jinja2 extensions, log_path, private key file and so on. The ansible.cfg file can be at four different locations but the order of the processing does matter. The first file found will be used and the settings will not be merged. Below is the order of processing and possible file locations.

1) ANSIBLE_CONFIG (environment variable)
2) ansible.cfg (in the current directory)
3) ~/.ansible.cfg (home directory of current user)
4) /etc/ansible/ansible.cfg (when ansible is installed via package or pip)

Here is my ansible.cfg file located at /etc/ansible on my ansible host.

2017-04-04 02_22_56-vagrant@ansi_ ~

Below are few mostly modified settings in the ansible.cfg

forks  -> This defines the default number of parallel processes to run when communicating with managed nodes. The default setting is 5 and can be changed as per your need.

host_key_checking  -> If the host key is not registered in known_hosts file, then it prompts for key confirmation during execution. By default host_key_checkig is enabled.

inventory  -> This defines the default location of the inventory file.

library  -> Default location Ansible looks for modules. (/usr/share/ansible)

log_path  -> Path to log information about the executions. Disabled by default

private_key_file  -> In case you use pem file for authentication like for AWS, the default path value can be set here.

vault_password_file  -> configures the path for the Vault password file, saves from entering the passwords.

Apart from the above settings that can be modified, there are many other settings for ansible.cfg which you can lookup in the ansible documentation.

Hope this was informative. Thanks!

 Part 1 – Introduction to Ansible

Part 2 – Ansible Lab Setup

Part 3 – Understanding our First Ansible Command

Part 4 – More about Inventory File

Part 5 – Ansible Config

Part 6 – Ansible Modules

Part 7 – Ansible Tasks, Plays, PlayBooks

Part 8 – Ansible Play Recap, vars, Notify, Handlers

Part 9 – Ansible Roles


#etcansible, #ansible-cfg, #host_key_checking