Saltstack Official Galera Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.0KB

  1. {%- from "galera/map.jinja" import master with context %}
  2. {%- if master.enabled %}
  3. {%- if grains.os_family == "Debian2" %}
  4. galera_debconf:
  5. debconf.set:
  6. - name: mariadb-galera-server
  7. - data:
  8. 'mysql-server/root_password': {'type':'string','value':'{{ server.admin.password }}'}
  9. 'mysql-server/root_password_again': {'type':'string','value':'{{ server.admin.password }}'}
  10. - require_in:
  11. - pkg: galera_packages
  12. {%- endif %}
  13. galera_packages:
  14. pkg.installed:
  15. - names: {{ master.pkgs }}
  16. galera_log_dir:
  17. file.directory:
  18. - name: /var/log/mysql
  19. - makedirs: true
  20. - mode: 755
  21. - require:
  22. - pkg: galera_packages
  23. {%- if not salt['cmd.run']('test -e /root/.galera_bootstrap') %}
  24. galera_bootstrap_temp_config:
  25. file.managed:
  26. - name: {{ master.config }}
  27. - source: salt://mysql/files/my.cnf.bootstrap
  28. - mode: 644
  29. - template: jinja
  30. - require:
  31. - pkg: galera_packages
  32. galera_bootstrap_start_service:
  33. service.running:
  34. - name: mysql
  35. - require:
  36. - file: galera_bootstrap_temp_config
  37. galera_bootstrap_set_root_password:
  38. cmd.run:
  39. - name: mysqladmin password "{{ master.admin.password }}"
  40. - require:
  41. - service: galera_bootstrap_start_service
  42. mysql_bootstrap_update_maint_password:
  43. cmd.run:
  44. - name: mysql -u root -p{{ master.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ master.maintenance_password }}';"
  45. - require:
  46. - cmd: galera_bootstrap_set_root_password
  47. galera_packages_bootstrap_stop_service:
  48. service.dead:
  49. - name: mysql
  50. - require:
  51. - cmd: mysql_bootstrap_update_maint_password
  52. galera_bootstrap_init_config:
  53. file.managed:
  54. - name: {{ master.config }}
  55. - source: salt://mysql/conf/my.cnf
  56. - mode: 644
  57. - template: jinja
  58. - require:
  59. - service: galera_bootstrap_stop_service
  60. galera_bootstrap_temp_config:
  61. file.touch:
  62. - require:
  63. - file: galera_bootstrap_init_config
  64. - watch_in:
  65. - service: galera_service
  66. {%- endif %}
  67. galera_service:
  68. service.running:
  69. - name: {{ master.service }}
  70. - enable: true
  71. - reload: true
  72. {%- endif %}