Saltstack Official Galera Formula
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

server.sls 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. {%- if pillar.get('mysql', {}).server is defined %}
  2. {%- set server = pillar.mysql.server %}
  3. {%- for database_name, database in server.get('database', {}).iteritems() %}
  4. mysql_database_{{ database_name }}:
  5. mysql_database.present:
  6. - name: {{ database_name }}
  7. {%- for user in database.users %}
  8. mysql_user_{{ user.name }}_{{ database_name }}_{{ user.host }}:
  9. mysql_user.present:
  10. - host: '{{ user.host }}'
  11. - name: '{{ user.name }}'
  12. - password: {{ user.password }}
  13. mysql_grants_{{ user.name }}_{{ database_name }}_{{ user.host }}:
  14. mysql_grants.present:
  15. - grant: {{ user.rights }}
  16. - database: '{{ database_name }}.*'
  17. - user: '{{ user.name }}'
  18. - host: '{{ user.host }}'
  19. - require:
  20. - mysql_user: mysql_user_{{ user.name }}_{{ database_name }}_{{ user.host }}
  21. - mysql_database: mysql_database_{{ database_name }}
  22. {%- endfor %}
  23. {%- if database.initial_data is defined %}
  24. /root/mysql/scripts/restore_{{ database_name }}.sh:
  25. file.managed:
  26. - source: salt://mysql/conf/restore.sh
  27. - mode: 770
  28. - template: jinja
  29. - defaults:
  30. database_name: {{ database_name }}
  31. database: {{ database }}
  32. - require:
  33. - file: mysql_dirs
  34. - mysql_database: mysql_database_{{ database_name }}
  35. restore_mysql_database_{{ database_name }}:
  36. cmd.run:
  37. - name: /root/mysql/scripts/restore_{{ database_name }}.sh
  38. - unless: "[ -f /root/mysql/flags/{{ database_name }}-installed ]"
  39. - cwd: /root
  40. - require:
  41. - file: /root/mysql/scripts/restore_{{ database_name }}.sh
  42. {%- endif %}
  43. {%- endfor %}
  44. {%- if not grains.get('noservices', False) %}
  45. {%- for user in server.get('users', []) %}
  46. mysql_user_{{ user.name }}_{{ user.host }}:
  47. mysql_user.present:
  48. - host: '{{ user.host }}'
  49. - name: '{{ user.name }}'
  50. {%- if user.password is defined %}
  51. - password: {{ user.password }}
  52. {%- else %}
  53. - allow_passwordless: True
  54. {%- endif %}
  55. {%- endfor %}
  56. {%- endif %}
  57. {%- endif %}