Ansible offline installation on Redhat Linux 8.1 with all dependencies

3.6k views Asked by At

I’m installing ansible on offline red hat Linux machine 8.1 with the help of rpm’s but they’re failing and requires more dependencies. Is there any way or method, from using which I’m able to install ansible on it

2

There are 2 answers

0
gary lopez On

In other rhel machine, with internet and the ansible repository configured, install yumdownloader with

yum install yum-utils

Download ansible with its dependencies:

yumdownloader ansible --destdir /tmp/ansible_rpm --resolve

Note: change /tmp/ansible_rpm by a directory in the rhel machine.

0
Jack Hamilton On

Adding on to this answer by @gary-lopez:

On other connected RHEL box to obtain Ansible:

sudo subscription-manager repos --enable ansible-2.9-for-rhel-8-x86_64-rpms
sudo yumdownloader ansible --destdir /tmp/ansible_rpm --resolve

Repeat below for any additional dependencies you come across. These are the two dependencies my offline install asked for:

sudo yumdownloader python3-jinja2 --destdir /tmp/ansible_rpm --resolve
sudo yumdownloader python3-pyyaml --destdir /tmp/ansible_rpm --resolve

Then package it up into a gzipped tar-ball for transport to the offline machine:

cd /tmp
sudo yum install tar -y
tar zcvf ansible_tar.tgz /tmp/ansible_rpm

Transfer the tar gzipped file to the disconnected/offline machine via some method (USB, etc). For example, if it's at least accessible to your connected machine, then you could secure copy to it:

scp ansible_tar.tgz <user>@<disconnected-target>:/tmp

On disconnected/offline target:

cd /tmp
tar zxvf ansible_rpm.tgz
cd ansible_rpm
yum localinstall python3-jinja2-2.10.1-2.el8_0.noarch.rpm
yum localinstall python3-pyyaml-3.12-12.el8.x86_64.rpm

Finally, use yum localinstall ansible-2.9.24-1.el8ae.noarch.rpm to install Ansible rpm. But if for some reason there's a final dependency you REALLY need to by-pass that you do not want to install, here's the work-around.

In my example, our customer would not allow sshpass to be installed no matter what (because reasons). Use rpm (instead of yum localinstall to override need for dependency sshpass because yum localinstall --nobest --skip-broken skips ansible install due to missing sshpass dependency.

rpm -i --nodeps ansible-2.9.24-1.el8ae.noarch.rpm