FlatKey.selinux
ansible-selinux-role
允许您配置 SELinux。
配置选项:
- 策略
- 状态
- 布尔值
- 端口
- 文件上下文
要求
仅在 RHEL 7 和 CentOS 7 上测试过。
Ansible 2.0 或更高版本
角色变量
不需要使用所有这些变量块,您可以仅使用您真正需要的配置选项。
以下变量用于配置 SELinux 策略和状态:
selinux_config:(可选,默认值:/etc/selinux/config)
selinux_policy:(可选,默认值:targeted)
selinux_state:(可选,仅值:enforcing|permissive|disabled,默认值:enforcing)
以下变量用于切换 SELinux 布尔值:
selinux_boolean:
name_of_selinux_boolean:
state:(可选,仅值:yes|no,默认值:yes)
persistent:(可选,仅值:yes|no,默认值:yes)
以下变量用于配置 SELinux 端口:
selinux_ports:
name_of_selinux_type:
ports:(必需,端口或端口范围)
protocol:(可选,仅值:tcp|udp,默认值:tcp)
state:(可选,仅值:present|absent,默认值:present)
以下变量用于配置 SELinux 文件上下文:
selinux_fcontext:
name_of_selinux_fcontext:(为了在您的剧本中更好的文档化,您自己的选择)
file_spec:(必需,常规表达式以描述受影响的文件)
setype:(必需,现有的 selinux 类型,用于标记您的 file_spec 的文件)
ftype:(可选,仅值:a|b|c|d|f|l|p|s - 请参阅手册页 semanage-fcontext 以了解文件类型,默认值:a - 所有文件)
state:(可选,仅值:present|absent,默认值:present)
示例剧本
- hosts: server
become: yes
become_user: root
become_method: su
roles:
- { role: ansible-selinux-role }
vars:
selinux_policy: "targeted"
selinux_state: "enforcing"
selinux_boolean:
antivirus_can_scan_system:
state: yes
persistent: yes
httpd_can_sendmail:
state: yes
persistent: yes
selinux_ports:
ssh_port_t:
ports: 2222
protocol: tcp
state: present
http_port_t:
ports: 9000-9004
protocol: tcp
state: present
selinux_fcontext:
vcloud_documentroot:
file_spec: "/srv/www(.*)"
setype: httpd_sys_rw_content_t
ftype: a
state: present
许可证
MIT