---
- name: "check setenforce command"
  command: command -v setenforce
  register: enforce
  ignore_errors: yes
  failed_when: false

- name: "do setenforce 0"
  command: setenforce 0
  when: enforce.rc == 0
  ignore_errors: yes

- name: "disable selinux"
  replace:
     path: "/etc/selinux/config"
     regexp: "SELINUX=enforcing"
     replace: "SELINUX=permissive"
  when: enforce.rc == 0
