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.

122 linhas
2.9KB

  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: {{ master.xtrabackup_repo }}
  8. - require_in:
  9. - pkg: galera_packages
  10. # Workaround https://bugs.launchpad.net/percona-server/+bug/1490144
  11. xtrabackup_repo_fix:
  12. cmd.run:
  13. - name: |
  14. sed -i 's,enabled\ =\ 1,enabled\ =\ 1\nexclude\ =\ Percona-XtraDB-\*\ Percona-Server-\*,g' /etc/yum.repos.d/percona-release.repo
  15. - unless: 'grep "exclude = Percona-XtraDB-\*" /etc/yum.repos.d/percona-release.repo'
  16. - watch:
  17. - pkg: xtrabackup_repo
  18. - require_in:
  19. - pkg: galera_packages
  20. {%- endif %}
  21. galera_packages:
  22. pkg.installed:
  23. - names: {{ master.pkgs }}
  24. - refresh: true
  25. galera_log_dir:
  26. file.directory:
  27. - name: /var/log/mysql
  28. - makedirs: true
  29. - mode: 755
  30. - require:
  31. - pkg: galera_packages
  32. galera_init_script:
  33. file.managed:
  34. - name: /etc/init.d/mysql
  35. - source: salt://galera/files/mysql
  36. - mode: 755
  37. - require:
  38. - pkg: galera_packages
  39. {%- if salt['cmd.run']('test -e /root/.galera_bootstrap; echo $?') != '0' %}
  40. galera_bootstrap_temp_config:
  41. file.managed:
  42. - name: {{ master.config }}
  43. - source: salt://galera/files/my.cnf.bootstrap
  44. - mode: 644
  45. - template: jinja
  46. - require:
  47. - pkg: galera_packages
  48. - file: galera_init_script
  49. galera_bootstrap_start_service:
  50. service.running:
  51. - name: {{ master.service }}
  52. - require:
  53. - file: galera_bootstrap_temp_config
  54. galera_bootstrap_set_root_password:
  55. cmd.run:
  56. - name: mysqladmin password "{{ master.admin.password }}"
  57. - require:
  58. - service: galera_bootstrap_start_service
  59. mysql_bootstrap_update_maint_password:
  60. cmd.run:
  61. - name: mysql -u root -p{{ master.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ master.maintenance_password }}';"
  62. - require:
  63. - cmd: galera_bootstrap_set_root_password
  64. galera_bootstrap_stop_service:
  65. service.dead:
  66. - name: {{ master.service }}
  67. - require:
  68. - cmd: mysql_bootstrap_update_maint_password
  69. galera_bootstrap_init_config:
  70. file.managed:
  71. - name: {{ master.config }}
  72. - source: salt://galera/files/my.cnf.init
  73. - mode: 644
  74. - template: jinja
  75. - require:
  76. - service: galera_bootstrap_stop_service
  77. galera_bootstrap_start_service_final:
  78. service.running:
  79. - name: {{ master.service }}
  80. - require:
  81. - file: galera_bootstrap_init_config
  82. galera_bootstrap_finish_flag:
  83. file.touch:
  84. - name: /root/.galera_bootstrap
  85. - require:
  86. - service: galera_bootstrap_start_service_final
  87. - watch_in:
  88. - file: galera_config
  89. {%- endif %}
  90. galera_config:
  91. file.managed:
  92. - name: {{ master.config }}
  93. - source: salt://galera/files/my.cnf
  94. - mode: 644
  95. - template: jinja
  96. - require_in:
  97. - service: galera_service
  98. galera_service:
  99. service.running:
  100. - name: {{ master.service }}
  101. - enable: true
  102. - reload: true
  103. {%- endif %}