Learning DevOps
上QQ阅读APP看书,第一时间看更新

Configuring Ansible

By default, the Ansible configuration is in the /etc/ansible/ansible.cfg file that is created during the installation of Ansible. This file contains several configuration keys, such as an SSL connection, a user, a protocol, transport, and many others.

This file is created by default during the installation of Ansible and, to guide the user to get started, initial content is placed in it. This content contains a multitude of configuration keys that are commented out so that they are not applied by Ansible but can be activated at any time by the user.

The following screenshot shows an extract from this /etc/ansible/ansible.cfg configuration file with some keys in comment with the # symbol:

If we want to change the default Ansible configuration, we can modify this file.

For more details about all Ansible configuration keys, see the official documentation:  https://docs.ansible.com/ansible/latest/reference_appendices/config.html#ansible-configuration-settings.

We can also view and modify this configuration using the ansible-config command. For example, for displaying the Ansible configuration file, execute the following command:

ansible-config view

The following screenshot shows the execution of this command:

In this section, we have seen how to install Ansible and then we have explored some of Ansible's artifacts. Finally, we saw different ways to configure Ansible.

In the next section, we will detail a static Ansible inventory and how to create it for targeting hosts.