How To Install Ansible On RHEL7

how-to-install-ansible-on-rhel7
Getting your Trinity Audio player ready...

Best Free IT Automation Tool Ansible 

In this article, we will discuss how to install ansible on rhel7 and start your journey to automation. Ansible is the best IT automation tool. It is almost 4 years if I am not wrong Ansible gets delivered via Yum Repository in form of an on-demand repository. Red Hat provides many software packages in form of different categories of repositories.

You can find what all repo is enabled in your environment using the yum repolist command. You can understand by the below example.

# yum repolist

Repo id                                     

Repo Name                                                    

Status

distro/7.5-8.el7/x86_64

RedHat Linux Distribution

5,099

kernel/7.5-8.el7/x86_64

Updated Kernel Software

12

ondemand/7.5-8.el7/x86_64

On-Demand Requested Software

1,887

optional/7.5-8.el7/x86_64                          

On-Demand Requested Software

5,073

security/7.5-8.el7/x86_64

Linux Security Updates 

5,452

updates/7.5-8.el7/x86_64

Linux Software Updates

5,452

Before we reach installation let us understand few basic things related to Ansible. This is for beginners who are just starting with Ansible.

What is Ansible?

Ansible is an open-source information technology automation platform from Red Hat. Ansible uses human-readable YAML templates to allow users to automate repetitive tasks, without learning any advanced coding language.

Ansible replaces shell script-based automation with an automated and repeatable process. Ansible pushes application code, programs, and IT infrastructure setup instructions via modules to managed nodes, whether physical servers, virtual machines, or even cloud instances.

It is really handy in many cases like

  • Orchestration
  • Configuration Management
  • Used Cases
  • Provisioning
  • Application Deployments
  • Rolling Upgrades
  • Security and Compliance

Why Ansible Was Designed?

The main goal why Ansible was designed is as below for your reference.

  • Minimal in Nature: Systems management should not impose additional dependencies on the environment.
  • Consistent: With Ansible one should be able to create consistent environments.
  • Secure: Ansible does not deploy agents to nodes. Only OpenSSH and Python are required on the managed nodes.
  • Highly Reliable: When carefully written, an Ansible playbook can be idempotent, in order to prevent unexpected side-effects on the managed systems. It should be noted, however, that it is entirely possible to have a poorly written playbook that is not idempotent.
  • Minimal Learning Required: Playbooks use descriptive language based on YAML and Jinja templates.

Important Ansible Terminology

Ansible Controller Machine

The controller machine is the machine where Ansible is installed and it is responsible to run automation within the organization. You can manage your IT infrastructure from Control Machine. You may have multiple control machines in your environment.

Ansible Inventory

Ansible inventory is the initialization file that has details of the servers you are expected to manage . In simple words list of servers to be managed is the inventory. contains information about the Servers you are managing.

Ansible Playbook

This is the main file where automation is defined through tasks using the YAML format. For creating automation playbooks are created.

Ansible Task

A block of instructions to fulfill a specific task for example like restarting any specific services on all nodes in inventory. You can include many tasks in an ansible playbook as per your requirement.

Ansible Modules

Ansible has a number of built-in modules to achieve specific goals and even you can create your own module.

Ansible Role

The role consists of pre-defined methods of organizing playbooks and even other files to facilitate sharing and they are reusable.

Ansible Play

In simple words, you can say the execution of a playbook is called a play. It adopts the starts to finish approach and executes them sequencially.

Main Advantages of Ansible

It’s Simple

Ansible uses general syntax written in YAML called playbooks YAML is a human-readable data serialization language. It is absolutely simple therefore no special coding skills are required.

Those who do not know what is Ansible in your company can very easily read an ansible playbook and easily understand what is happening. It always executes tasks in order. And most important is that it is really easy to install. Let’s deep dive into how to install ansible on rhel7.   

It’s Agentless

IT does not need any agents needs to be installed on the servers which you want to manage. Ansible is agentless means there are no agents or additional firewall ports that need to install on the client systems or hosts which you want to automate.

You do not have to set up a management infrastructure that includes managing your entire systems, network, and storage. It reduces the amount of effort required for your team to start automating immediately.

It is Powerful & very Flexible

Ansible has powerful features that may enable you to model even the most complex IT workflows.

Ansible supports hundreds of inbuild modules to manage. Ansible’s capabilities allow you to orchestrate the entire application environment regardless of where it is deployed.

It’s very Efficient

No extra software on your servers means more resources for your applications Also since Ansible modules work via JSON, Ansible is extensible with modules written in a programming language you already know Ansible introduces modules as basic building blocks for your software So, you can even customize it as per your needs.

For example: If you have an existing message sending module that sends messages in plain text, and you want to send images too, you can add image sending features on top of it.

how to install ansible on rhel7

 

Why Ansible?

The main reasons to choose the only ansible as below.

  • It is a free and open-source software tool.
  • It is agentless so no need for agent installation and management.
  • Python/YAML-based.
  • Highly Flexible.
  • Configuration Management System
  • A large number of inbuild ready-to-use modules.
  • Custom Modules can be incorporated
  • Rollback is possible in case of error.
  • Simple and Human Readable.
  • It documents itself

So now we have seen enough about ansible. Ansible can be a turning and rewarding point in your automation journey. So let us come back to our main topic how to install ansible on rhel7. Check for more details on how ansible works?

We have already seen that you have already set up all RedHat linux repo either on an organizational basis or directly using Redhat yum online. The first thing to check the availability of an ansible package in your yum repository before installing it.

How to Check Ansible Package Availability in RHEL7

# yum --enablerepo=* list ansible*
Available Packages
ansible.noarch                             2.4.2.0-2.el7                                         ondemand
ansible-doc.noarch                     2.4.2.0-2.el7                                         ondemand

The above command will display the availability of an ansible package in your yum repo. Please refer to the output above you can easily found what version of ansible is available.

How to Install Ansible On RHEL7

Now it is my turn to install it. Please refer to the below example once it will ask you have to just enter y and it gets installed with dependencies as well.

# yum --enablerepo=* install ansible*
============================================================
Package                          Arch              Version                     Repository                  Size
Installing:
ansible                           noarch           2.4.2.0-2.el7            ondemand                   7.6 M
ansible-doc                   noarch           2.4.2.0-2.el7            ondemand                   763 k
Installing for dependencies:
python-babel                noarch          0.9.6-8.el7                distro                            1.4 M
python-httplib2           noarch          0.9.2-1.el7                 ondemand                   115 k
python-jinja2               noarch          2.7.2-2.el7cp             ondemand                   516 k
python-markupsafe    x86_64        0.11-10.el7                distro                             25 k
python-passlib            noarch          1.6.5-2.el7                 ondemand                   488 k
python2-jmespath      noarch          0.9.0-el7ae               ondemand                   39 k
sshpass                          x86_64        1.06-.el7                    ondemand                   21 k
Transaction Summary
============================================================
Install  2 Packages (+7 Dependent packages)
Total download size: 11 M
Installed size: 52 M
Is this ok [y/d/N]: y
Installed:
ansible.noarch 0:2.4.2.0-2.el7               ansible-doc.noarch 0:2.4.2.0-2.el7
Dependency Installed:
python-babel.noarch 0:0.9.6-8.el7    python-httplib2.noarch 0:0.9.2-1.el7     
python-jinja2.noarch 0:2.7.2-2.el7cp  python-markupsafe.x86_64 0:0.11-10.el7
python-passlib.noarch 0:1.6.5-2.el7  python2-jmespath.noarch 0:0.9.0-4.el7ae  
sshpass.x86_64 0:1.06-2.el7
#

You might have seen above that all the dependencies also automatically installed. That`s it now we have successfully installed ansible on rhel7.

How to Check Ansible Version?

You can check the ansible version in linux using the ansible –version command. Please find the below example for reference purposes.

# ansible --version
ansible 2.4.2.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/user/.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, May 31 2018, 09:41:32) [GCC 4.8.5 20150623 
(Red Hat 4.8.5-28)]
#

Alternatively, you can use the rpm command in linux also to check the ansible version. These two are the easiest method for how to check ansible in redhat enterprise linux.

# rpm –qa |grep ansible
ansible.noarch 0:2.4.2.0-2.el7
ansible-doc.noarch 0:2.4.2.0-2.el7
#

Conclusion

That`s it about how to install ansible on rhel7. These two are the easiest method for how to check ansible in redhat enterprise linux.

Please share in form of comments if you are using any other method either for installing ansible for rhel7 or how to find ansible version in rhel7.

Another resource, if you are interested to learn more, is as below.

Why Find Command In Linux Had Been So Popular Till Now?

40 Important Basic Linux Commands For Beginners With Examples

Linux Change Password

How to Remove Veritas File System

How to Increase File System in VXVM

How to Install Ansible on Ubuntu