How can we help?
Categories
< All Topics
Print

Classes: Introduction to Ansible for a robust Configuration Management

Do you need robust configuration management? If you manually manage many servers with many configurations, then you know how difficult it is. This is where Ansible can help you to have better server management and configuration standardization without too much hassle.

What is Ansible?

  • Ansible is an open-source IT Configuration Management, Deployment & Orchestration tool.
  • It aims to provide large productivity gains to various automation challenges.
    For example, you are going to config SMTP servers or collect logs from SMTP servers.
  • This tool is very simple to use but powerful enough to automate complex application environments.
  • Ansible is an automation tool that provides a way to define infrastructure as code.
  • Infrastructure as code (IAC) means managing infrastructure by writing code rather than using manual processes.
  • You don’t need to know the commands to accomplish a specific task.
    For example, when adding a new user on Linux OS. Normally, you need to run more than two commands to add the new user.
  • In Ansible, you simply need to specify what state you want the system to be in, and then Ansible will take care of it.
    (In case of adding a user, state can be “present” or “absent”)
  • For example,
    • Task for create new user
      – name: Manage Users  
      user:    
      name: user1    
      state: present  
      groups: engineer    
      shell: /bin/bash    
      become: true  
      tags:    – usergroup

Ansible connects via SSH to remote hosts listed on inventory files such as /etc/ansible/hosts. You can do a simple command by using the Ansible adhoc command. For example, to get a date from a server, you can do it like “ansible –m command SERVER date”.

You can also do a complete setup on a server, like installing apps and configuring them on a server using Ansible Playbook. Playbook is a template for which “Infrastructure as a Code” term refers to a Code.

Playbook will have modules, inventory, and tasks. Since Playbook is a template, we can use it as a standard centralized configuration for all the server provisioning. Also, we can share the templates and modify them as needed.

Terminologies

Generally, Ansible uses these terminologies below:

  1. Controller Machine: Machine to install Ansible
  2. Inventory: detailed info regarding servers to be managed
  3. Playbook: Automation is defined using tasks defined in YAML format
  4. Task: Procedure to be executed
  5. Module: Predefined command execute directly on remote hosts
  6. Play: Execution of a playbook
  7. Role: a Pre-defined way for organizing playbooks
  8. Handlers: Tasks with unique names. Another task will execute it if there is any notification.

    (For an example of the configuration, please visit “Classes: Install and Configure Ansible” and “Classes: Post Installation”)

Advantages of Ansible for Configuration Management

  • Ansible is an open-source tool.
  • Ansible’s playbooks do not require special coding skills.
  • It also allows you to model even highly complex IT workflows.
    For example, you need to add a repository based on the OS version.
  • You do not need to install any agent on the target systems you want to automate.
  • You do not need to set up a separate management structure like puppet.
  • Since you don’t have to install any extra software, your server has more room for application resources.
  • Ansible is simple, reliable, and consistent for configuration management.
  • Secure and consistent
    Because Ansible only uses SSH and Python on the managed nodes, it ensures safety and security.
  • Reliable
    An Ansible playbook can be idempotent when written carefully. This prevents unexpected side effects on the managed systems.
    An operation is idempotent if the result of performing it once is exactly the same as the result of performing it repeatedly without any intervening actions (denoting an element of a set that is unchanged).

Lastly, if you want to know how to install and configure Ansible, you can find out by reading this article.

Table of Contents