Saltstack Official Galera Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

master.sls 2.9KB

8 년 전
8 년 전
9 년 전
9 년 전
9 년 전
9 년 전
9 년 전
9 년 전
9 년 전
9 년 전
9 년 전
9 년 전
9 년 전
9 년 전
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 %}