Ansible Advantages and Disadvantages

Ansible is an open source orchestration and configuration tool. By writing simple YML files, you can automate a variety of infrastructure, including networks, servers, and clouds. In this article, we will learn the basics of YML files and how to automate your infrastructure infrastructure frame using Ansible We considered the advantages and disadvantages of Ansible.

Should be automated by promoting cloud computing

First, cloud computing is being used, but cloud computing is pay-as-you-go.
The cost is high, so an operation that provides infrastructure when needed and removes the environment when it is not needed is suitable.
The cloud is expensive and can be used when the case is right.
In many cases, I want to use the verification environment temporarily, so it is beneficial to be able to create the verification environment quickly and only when I want to use it if I can build it automatically.
Let’s use Ansible to automate and make the most of the cloud.
On the other hand, there is also the generous Oracle Cloud Infrastructure that offers servers that can be used for free for many years.
If you are interested, please read this article as well.

Infrastructure as Code

Infrastructure as Code is the automation of infrastructure construction and modification tasks that used to be done manually, but are now defined in code. What has been done in the application can be applied at the infrastructure layer to manipulate infrastructure resources with code. Managing the infrastructure with code would have the advantage of reducing operating costs, improving quality, and making governance more effective by standardizing the work.
On the other hand, while design documents and the like may no longer be needed, the code itself must be managed by version control and CI tools. It will take time for infrastructure engineers to understand how to operate more than applications.

Scope of Infrastructure as Code

There are three areas that can be automated with Infrastructure as Code: Orchestration, Configuration Managemetn , and BootStrapping. Simply put, the three layers are Application, OS, and BIOS. Tools that can automate at each layer include Capistrano/Fabric, CFEngine/Puppet/Chef, AWS/VMware/Docker, etc. It can get complicated if multiple tools have different defenses, so it is better to have a tool that can cover them all.
So, one tool that can do multi-layered orchestration is Ansible, which covers the scope of all three. Ansible can be used without an Agent on the client side as well, so as long as you have an ssh connection, you can proceed with the automation.
In this article, we will introduce Ansible.

What is Ansible?

Ansible is an open source orchestration and configuration tool developed for infrastructure automation. Ansible is an open source orchestration and configuration tool developed for infrastructure automation. YML files are sets of instructions for automating the infrastructure.

YML Basics

YML (YAML Markup Language) is a concise markup language for automating infrastructure configuration. we often create Ansible playbooks by following three rules for writing YML files

  • Use two spaces to create indentation.
  • Use a colon (:) to associate a keyword with a value.
  • Use a hyphen (-) to indent list items.

The simplicity of the YAML format makes it easy to read and write, and it is characterized by low learning costs and low genus.

A specific example is shown below, starting with “—“.

---
- hosts: webservers
  remote_user: root
  sudo: yes
  tasks:
  - name: Install software
    apt: name={{item}} state=installed

Advantages and disadvantages of Ansible

YAML is simple, so using Ansible offers the benefits of simplicity.
On the other hand, complex processing including conditional branching requires ingenuity, and overcomplicating the process will weaken the benefits.
It is important to reduce the process to a simple operation and automate it.

Advantages and disadvantages include

.

  1. easy configuration management; Ansible requires no programming skills and uses the YAML language to define host and service configurations using Playbooks.
  2. multi-platform support; Ansible supports many operating systems (Linux, UNIX, Windows) and services (MySQL, Apache, nginx). You can grasp the details by checking the module index.
  3. lightweight and scalable.
    It is lightweight and scalable; the architecture that Ansible incorporates does not require you to manage all of your servers and is fast.
  4. With Ansible, your infrastructure configuration becomes code in the form of code files. This makes it easy to track how applications and servers are configured. It also allows you to unify server configurations and simplify changes.

<Disadvantages.

  1. Ansible is not suited for building customized and flexible infrastructure. You should set up a simple configuration.
  2. it is not suited for complex operations, and Ansible’s looping syntax seems to be very cumbersome.
  3. when using Ansible with virtual machines, you need to define the environment of the virtual machine with variables.

Ansible defines and automates Inventory and Playbook

As a simple configuration, you define Inventory and describe what to do in Playboook to move it along.
If we consider that we only define what to do and how to do it, it is a good idea to have a simple concept.
As an Inventory, we describe parameters such as IP address, etc. We define it as inventory.ini.
It can be grouped into any group name, such as [web_servers], [db_servers], etc.
The all group is defined implicitly and refers to everything listed in the inventory file.

[web_servers]
web-1 ansible_host=192.168.10.1
web-2 ansible_host=192.168.10.2
[db_servers]
db-1 ansible_host=192.168.11.[1:2]

As a playbook, define what to do for the above inventory: define site.yml.
The example below shows how to yum start httpd on 192.168.10.1/192.168.1.2 defined in yml.

- hosts: web_servers
  tasks:
   - name: Install Apache
      yum:
       name: httpd
              state: started
       enabled: yes

It is a simple image that configures what to do and for what.
Execution can be done by specifying inventory and yml.

ansible-playbook -i invent.ini site.yml

What happens when you execute the same thing twice?

Ansible guarantees completeness, which means that multiple runs can be made without error and the program will move on to the next task.
Therefore, there is no need to describe conditional branches for error handling, which simplifies the playbook.
However, if you use a highly flexible module such as the command module, you will not be able to use one of the advantages of ansible. It is better to use the command module as a last resort.

Conclusion

As an introduction to Ansible, we have introduced the advantages and disadvantages of Ansible.
Ansible is simple and can be used for a wide range of applications.
The community version is free to use, and I would like to try both the CLI/GUI versions.