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.

71 lines
1.8KB

  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. {%- for user in server.get('users', []) %}
  45. mysql_user_{{ user.name }}_{{ user.host }}:
  46. mysql_user.present:
  47. - host: '{{ user.host }}'
  48. - name: '{{ user.name }}'
  49. {%- if user.password is defined %}
  50. - password: {{ user.password }}
  51. {%- else %}
  52. - allow_passwordless: True
  53. {%- endif %}
  54. {%- endfor %}
  55. {%- endif %}