Saltstack Official Galera Formula
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

100 linhas
2.2KB

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