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.

67 lines
1.4KB

  1. {%- from "galera/map.jinja" import slave with context %}
  2. {%- if slave.get('enabled', False) %}
  3. {%- if slave.get('ssl', {}).get('enabled', False) %}
  4. include:
  5. - galera._ssl
  6. {%- endif %}
  7. galera_packages:
  8. pkg.installed:
  9. - names: {{ slave.pkgs }}
  10. - refresh: true
  11. - force_yes: True
  12. galera_run_dir:
  13. file.directory:
  14. - name: /var/run/mysqld
  15. - makedirs: true
  16. - mode: 755
  17. - user: mysql
  18. - group: root
  19. - require:
  20. - galera_packages
  21. {%- if salt['cmd.shell']('test -e /etc/salt/.galera_bootstrap; echo $?') != '0' %}
  22. galera_set_root_password:
  23. cmd.run:
  24. - name: mysqladmin password "{{ slave.admin.password }}"
  25. {%- if grains.get('noservices') %}
  26. - onlyif: /bin/false
  27. {%- endif %}
  28. mariadb_update_maint_password:
  29. cmd.run:
  30. - name: mysql -u root -p{{ slave.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ slave.maintenance_password }}';"
  31. {%- if grains.get('noservices') %}
  32. - onlyif: /bin/false
  33. {%- endif %}
  34. mariadb_service_dead:
  35. service.dead:
  36. - name: {{ slave.service }}
  37. galera_mariadb_finish_flag:
  38. file.touch:
  39. - name: /etc/salt/.galera_bootstrap
  40. {%- endif %}
  41. galera_config:
  42. file.managed:
  43. - name: {{ slave.config }}
  44. - source: salt://galera/files/my.cnf
  45. - mode: 644
  46. - template: jinja
  47. mariadb_service_enable:
  48. service.running:
  49. - name: {{ slave.service }}
  50. - enable: true
  51. - require:
  52. - galera_packages
  53. - galera_config
  54. {%- endif %}