It is a free platform developed in Python and Ruby languages that allows servers under your Ansible management to do everything you want under one roof, does not require any agents to install on clients. Currently, it is open-source and commercially active under the roof of redhat.
Ansible in-house data centres, cloud structure, application distribution, software provisioning, configuration management, etc., which enables many servers in physical or virtual environments to be managed without requiring agent installation. Ansible has a coding structure that is easy to read and understand and is therefore very popular. Thus, many servers belonging to many different environments can manage with Ansible.
I want to talk a little bit about Ansible’s file structure. Ansible can contain different roles. You can define each action as a different role. In this way, your files will be more organized and meaningful. I will make my statements based on centos 8. Here, it contains files under /etc/ansible directory as the default directory.
For an administration with Ansible, it will be sufficient to connect to the server via SSH. We need to create an SSH key for the user to connect to servers with SSH. Then we need to set this SSH key as authorized_key for other users to connect. In my previous article, I explained the Ansible installation and how to create an ssh key. You can look at this link.
Let’s create a simple role structure and give some information about file directories. A role is created with the following command under “/etc/ansible/roles” array.
After this command, the file layout will be created in this way. Let’s write down what the files mean here.
defaults: Files where the default variables used in this role are stored.
files: Files to be uploaded to the remote server are hosted.
handlers: Here variables are usually stored where we can check the status of the services. Like restart, stop, start.
meta: It is the part that gives information about the created role. The information here is read by ansible and provided by the necessary dependencies.
task: The tasks to be executed by the role can be found here in different files.
templates: If there is a configuration to be sent to the server, it is kept here.
vars: Variables to be used by tasks are stored.