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.

112 lines
2.6KB

  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. galera_init_script:
  24. file.managed:
  25. - name: /etc/init.d/mysql
  26. - source: salt://galera/files/mysql
  27. - mode: 755
  28. - require:
  29. - pkg: galera_packages
  30. {%- if not salt['cmd.run']('test -e /root/.galera_bootstrap') %}
  31. galera_bootstrap_temp_config:
  32. file.managed:
  33. - name: {{ master.config }}
  34. - source: salt://galera/files/my.cnf.bootstrap
  35. - mode: 644
  36. - template: jinja
  37. - require:
  38. - pkg: galera_packages
  39. - file: galera_init_script
  40. galera_bootstrap_start_service:
  41. service.running:
  42. - name: mysql
  43. - require:
  44. - file: galera_bootstrap_temp_config
  45. galera_bootstrap_set_root_password:
  46. cmd.run:
  47. - name: mysqladmin password "{{ master.admin.password }}"
  48. - require:
  49. - service: galera_bootstrap_start_service
  50. mysql_bootstrap_update_maint_password:
  51. cmd.run:
  52. - name: mysql -u root -p{{ master.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ master.maintenance_password }}';"
  53. - require:
  54. - cmd: galera_bootstrap_set_root_password
  55. galera_bootstrap_stop_service:
  56. service.dead:
  57. - name: {{ master.service }}
  58. - require:
  59. - cmd: mysql_bootstrap_update_maint_password
  60. galera_bootstrap_init_config:
  61. file.managed:
  62. - name: {{ master.config }}
  63. - source: salt://galera/files/my.cnf.init
  64. - mode: 644
  65. - template: jinja
  66. - require:
  67. - service: galera_bootstrap_stop_service
  68. galera_bootstrap_start_service_final:
  69. service.running:
  70. - name: {{ master.service }}
  71. - require:
  72. - file: galera_bootstrap_init_config
  73. galera_bootstrap_finish_flag:
  74. file.touch:
  75. - require:
  76. - service: galera_bootstrap_start_service_final
  77. - watch_in:
  78. - file: galera_config
  79. {%- endif %}
  80. galera_config:
  81. file.managed:
  82. - name: {{ master.config }}
  83. - source: salt://galera/files/my.cnf
  84. - mode: 644
  85. - template: jinja
  86. - require_in:
  87. - service: galera_service
  88. galera_service:
  89. service.running:
  90. - name: {{ master.service }}
  91. - enable: true
  92. - reload: true
  93. {%- endif %}