Saltstack Official Galera Formula
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

master.sls 3.3KB

il y a 9 ans
il y a 8 ans
il y a 8 ans
il y a 9 ans
il y a 8 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. {%- 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_bootstrap_script:
  57. file.managed:
  58. - name: /usr/local/sbin/galera_bootstrap.sh
  59. - mode: 755
  60. - source: salt://galera/files/bootstrap.sh
  61. - template: jinja
  62. {%- if salt['cmd.run']('test -e /var/lib/mysql/.galera_bootstrap; echo $?') != '0' %}
  63. galera_bootstrap_start_service:
  64. cmd.run:
  65. - name: /usr/local/sbin/galera_bootstrap.sh
  66. - require:
  67. - file: galera_run_dir
  68. - file: galera_bootstrap_script
  69. galera_bootstrap_set_root_password:
  70. cmd.run:
  71. - name: mysqladmin password "{{ master.admin.password }}"
  72. - require:
  73. - cmd: galera_bootstrap_start_service
  74. mysql_bootstrap_update_maint_password:
  75. cmd.run:
  76. - name: mysql -u root -p{{ master.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ master.maintenance_password }}';"
  77. - require:
  78. - cmd: galera_bootstrap_set_root_password
  79. galera_bootstrap_stop_service:
  80. service.dead:
  81. - name: {{ master.service }}
  82. - require:
  83. - cmd: mysql_bootstrap_update_maint_password
  84. galera_bootstrap_init_config:
  85. file.managed:
  86. - name: {{ master.config }}
  87. - source: salt://galera/files/my.cnf.init
  88. - mode: 644
  89. - template: jinja
  90. - require:
  91. - service: galera_bootstrap_stop_service
  92. galera_bootstrap_start_service_final:
  93. cmd.run:
  94. - name: /usr/local/sbin/galera_bootstrap.sh
  95. - require:
  96. - file: galera_bootstrap_init_config
  97. - file: galera_bootstrap_script
  98. galera_bootstrap_finish_flag:
  99. file.touch:
  100. - name: /var/lib/mysql/.galera_bootstrap
  101. - require:
  102. - cmd: galera_bootstrap_start_service_final
  103. - watch_in:
  104. - file: galera_config
  105. {%- endif %}
  106. galera_config:
  107. file.managed:
  108. - name: {{ master.config }}
  109. - source: salt://galera/files/my.cnf
  110. - mode: 644
  111. - template: jinja
  112. - require_in:
  113. - service: galera_service
  114. galera_service:
  115. service.running:
  116. - name: {{ master.service }}
  117. - enable: true
  118. - reload: true
  119. {%- endif %}