custom log in ansible
Ansible configuration file uses an INI format to store its configuration data. In Ansible, we can overwrite nearly all of the configuration settings either through Ansible playbook options or environment variables.
While running an Ansible command, the command looks for its configuration file in a predefined order, as follows:
*ANSIBLE_CFG: This environment variable is used, provided it is set
*ansible.cfg: This is located in the current directory
*~/.ansible.cfg: This is located in the user's home directory
*/etc/ansible/ansible.cfg
The default ansible configuration file is available under /etc/ansible
# tree /etc/ansible/
/etc/ansible/
├── ansible.cfg
└── hosts
[defaults] section
Ansible's configuration file is divided into several sections. The main section that we will concentrate on is the [defaults] general section.
inventory
This points to the path of the inventory file which contains the hostname or IP address details of managed nodes.
On most systems, it points to /etc/ansible/hosts, as follows
#inventory = /etc/ansible/hosts
roles_path
This contains the path of default roles directory where the Ansible playbook should look for additional roles:
#roles_path = /etc/ansible/roles
log_path
This defines the log files where Ansible should be storing its log.
The log file and path must have enough permission for the user running Ansible to perform read and write operations.
#log_path = /var/log/ansible.log
host_keychecking
A host key is assigned for individual managed nodes.
Now it is possible that the client nodes get re-installed multiple times which can cause Ansible to throw a warning at the time of initiating the connection.
Disabling this parameter will make Ansible ignore the error messages related to the known_hosts keys:
#host_key_checking = False
This is all about the ansible configuration file, we can learn more about different options in the configuration file on the official ansible page.
Relevant Blogs:
Recent Comments
No comments
Leave a Comment
We will be happy to hear what you think about this post