2017-05-30 194 views
1

的劇本:如何使用Ansible在Ubuntu上禁用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時,不能在系統上安裝。

回答

3

將您的任務更改爲此。您需要先安裝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 
+0

我試過,但它說:'致命的:[服務器]:失敗! => {「changed」:false,「failed」:true,「msg」:「沒有與'libselinux-python'匹配的包'}'。 –

+0

@cloud_cloud希望這會有幫助看看https://packages.ubuntu.com/source/trusty-updates/libselinux –

+0

非常感謝。但是這一次:'致命的:[rancherserver]:失敗! => {「changed」:false,「failed」:true,「module_stderr」:「與192.168.33.111關閉的共享連接。\ r \ n」,「module_stdout」:「Traceback(最近一次調用最後一次):\ r \ n File \「/ tmp/ansible_T58IMt/ansible_module _selinux.py \」,第226行,在'。 –