Making a Centos machine ready for Ansible installation.
Login to the Centos7 VM and add the package repository with command,
$ sudo yum install –y epel-release
$ sudo yum install –y ansible
For installing ansible on RHEL8.
$ sudo dnf -y install python3-pip
$ sudo pip3 install --upgrade pip
$ sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
$ sudo dnf install --enablerepo epel-playground ansible
Install Ansible using Python package repository
$ sudo yum install -y gcc … install compiler repository update
$ sudo yum install -y python-setuptools
$ sudo easy_install pip … python package Manager
$ sudo yum install –y python-devel … install python dev library
$ sudo pip install ansible …. Download code, compile and install the package.
Ansible works in push mode, so we have to allow Ansible server to connect over SSH to other Linux machines.
In order to have your Ansible Controller server talk to remote nodes over SSH, make sure to add the public key pair to the remote server. This will enable the user on Ansible server to login to remote server using SSH protocol.
If you face difficulty authenticating, try removing the entry for that remote server from the ‘known_hosts’ file on the Ansible server. This can be done by running below command,
$ ssh-keygen -f "/root/.ssh/known_hosts" -R <remote server name / IPaddress>
Installing Ansible on Ubuntu Linux:
To install Ansible on Ubuntu server, use below commands. The easiest way to install Ansible on a Ubuntu system is to use the official apt package.
$ sudo apt-add-repository -y ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install -y ansible
Comments