I am trying to create one ansible playbook that will copy the rpm file for libselinux-python-2.5-15.el7.x86_64.rpm on the remote machine and then install it so that the rest of the tasks which requires this library can be executed
Hey, Mohammed! It’s telling you that, in order to install that RPM (libselinux-python-2.5-15.el7.x86_64.rpm), a dependent RPM (libselinux-python) ALSO needs to be installed. Is there a reason that you can’t just do an installation of libselinux-python via ansible.builtin.yum? Is the system not connected to software repositories? Copying individual RPMs to the system seems like a terribly convoluted way of doing things. Is this system air-gapped or something?
You can create repositories using the reposync functionality of yum. Have a look at https://www.redhat.com/sysadmin/how-mirror-repository for details. You can mirror the repos on one machine, then copy the repo to a thumb drive and attach to the air-gapped network if that doesn’t violate any security policies. I’ll leave that up to you. But you very well may want to mirror the RHEL 7 repos and make them available on your air-gapped network, it’ll make your life a lot easier.