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.

111 line
2.5KB

  1. {%- from "galera/map.jinja" import master with context %}
  2. {%- if master.enabled %}
  3. {%- if grains.os_family == 'RedHat' %}
  4. xtrabackup_repo:
  5. pkg.installed:
  6. - sources:
  7. - percona-release: {{ slave.xtrabackup_repo }}
  8. - require_in:
  9. - pkg: galera_packages
  10. {%- endif %}
  11. galera_packages:
  12. pkg.installed:
  13. - names: {{ master.pkgs }}
  14. - refresh: true
  15. galera_log_dir:
  16. file.directory:
  17. - name: /var/log/mysql
  18. - makedirs: true
  19. - mode: 755
  20. - require:
  21. - pkg: galera_packages
  22. galera_init_script:
  23. file.managed:
  24. - name: /etc/init.d/mysql
  25. - source: salt://galera/files/mysql
  26. - mode: 755
  27. - require:
  28. - pkg: galera_packages
  29. {%- if salt['cmd.run']('test -e /root/.galera_bootstrap; echo $?') != '0' %}
  30. galera_bootstrap_temp_config:
  31. file.managed:
  32. - name: {{ master.config }}
  33. - source: salt://galera/files/my.cnf.bootstrap
  34. - mode: 644
  35. - template: jinja
  36. - require:
  37. - pkg: galera_packages
  38. - file: galera_init_script
  39. galera_bootstrap_start_service:
  40. service.running:
  41. - name: {{ master.service }}
  42. - require:
  43. - file: galera_bootstrap_temp_config
  44. galera_bootstrap_set_root_password:
  45. cmd.run:
  46. - name: mysqladmin password "{{ master.admin.password }}"
  47. - require:
  48. - service: galera_bootstrap_start_service
  49. mysql_bootstrap_update_maint_password:
  50. cmd.run:
  51. - name: mysql -u root -p{{ master.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ master.maintenance_password }}';"
  52. - require:
  53. - cmd: galera_bootstrap_set_root_password
  54. galera_bootstrap_stop_service:
  55. service.dead:
  56. - name: {{ master.service }}
  57. - require:
  58. - cmd: mysql_bootstrap_update_maint_password
  59. galera_bootstrap_init_config:
  60. file.managed:
  61. - name: {{ master.config }}
  62. - source: salt://galera/files/my.cnf.init
  63. - mode: 644
  64. - template: jinja
  65. - require:
  66. - service: galera_bootstrap_stop_service
  67. galera_bootstrap_start_service_final:
  68. service.running:
  69. - name: {{ master.service }}
  70. - require:
  71. - file: galera_bootstrap_init_config
  72. galera_bootstrap_finish_flag:
  73. file.touch:
  74. - name: /root/.galera_bootstrap
  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 %}