Saltstack Official Galera Formula
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

113 rindas
2.5KB

  1. {%- from "galera/map.jinja" import slave with context %}
  2. {%- if slave.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: {{ slave.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: {{ slave.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: {{ slave.service }}
  42. - require:
  43. - file: galera_bootstrap_temp_config
  44. galera_bootstrap_set_root_password:
  45. cmd.run:
  46. - name: mysqladmin password "{{ slave.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{{ slave.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ slave.maintenance_password }}';"
  52. - require:
  53. - cmd: galera_bootstrap_set_root_password
  54. galera_bootstrap_stop_service:
  55. service.dead:
  56. - name: {{ slave.service }}
  57. - require:
  58. - cmd: mysql_bootstrap_update_maint_password
  59. galera_bootstrap_init_config:
  60. file.managed:
  61. - name: {{ slave.config }}
  62. - source: salt://galera/files/my.cnf
  63. - mode: 644
  64. - template: jinja
  65. - require:
  66. - service: galera_bootstrap_stop_service
  67. galera_bootstrap_start_service_final:
  68. cmd.script:
  69. - name: slave_bootstrap
  70. - source: salt://galera/files/slave_bootstrap.sh
  71. - template: jinja
  72. - require:
  73. - file: galera_bootstrap_init_config
  74. galera_bootstrap_finish_flag:
  75. file.touch:
  76. - name: /root/.galera_bootstrap
  77. - require:
  78. - cmd: galera_bootstrap_start_service_final
  79. - watch_in:
  80. - file: galera_config
  81. {%- endif %}
  82. galera_config:
  83. file.managed:
  84. - name: {{ slave.config }}
  85. - source: salt://galera/files/my.cnf
  86. - mode: 644
  87. - template: jinja
  88. - require_in:
  89. - service: galera_service
  90. galera_service:
  91. service.running:
  92. - name: {{ slave.service }}
  93. - enable: true
  94. - reload: true
  95. {%- endif %}