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.

95 lines
2.3KB

  1. {%- from "galera/map.jinja" import master, slave with context %}
  2. {%- if master.get('enabled', False) %}
  3. {%- set service, role = master, 'master' %}
  4. {%- elif slave.get('enabled', False) %}
  5. {%- set service, role = slave, 'slave' %}
  6. {%- endif %}
  7. {%- if service.get('ssl', {}).get('enabled', False) %}
  8. {%- if service.ssl.cacert_chain is defined %}
  9. mysql_cacertificate:
  10. file.managed:
  11. - name: {{ service.ssl.ca_file }}
  12. - contents_pillar: galera:{{ role }}:ssl:cacert_chain
  13. - mode: 0444
  14. - makedirs: true
  15. - require_in:
  16. - service: galera_service
  17. - file: galera_config
  18. {%- else %}
  19. mysql_cacertificate_exists:
  20. file.exists:
  21. - name: {{ service.ssl.ca_file }}
  22. mysql_cacertificate:
  23. file.managed:
  24. - name: {{ service.ssl.ca_file }}
  25. - mode: 644
  26. - create: False
  27. - require:
  28. - file: mysql_cacertificate_exists
  29. - require_in:
  30. - service: galera_service
  31. - file: galera_config
  32. {%- endif %}
  33. {%- if service.ssl.cert is defined %}
  34. mysql_certificate:
  35. file.managed:
  36. - name: {{ service.ssl.cert_file }}
  37. - contents_pillar: galera:{{ role }}:ssl:cert
  38. - mode: 0444
  39. - makedirs: true
  40. - require_in:
  41. - service: galera_service
  42. - file: galera_config
  43. {%- else %}
  44. mysql_certificate_exists:
  45. file.exists:
  46. - name: {{ service.ssl.cert_file }}
  47. mysql_certificate:
  48. file.managed:
  49. - name: {{ service.ssl.cert_file }}
  50. - mode: 644
  51. - create: False
  52. - require:
  53. - file: mysql_certificate_exists
  54. - require_in:
  55. - service: galera_service
  56. - file: galera_config
  57. {%- endif %}
  58. {%- if service.ssl.key is defined %}
  59. mysql_server_key:
  60. file.managed:
  61. - name: {{ service.ssl.key_file }}
  62. - contents_pillar: galera:{{ role }}:ssl:key
  63. - user: root
  64. - group: mysql
  65. - mode: 0440
  66. - makedirs: true
  67. - require:
  68. - pkg: galera_packages
  69. - require_in:
  70. - service: galera_service
  71. - file: galera_config
  72. {%- else %}
  73. mysql_server_key_exists:
  74. file.exists:
  75. - name: {{ service.ssl.key_file }}
  76. mysql_server_key:
  77. file.managed:
  78. - name: {{ service.ssl.key_file }}
  79. - user: root
  80. - group: mysql
  81. - mode: 0440
  82. - create: False
  83. - require:
  84. - file: mysql_server_key_exists
  85. - pkg: galera_packages
  86. - require_in:
  87. - service: galera_service
  88. - file: galera_config
  89. {%- endif %}
  90. {%- endif %}