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

Hello everyone,
I'm Okazaki, a member of the SRE team in the System Solutions Department
I think that in the course of operations, it is common to have to do the same tasks and build the same servers. It
can be very tedious to do the same tasks every time, and you
have to deal with those tasks even though you want to do other work.
to introduce a tool I have recently been using to eliminate such routine tasks: 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 between them 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 higher is installed on the client and SSH can be connected.
Features of Ansible
Other features include the following:
-
idempotency
Like other configuration management tools, Ansible is characterized by its idempotence guarantee,
the tool guarantees that some modules will converge to the same state no matter how many times they are executed, -
Module
allows you to control and execute
various functions and platform settings with minimal To use them, you need to use a function called a defined module.
The modules themselves have been created to perform detailed server settings (yum, user, file) and
to configure each platform (ec2, azure, gce), and
compatibility may vary depending on the version, they can all 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 the Python version is 2.4 or higher, it can be installed without any problems.
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 gave a brief introduction to Ansible and how to install it, but
write about how to
actually install it and then connect to another server from Ansible via SSH and configure I hope this article has sparked at least some interest in Ansible and operation/construction automation.
That's all for now.
0