In order to use Ansible, we first need to define the inventory, which represents the available resources. Then, we will be able to either execute a single command or define a set of tasks using the Ansible playbook.
An inventory is a list of all the servers that are managed by Ansible. Each server requires nothing more than the Python interpreter and the SSH server installed. By default, Ansible assumes that the SSH keys are used for authentication; however, it is also possible to use the username and the password, by adding the --ask-pass
option to the Ansible commands.
Note
SSH keys can be generated with the ssh-keygen
tool, and they are usually stored in the ~/.ssh
directory.
The inventory is defined in the /etc/ansible/hosts
file, and it has the following structure:
[group_name] <server1_address> <server2_address> ...