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

时间:2017-05-30 05:13:23

标签: python ubuntu ansible selinux

剧本:

---
- 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时,无法在系统上安装。

1 个答案:

答案 0 :(得分:5)

将您的任务更改为此。您需要先安装python-selinux。的 Ansible 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