ansible.posix.selinux 模块 – 更改 SELinux 的策略和状态
注意
此模块是 ansible.posix 集合 (版本 1.6.2) 的一部分。
如果您使用的是 ansible
包,则可能已经安装了此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用: ansible-galaxy collection install ansible.posix
。您需要其他要求才能使用此模块,请参阅 要求 获取详细信息。
要在剧本中使用它,请指定: ansible.posix.selinux
。
ansible.posix 1.0.0 中的新增功能
概要
配置 SELinux 模式和策略。
使用后可能需要重新启动。
Ansible 不会发出此重新启动请求,但会告知您何时需要重新启动。
要求
在执行此模块的主机上需要以下要求。
libselinux-python
参数
参数 |
注释 |
---|---|
SELinux 配置文件的路径(如果非标准)。 默认值: |
|
要使用的 SELinux 策略的名称(例如 |
|
SELinux 模式。 选项
|
|
如果设置为 目标系统上必须存在 选项
|
示例
- name: Enable SELinux
ansible.posix.selinux:
policy: targeted
state: enforcing
- name: Put SELinux in permissive mode, logging actions that would be blocked.
ansible.posix.selinux:
policy: targeted
state: permissive
- name: Disable SELinux
ansible.posix.selinux:
state: disabled
返回值
常见的返回值已在 此处 记录,以下是此模块特有的字段
键 |
描述 |
---|---|
SELinux 配置文件的路径。 返回:始终 示例: |
|
描述所做更改的消息。 返回:始终 示例: |
|
SELinux 策略的名称。 返回:始终 示例: |
|
更改是否需要重新启动才能生效。 返回:始终 示例: |
|
SELinux 模式。 返回:始终 示例: |