# Cannot use lineinfile as it complains about python-selinux missing

**URL:** <https://forum.ansible.com/t/cannot-use-lineinfile-as-it-complains-about-python-selinux-missing/13309>\
**Category:** Ansible Project\
**Created:** [August 14, 2013, 10:53pm UTC](https://forum.ansible.com/t/cannot-use-lineinfile-as-it-complains-about-python-selinux-missing/13309 "2013-08-14T22:53:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kavin\_Kankeshwar](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kavin\_Kankeshwar](https://forum.ansible.com/u/Kavin_Kankeshwar)\
**Post date:** [August 14, 2013, 10:53pm UTC](https://forum.ansible.com/t/cannot-use-lineinfile-as-it-complains-about-python-selinux-missing/13309/1 "2013-08-14T22:53:53Z")

</div>

Hi,

I am trying to change a file on remote machine, I get the following error. Selinux is set to be permissive.

msg: Aborting, target uses selinux but python bindings (python-selinux) aren’t installed!

---

<div class="post-metadata">

**Author:** ![kahlil.hodgson](https://avatars.discourse-cdn.com/v4/letter/k/b9bd4f/32.png) [@kahlil.hodgson](https://forum.ansible.com/u/kahlil.hodgson)\
**Post date:** [August 14, 2013, 11:13pm UTC](https://forum.ansible.com/t/cannot-use-lineinfile-as-it-complains-about-python-selinux-missing/13309/2 "2013-08-14T23:13:50Z")

</div>

You still need to install the appropriate python-selinux package on  
the target machine even though SELinux is set to permissive. The  
permissive mode still generates warnings on policy violations, it just  
doesn't block whatever triggered it,  
so files on your system still need their security contexts set. If you  
want to avoid this you will have to disable selinux, but I do not  
advise that -- better to install the appropriate package.

On CentOS/RHEL the pacakge you need is libselinux-python. Not sure  
about other OS's

K

Kahlil (Kal) Hodgson GPG: C9A02289  
Head of Technology (m) +61 (0) 4 2573 0382  
DealMax Pty Ltd (w) +61 (0) 3 9008 5281

Suite 1415  
401 Docklands Drive  
Docklands VIC 3008 Australia

"All parts should go together without forcing. You must remember that  
the parts you are reassembling were disassembled by you. Therefore,  
if you can't get them together again, there must be a reason. By all  
means, do not use a hammer." -- IBM maintenance manual, 1925

---

<div class="post-metadata">

**Author:** ![Kavin\_Kankeshwar](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kavin\_Kankeshwar](https://forum.ansible.com/u/Kavin_Kankeshwar)\
**Post date:** [August 15, 2013, 2:57am UTC](https://forum.ansible.com/t/cannot-use-lineinfile-as-it-complains-about-python-selinux-missing/13309/3 "2013-08-15T02:57:27Z")

</div>

Thank you very much!

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 15, 2013, 12:29pm UTC](https://forum.ansible.com/t/cannot-use-lineinfile-as-it-complains-about-python-selinux-missing/13309/4 "2013-08-15T12:29:20Z")

</div>

Slight correction:

“On CentOS/RHEL the pacakge you need is libselinux-python. Not sure  
about other OS’s”

You will need this package (on any platform) only if SELinux is enabled.

This is desired and expected behavior.
