Getting started with Infrastructure as Code using Ansible (Introduction & Installation)

Hello everyone,
the System Solutions Department
I'm Okazaki from the SRE team in
In the course of operations, you often find yourself doing similar tasks and building similar servers. It can be incredibly tedious
to do the same thing over and over again, and you
end up having to dedicate time to these tasks when you should be working on other things.
To eliminate these repetitive tasks, I'd like to introduce a tool I've recently started using: Ansible.
What is Ansible?
It is generally known as a configuration management tool for deployment management and infrastructure configuration management.
Other representative configuration management tools include Chef and Puppet.
The differences are as follows:
Chef
- Developed by Chef
- The agent must also be installed on the client where the operation is to be performed
- The configuration file is written in Ruby, which requires a high learning curve
- It was released before Ansible and is still being released frequently
Puppet
- Developed by Puppet Labs
- It can be used by installing an agent on the client to run it, or as a standalone
- The oldest release of the three
- The configuration file is written in Ruby, which requires a high learning curve
Ansible
- Developed by RedHat
- No need to install an agent on the client
- The least experienced of the three
- The configuration file is written in YAML, so the learning cost is low
The differences are as described above, but Ansible
will work as long as Python 2.4 or later is installed on the client and an SSH connection is possible.
Features of Ansible
Other features include the following:
-
idempotency
Like other configuration management tools, Ansible is characterized by its guarantee of idempotency.
This means that no matter how many times it is executed using certain modules, it
will converge to the same state, without requiring any user intervention. -
Module
various functions and platform configurations with a minimum number of
allows you to control and execute
To use these, you need to utilize a defined feature called modules.
Modules are created for detailed server configurations (yum, user, file) and
platform configurations (ec2, azure, gce), and while
compatibility may vary depending on the Ansible version, they can be used.
How to install Ansible
Now, I will show you how to install Ansible
First, check the version of Python
# python --version Python 2.7.5
Since your Python version is 2.4 or higher, installation should be possible without any problems.
We will install it to specify the EPEL repository.
# yum install epel-release
Now let's install Ansible
# yum install --enablerepo=epel ansible Installed: ansible.noarch 0:2.6.3-1.el7 Dependency Installed: PyYAML.x86_64 0:3.10-11.el7 libtomcrypt.x86_64 0:1.17-26.el7 libtommath.x86_64 0:0.42.0-6.el7 libyaml.x86_64 0:0.1.4-11.el7_0 make.x86_64 1:3.82-23.el7 openssl.x86_64 1:1.0.2k-12.el7 python-babel.noarch 0:0.9.6-8.el7 python-cffi.x86_64 0:1.6.0-5.el7 python-enum34.noarch 0:1.0.4-1.el7 python-httplib2.noarch 0:0.9.2-1.el7 python-idna.noarch 0:2.4-1.el7 python-jinja2.noarch 0:2.7.2-2.el7 python-keyczar.noarch 0:0.71c-2.el7 python-markupsafe.x86_64 0:0.11-10.el7 python-paramiko.noarch 0:2.1.1-4.el7 python-ply.noarch 0:3.4-11.el7 python-pycparser.noarch 0:2.14-1.el7 python-six.noarch 0:1.9.0-2.el7 python2-crypto.x86_64 0:2.6.1-15.el7 python2-cryptography.x86_64 0:1.7.2-2.el7 python2-jmespath.noarch 0:0.9.0-3.el7 python2-pyasn1.noarch 0:0.1.9-7.el7 sshpass.x86_64 0:1.06-2.el7 Complete!
Installation complete!!
# ansible --version ansible 2.6.3 config file = /etc/ansible/ansible.cfg configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Ansible 2.6.3 has been successfully installed!
summary
This time, I briefly introduced Ansible and explained how to install it.
actually install it and then use Ansible to establish an SSH connection to another server and
I'd like to write about how to
. I hope this article has sparked some interest in Ansible and automation of operations and configurations.
That's all for now.
0
