selinux.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ---
  2. - name: Selinux... selinux targets
  3. sefcontext:
  4. target: "{{ item }}"
  5. setype: httpd_sys_rw_content_t
  6. state: present
  7. register: filecontext
  8. with_items:
  9. - '{{ nc_data_dir }}(/.*)?'
  10. - '{{ http_webroot }}/nextcloud/config(/.*)?'
  11. - '{{ http_webroot }}/nextcloud/apps(/.*)?'
  12. - '{{ http_webroot }}/nextcloud/custom_apps(/.*)?'
  13. - '{{ http_webroot }}/nextcloud/assets(/.*)?'
  14. - '{{ http_webroot }}/nextcloud/.htaccess'
  15. - '{{ http_webroot }}/nextcloud/.user.ini'
  16. - '{{ http_webroot }}/nextcloud/3rdparty/aws/aws-sdk-php/src/data/logs(/.*)?'
  17. - name: Selinux... enable seboolean settings
  18. seboolean:
  19. name: "{{ item }}"
  20. state: yes
  21. persistent: yes
  22. with_items:
  23. - httpd_unified
  24. - httpd_graceful_shutdown
  25. - httpd_can_network_relay
  26. - httpd_can_network_connect
  27. - httpd_can_network_connect_db
  28. - daemons_enable_cluster_mode
  29. - httpd_use_fusefs
  30. - httpd_use_cifs
  31. - httpd_use_gpg
  32. - httpd_use_nfs
  33. - httpd_execmem
  34. - httpd_can_sendmail
  35. ###- name: Selinux... enable seboolean settings
  36. ### command: semodule -i {{ role_path }}/files/{{ item }}
  37. ### loop:
  38. ### - httpd-to-php-fpm.pp
  39. ### - httpd-to-redis-socket.pp
  40. ### - httpd-to-upload-tmp.pp
  41. # if you have trouble with php-fpm and selinux in this nextcloud configuration :
  42. # # ausearch -c 'php-fpm' --raw | audit2allow -M my-phpfpm
  43. # # semodule -X 300 -i my-phpfpm.pp
  44. # # ausearch -c 'df' --raw | audit2allow -M my-df
  45. # # semodule -X 300 -i my-df.pp
  46. - name: Selinux... Run restore context to reload selinux
  47. shell: restorecon -R -v {{ item.target }}
  48. when: filecontext.results[item.index] is changed
  49. with_items:
  50. - { index: 0, target: '{{ nc_data_dir }}/' }
  51. - { index: 1, target: '{{ http_webroot }}/nextcloud/' }
  52. - name: Selinux... Restart {{ http_service_name }} service
  53. service:
  54. name: "{{ http_service_name }}"
  55. state: restarted