如何使用Ansible在Ubuntu上禁用SELinux?

clo*_*oud 3 python ubuntu selinux ansible

剧本:

---
- name: Update repositories cache
  apt: update_cache=yes

- name: Install build-essential
  apt: name=build-essential state=present

- name: Disable SELinux
  selinux: state=disabled
Run Code Online (Sandbox Code Playgroud)

结果:

TASK [common : Update repositories cache] ***************************************************************************************************************************************************************************************************
changed: [server]

TASK [common : Install build-essential] *****************************************************************************************************************************************************************************************************
ok: [server]

TASK [common : Disable SELinux] *************************************************************************************************************************************************************************************************************
fatal: [server]: FAILED! => {"changed": false, "failed": true, "msg": "libselinux-python required for this module"}
Run Code Online (Sandbox Code Playgroud)

我试图找到libselinux-python但似乎不存在.当我尝试其他一些库时python-selinux,无法在系统上安装.

Sah*_*ati 6

将您的任务更改为此.您需要先安装python-selinux.Ansible intro install requirements

您应该将此添加到您的任务中.

- name: Install the libselinux-python package
  apt: name=python-selinux state=present
Run Code Online (Sandbox Code Playgroud)

整个任务都是这样的.

---
- name: Update repositories cache
  apt: update_cache=yes

- name: Install build-essential
  apt: name=build-essential state=present

- name: Install the libselinux-python package
  apt: name=python-selinux state=present

- name: Disable SELinux
  selinux: state=disabled
Run Code Online (Sandbox Code Playgroud)