【问题标题】:How to disable SELinux on Ubuntu with Ansible?如何使用 Ansible 在 Ubuntu 上禁用 SELinux?
【发布时间】:2023-03-26 00:00:01
【问题描述】:

剧本:

---
- 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 ubuntu ansible selinux


    【解决方案1】:

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

    【讨论】:

    • 我试过了,但它说:fatal: [server]: FAILED! => {"changed": false, "failed": true, "msg": "No package matching 'libselinux-python' is available"}.
    • @cloud_cloud 希望这会有所帮助,看看packages.ubuntu.com/source/trusty-updates/libselinux
    • 非常感谢。但这次:fatal: [rancherserver]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to 192.168.33.111 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_T58IMt/ansible_module _selinux.py\", line 226, in <module>.
    • @cloud_cloud 我认为这与您当前的帖子无关。您上面提到的问题现已修复。
    • 也许,我也这么认为。顺便说一句,我使用的发行版是bento/ubuntu-16.04。一个流浪的官方中心版本。
    猜你喜欢
    • 2021-06-05
    • 1970-01-01
    • 2015-08-10
    • 1970-01-01
    • 1970-01-01
    • 2020-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多