Saltstack Official Galera Formula
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

152 Zeilen
3.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. # 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: {{ slave.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. {%- if grains.os_family == 'Debian' %}
  33. galera_run_dir:
  34. file.directory:
  35. - name: /var/run/mysqld
  36. - makedirs: true
  37. - mode: 755
  38. - user: mysql
  39. - group: root
  40. - require:
  41. - pkg: galera_packages
  42. galera_purge_init:
  43. file.absent:
  44. - name: /etc/init/mysql.conf
  45. - require:
  46. - pkg: galera_packages
  47. galera_conf_debian:
  48. file.managed:
  49. - name: /etc/mysql/debian.cnf
  50. - template: jinja
  51. - source: salt://galera/files/debian.cnf
  52. - mode: 640
  53. - require:
  54. - pkg: galera_packages
  55. {%- endif %}
  56. galera_init_script:
  57. file.managed:
  58. - name: /usr/local/sbin/galera_init.sh
  59. - mode: 755
  60. - source: salt://galera/files/init_bootstrap.sh
  61. - defaults:
  62. service: {{ slave|yaml }}
  63. - template: jinja
  64. galera_bootstrap_script:
  65. file.managed:
  66. - name: /usr/local/sbin/galera_bootstrap.sh
  67. - mode: 755
  68. - defaults:
  69. service: {{ slave|yaml }}
  70. - source: salt://galera/files/bootstrap.sh
  71. - template: jinja
  72. {%- if salt['cmd.run']('test -e /var/lib/mysql/.galera_bootstrap; echo $?') != '0' %}
  73. galera_init_start_service:
  74. cmd.run:
  75. - name: /usr/local/sbin/galera_init.sh
  76. - require:
  77. - file: galera_run_dir
  78. - file: galera_init_script
  79. galera_bootstrap_set_root_password:
  80. cmd.run:
  81. - name: mysqladmin password "{{ slave.admin.password }}"
  82. - require:
  83. - cmd: galera_init_start_service
  84. mysql_bootstrap_update_maint_password:
  85. cmd.run:
  86. - name: mysql -u root -p{{ slave.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ slave.maintenance_password }}';"
  87. - require:
  88. - cmd: galera_bootstrap_set_root_password
  89. galera_bootstrap_stop_service:
  90. service.dead:
  91. - name: {{ slave.service }}
  92. - require:
  93. - cmd: mysql_bootstrap_update_maint_password
  94. galera_bootstrap_init_config:
  95. file.managed:
  96. - name: {{ slave.config }}
  97. - source: salt://galera/files/my.cnf
  98. - mode: 644
  99. - template: jinja
  100. - require:
  101. - service: galera_bootstrap_stop_service
  102. galera_bootstrap_start_service_final:
  103. cmd.run:
  104. - name: /usr/local/sbin/galera_bootstrap.sh
  105. - require:
  106. - file: galera_bootstrap_init_config
  107. - file: galera_bootstrap_script
  108. galera_bootstrap_finish_flag:
  109. file.touch:
  110. - name: /var/lib/mysql/.galera_bootstrap
  111. - require:
  112. - cmd: galera_bootstrap_start_service_final
  113. - watch_in:
  114. - file: galera_config
  115. {%- endif %}
  116. galera_config:
  117. file.managed:
  118. - name: {{ slave.config }}
  119. - source: salt://galera/files/my.cnf
  120. - mode: 644
  121. - template: jinja
  122. - require_in:
  123. - service: galera_service
  124. galera_service:
  125. service.running:
  126. - name: {{ slave.service }}
  127. - enable: true
  128. - reload: true
  129. {%- endif %}