Introduction
As Ansible is agentless, unlike other configuration management platforms, it only requires a master node installation. Ansible is also particularly light due to its lack of daemons, database reliance, and keep-on-running services. Ansible uses Secure Shell (SSH) and WinRM to manage its host clients. Installing Ansible is a fairly straightforward process and in this article we will quickly demonstrate how to install it on a Centos 7 system using the yum package manager.Prerequisites:
In this respect, Ansible is awesome. For a Linux package installation, all you need is Python 2 (version 2.6 or higher) or Python 3 (version 3.5 or higher). For source installation, we may need the development suite, such as the build-essential package for the Debian family, or the Development Tools group package for the Red Hat family. Most package managers of Linux operating systems willautomatically download the appropriate Python version and its dependencies when asked to install Ansible.
Ansible installation on Centos 7:
If you are using Yellowdog Updater, Modified (Yum), you will have an extra step, since Ansible is not located in the default RHEL repositories. As you may have experienced when installing tools in the past, the Extra Package for Enterprise Linux (EPEL) is often required to be installed before you can use the package manager to install the tools. This is a very straightforward step. We first need to download the epel-release rpm file from the Fedora Project website: http:/ / fedoraproject. org/ wiki/ EPEL. We then need to install it using rpm as follows:rpm -i epel-release-latest-7.noarch.rpm
or
yum install epel-release -y
We can verify that the EPEL repository is now available on the system:
[root@lab ~]# yum repolist epel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.nbrc.ac.in
* epel: d2lzkl7pfhq30w.cloudfront.net
* extras: mirror.nbrc.ac.in
* nux-dextop: mirror.li.nux.ro
* updates: mirror.nbrc.ac.in
repo id repo name status
*epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 12,909
repolist: 12,909
[root@lab ~]#
Just like installing any other package using Yum, we will use the yum install command following by the package name (Ansible in this case).
[root@lab ~]# yum install ansible -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.nbrc.ac.in
* epel: d2lzkl7pfhq30w.cloudfront.net
* extras: mirror.nbrc.ac.in
* nux-dextop: mirror.li.nux.ro
* updates: mirror.nbrc.ac.in
Resolving Dependencies
--> Running transaction check
---> Package ansible.noarch 0:2.7.8-1.el7 will be installed
--> Processing Dependency: python-crypto for package: ansible-2.7.8-1.el7.noarch
--> Processing Dependency: python-httplib2 for package: ansible-2.7.8-1.el7.noarch
--> Processing Dependency: python-keyczar for package: ansible-2.7.8-1.el7.noarch
--> Processing Dependency: python-paramiko for package: ansible-2.7.8-1.el7.noarch
--> Processing Dependency: python2-jmespath for package: ansible-2.7.8-1.el7.noarch
--> Processing Dependency: sshpass for package: ansible-2.7.8-1.el7.noarch
--> Running transaction check
---> Package python-httplib2.noarch 0:0.9.2-1.el7 will be installed
---> Package python-keyczar.noarch 0:0.71c-2.el7 will be installed
---> Package python-paramiko.noarch 0:2.1.1-9.el7 will be installed
--> Processing Dependency: python-cryptography for package: python-paramiko-2.1.1-9.el7.noarch
---> Package python2-crypto.x86_64 0:2.6.1-15.el7 will be installed
--> Processing Dependency: libtomcrypt.so.0()(64bit) for package: python2-crypto-2.6.1-15.el7.x86_64
---> Package python2-jmespath.noarch 0:0.9.0-3.el7 will be installed
---> Package sshpass.x86_64 0:1.06-2.el7 will be installed
--> Running transaction check
---> Package libtomcrypt.x86_64 0:1.17-26.el7 will be installed
--> Processing Dependency: libtommath >= 0.42.0 for package: libtomcrypt-1.17-26.el7.x86_64
--> Processing Dependency: libtommath.so.0()(64bit) for package: libtomcrypt-1.17-26.el7.x86_64
---> Package python2-cryptography.x86_64 0:1.7.2-2.el7 will be installed
--> Processing Dependency: python-idna >= 2.0 for package: python2-cryptography-1.7.2-2.el7.x86_64
--> Processing Dependency: python-cffi >= 1.4.1 for package: python2-cryptography-1.7.2-2.el7.x86_64
--> Processing Dependency: python-enum34 for package: python2-cryptography-1.7.2-2.el7.x86_64
--> Running transaction check
---> Package libtommath.x86_64 0:0.42.0-6.el7 will be installed
---> Package python-cffi.x86_64 0:1.6.0-5.el7 will be installed
--> Processing Dependency: python-pycparser for package: python-cffi-1.6.0-5.el7.x86_64
---> Package python-enum34.noarch 0:1.0.4-1.el7 will be installed
---> Package python-idna.noarch 0:2.4-1.el7 will be installed
--> Running transaction check
---> Package python-pycparser.noarch 0:2.14-1.el7 will be installed
--> Processing Dependency: python-ply for package: python-pycparser-2.14-1.el7.noarch
--> Running transaction check
---> Package python-ply.noarch 0:3.4-11.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================================================================================
Package Arch Version Repository Size
==========================================================================================================================================================================
Installing:
ansible noarch 2.7.8-1.el7 epel 11 M
Installing for dependencies:
libtomcrypt x86_64 1.17-26.el7 extras 224 k
libtommath x86_64 0.42.0-6.el7 extras 36 k
python-cffi x86_64 1.6.0-5.el7 base 218 k
python-enum34 noarch 1.0.4-1.el7 base 52 k
python-httplib2 noarch 0.9.2-1.el7 extras 115 k
python-idna noarch 2.4-1.el7 base 94 k
python-keyczar noarch 0.71c-2.el7 epel 218 k
python-paramiko noarch 2.1.1-9.el7 updates 269 k
python-ply noarch 3.4-11.el7 base 123 k
python-pycparser noarch 2.14-1.el7 base 104 k
python2-crypto x86_64 2.6.1-15.el7 extras 477 k
python2-cryptography x86_64 1.7.2-2.el7 base 502 k
python2-jmespath noarch 0.9.0-3.el7 extras 39 k
sshpass x86_64 1.06-2.el7 extras 21 k
Transaction Summary
==========================================================================================================================================================================
Install 1 Package (+14 Dependent packages)
Total download size: 14 M
Installed size: 71 M
Downloading packages:
(1/15): libtommath-0.42.0-6.el7.x86_64.rpm | 36 kB 00:00:00
(2/15): python-enum34-1.0.4-1.el7.noarch.rpm | 52 kB 00:00:00
(3/15): libtomcrypt-1.17-26.el7.x86_64.rpm | 224 kB 00:00:00
(4/15): python-cffi-1.6.0-5.el7.x86_64.rpm | 218 kB 00:00:00
(5/15): python-httplib2-0.9.2-1.el7.noarch.rpm | 115 kB 00:00:00
(6/15): python-idna-2.4-1.el7.noarch.rpm | 94 kB 00:00:00
(7/15): ansible-2.7.8-1.el7.noarch.rpm | 11 MB 00:00:00
(8/15): python-keyczar-0.71c-2.el7.noarch.rpm | 218 kB 00:00:00
(9/15): python-pycparser-2.14-1.el7.noarch.rpm | 104 kB 00:00:00
(10/15): python-ply-3.4-11.el7.noarch.rpm | 123 kB 00:00:00
(11/15): python-paramiko-2.1.1-9.el7.noarch.rpm | 269 kB 00:00:00
(12/15): python2-crypto-2.6.1-15.el7.x86_64.rpm | 477 kB 00:00:00
(13/15): python2-jmespath-0.9.0-3.el7.noarch.rpm | 39 kB 00:00:00
(14/15): sshpass-1.06-2.el7.x86_64.rpm | 21 kB 00:00:00
(15/15): python2-cryptography-1.7.2-2.el7.x86_64.rpm | 502 kB 00:00:00
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 10 MB/s | 14 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python-enum34-1.0.4-1.el7.noarch 1/15
Installing : python-httplib2-0.9.2-1.el7.noarch 2/15
Installing : sshpass-1.06-2.el7.x86_64 3/15
Installing : libtommath-0.42.0-6.el7.x86_64 4/15
Installing : libtomcrypt-1.17-26.el7.x86_64 5/15
Installing : python2-crypto-2.6.1-15.el7.x86_64 6/15
Installing : python-keyczar-0.71c-2.el7.noarch 7/15
Installing : python2-jmespath-0.9.0-3.el7.noarch 8/15
Installing : python-ply-3.4-11.el7.noarch 9/15
Installing : python-pycparser-2.14-1.el7.noarch 10/15
Installing : python-cffi-1.6.0-5.el7.x86_64 11/15
Installing : python-idna-2.4-1.el7.noarch 12/15
Installing : python2-cryptography-1.7.2-2.el7.x86_64 13/15
Installing : python-paramiko-2.1.1-9.el7.noarch 14/15
Installing : ansible-2.7.8-1.el7.noarch 15/15
Verifying : python-keyczar-0.71c-2.el7.noarch 1/15
Verifying : python-idna-2.4-1.el7.noarch 2/15
Verifying : python-ply-3.4-11.el7.noarch 3/15
Verifying : ansible-2.7.8-1.el7.noarch 4/15
Verifying : python-paramiko-2.1.1-9.el7.noarch 5/15
Verifying : python2-jmespath-0.9.0-3.el7.noarch 6/15
Verifying : python2-crypto-2.6.1-15.el7.x86_64 7/15
Verifying : libtomcrypt-1.17-26.el7.x86_64 8/15
Verifying : python-cffi-1.6.0-5.el7.x86_64 9/15
Verifying : libtommath-0.42.0-6.el7.x86_64 10/15
Verifying : sshpass-1.06-2.el7.x86_64 11/15
Verifying : python-httplib2-0.9.2-1.el7.noarch 12/15
Verifying : python-enum34-1.0.4-1.el7.noarch 13/15
Verifying : python-pycparser-2.14-1.el7.noarch 14/15
Verifying : python2-cryptography-1.7.2-2.el7.x86_64 15/15
Installed:
ansible.noarch 0:2.7.8-1.el7
Dependency Installed:
libtomcrypt.x86_64 0:1.17-26.el7 libtommath.x86_64 0:0.42.0-6.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-keyczar.noarch 0:0.71c-2.el7 python-paramiko.noarch 0:2.1.1-9.el7
python-ply.noarch 0:3.4-11.el7 python-pycparser.noarch 0:2.14-1.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 sshpass.x86_64 0:1.06-2.el7
Complete!
[root@lab ~]#
Now to validate the success of our installation we can check the ansible version installed on the system using the following command:
[root@lab ~]# ansible --version
ansible 2.7.8
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 = /bin/ansible
python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
[root@lab ~]#