selinux.yml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. ---
  2. - name: Allow mysql to listen on tcp port 4567,4568,4444
  3. seport:
  4. ports: 4567,4568,4444
  5. proto: tcp
  6. setype: mysqld_port_t
  7. state: present
  8. - name: Allow mysql to listen on udp port 4567
  9. seport:
  10. ports: 4567
  11. proto: udp
  12. setype: mysqld_port_t
  13. state: present
  14. - name: Sets the MySQL SELinux domain to permissive mode temporarily
  15. command: semanage permissive -a mysqld_t
  16. - name: Mariadb service
  17. service:
  18. name: "{{ mariadb_service }}"
  19. state: stopped
  20. - name: Bootstrap the cluster
  21. command: galera_new_cluster
  22. delegate_to: "{{ groups['db_servers'][0] }}"
  23. - name: Create a database for the specific purpose of logging SST events
  24. mysql_db:
  25. name: selinux
  26. state: present
  27. delegate_to: "{{ groups['db_servers'][0] }}"
  28. run_once: true
  29. - name: Create a table for the specific purpose of logging SST events
  30. community.mysql.mysql_query:
  31. login_db: selinux
  32. query: "CREATE TABLE selinux.selinux_policy (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id));"
  33. delegate_to: "{{ groups['db_servers'][0] }}"
  34. run_once: true
  35. - name: Run insert queries against db selinux in single transaction
  36. community.mysql.mysql_query:
  37. login_db: selinux
  38. query: "INSERT INTO selinux.selinux_policy VALUES ();"
  39. single_transaction: yes
  40. delegate_to: "{{ groups['db_servers'][0] }}"
  41. run_once: true
  42. - name: Mariadb service
  43. service:
  44. name: "{{ mariadb_service }}"
  45. state: started
  46. - name: Generate IST events
  47. community.mysql.mysql_query:
  48. login_db: selinux
  49. query: "INSERT INTO selinux.selinux_policy VALUES ();"
  50. single_transaction: yes
  51. - name: Create and enable the SELinux policy
  52. shell: "grep mysql /var/log/audit/audit.log | audit2allow -M Galera"
  53. ignore_errors: yes
  54. - name: Build and install Galera.pp
  55. shell: semodule -i Galera.pp
  56. - name: Disable permissive mode
  57. shell: semanage permissive -d mysqld_t
  58. - name: Mariadb stop service
  59. service:
  60. name: "{{ mariadb_service }}"
  61. state: stopped
  62. - name: Make Bootstrap safe
  63. lineinfile:
  64. dest: /var/lib/mysql/grastate.dat
  65. regexp: "^{{ item.property | regex_escape() }}.*"
  66. line: "{{ item.value }}"
  67. with_items:
  68. - { property: 'safe_to_bootstrap:', value: 'safe_to_bootstrap: 1' }
  69. delegate_to: "{{ groups['db_servers'][0] }}"
  70. run_once: true