httpd_sys_content_t,執行命令 restorecon 將 /webtest 目錄及其次目錄的 fcontext 還原成預設值。
ceuser@deyu:~/ansible_pb$ vi sefcontext.yml
ceuser@deyu:~/ansible_pb$ cat sefcontext.yml
---
- name: Web test
hosts: dev
tasks:
- name: Install the latest version of policycore.....
ansible.builtin.dnf:
name: policycore......
state: latest
- name: Allow apache to modify files in /webtest
community.general.sefcontext:
target: '/webtest(/.*)?'
setype: httpd_sys_content_t
state: present
- name: Apply new SELinux file context to filesystem
ansible.builtin.command: restorecon -irv /webtest
ceuser@deyu:~/ansible_pb$ ansible-playbook sefcontext.yml PLAY [Web test] **************************************************************** TASK [Gathering Facts] ********************************************************* ok: [kvm11] TASK [Install the latest version of policycore.....] *************************** changed: [kvm11] TASK [Allow apache to modify files in /webtest] ******************************** changed: [kvm11] TASK [Apply new SELinux file context to filesystem] **************************** changed: [kvm11] PLAY RECAP ********************************************************************* kvm11 : ok=4 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
httpd_sys_content_t。
ceuser@deyu:~/ansible_pb$ ansible dev -m shell -a "ls -Z /webtest" kvm11 | CHANGED | rc=0 >> system_u:object_r:httpd_sys_content_t:s0 index.html
ceuser@deyu:~/ansible_pb$ curl http://kvm11/webtest/ WebTest on kvm11