# How to copy rpm file from local to remote if selinux is enabled

**URL:** <https://forum.ansible.com/t/how-to-copy-rpm-file-from-local-to-remote-if-selinux-is-enabled/4632>\
**Category:** Get Help\
**Tags:** playbook, awx, collections, ansible-core\
**Created:** [March 29, 2024, 12:57pm UTC](https://forum.ansible.com/t/how-to-copy-rpm-file-from-local-to-remote-if-selinux-is-enabled/4632 "2024-03-29T12:57:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![husnain\_taja](https://avatars.discourse-cdn.com/v4/letter/h/f04885/32.png) [@husnain\_taja](https://forum.ansible.com/u/husnain_taja)\
**Post date:** [March 29, 2024, 12:57pm UTC](https://forum.ansible.com/t/how-to-copy-rpm-file-from-local-to-remote-if-selinux-is-enabled/4632/1 "2024-03-29T12:57:55Z")

</div>

Hi,

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

```auto
- name: Copy SELinux library
  copy:
    src: /git/telegraf/libselinux-python-2.5-15.el7.x86_64.rpm
    dest: /tmp/
  tags: packages

- name: Install SELinux library
  yum:
    name: /tmp/libselinux-python-2.5-15.el7.x86_64.rpm
    state: present
    disable_gpg_check: yes
    disablerepo: local
  when: selinux_lib_installed.rc != 0
  tags: package

```

s

The issue is that selinux is enabled in permissive mode on the remote server.So I am getting this error on copying the rpm itself.

TASK [telegraf : Copy SELinux library] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

fatal: [ilgss0979]: FAILED! =\> {“changed”: false, “checksum”: “b19890139b8233801eca80a133b1ae78257d9aa4”, “failed\_when\_result”: true, “msg”: “Aborting, target uses selinux but python bindings (libselinux-python) aren’t installed!”}

So how can I fix this

---

<div class="post-metadata">

**Author:** ![ThomasCameron512](https://avatars.discourse-cdn.com/v4/letter/t/ea666f/32.png) [@ThomasCameron512](https://forum.ansible.com/u/ThomasCameron512)\
**Post date:** [March 29, 2024, 3:56pm UTC](https://forum.ansible.com/t/how-to-copy-rpm-file-from-local-to-remote-if-selinux-is-enabled/4632/2 "2024-03-29T15:56:58Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![husnain\_taja](https://avatars.discourse-cdn.com/v4/letter/h/f04885/32.png) [@husnain\_taja](https://forum.ansible.com/u/husnain_taja)\
**Post date:** [March 30, 2024, 1:01am UTC](https://forum.ansible.com/t/how-to-copy-rpm-file-from-local-to-remote-if-selinux-is-enabled/4632/3 "2024-03-30T01:01:11Z")

</div>

Hi @ThomasCameron512 ,

Thanks for the quick response.

Yes.The system is air-gapped.We don’t have internet connectivity to install packages via yum.

---

<div class="post-metadata">

**Author:** ![ThomasCameron512](https://avatars.discourse-cdn.com/v4/letter/t/ea666f/32.png) [@ThomasCameron512](https://forum.ansible.com/u/ThomasCameron512)\
**Post date:** [April 1, 2024, 10:33pm UTC](https://forum.ansible.com/t/how-to-copy-rpm-file-from-local-to-remote-if-selinux-is-enabled/4632/4 "2024-04-01T22:33:53Z")

</div>

You can create repositories using the reposync functionality of yum. Have a look at [https://www.redhat.com/sysadmin/how-mirror-repository](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.
