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

How to disable SELinux on Ubuntu with 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

结果:

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"}

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

把你的任务改成这个。您需要先安装 python-selinuxAnsible intro install requirements

您应该将其添加到您的任务中。

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

整个任务就是这样。

---
- 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