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.

108 lines
2.5KB

  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. galera_ssl_dir:
  9. file.directory:
  10. - name: /etc/mysql/ssl
  11. - makedirs: true
  12. - mode: 755
  13. - require:
  14. - pkg: galera_packages
  15. {%- if service.ssl.cacert_chain is defined %}
  16. mysql_cacertificate:
  17. file.managed:
  18. - name: {{ service.ssl.ca_file }}
  19. - contents_pillar: galera:{{ role }}:ssl:cacert_chain
  20. - mode: 0444
  21. - makedirs: true
  22. - require_in:
  23. - service: galera_service
  24. - file: galera_config
  25. {%- else %}
  26. mysql_cacertificate_exists:
  27. file.exists:
  28. - name: {{ service.ssl.ca_file }}
  29. mysql_cacertificate:
  30. file.managed:
  31. - name: {{ service.ssl.ca_file }}
  32. - mode: 644
  33. - create: False
  34. - require:
  35. - file: mysql_cacertificate_exists
  36. - file: galera_ssl_dir
  37. - require_in:
  38. - service: galera_service
  39. - file: galera_config
  40. {%- endif %}
  41. {%- if service.ssl.cert is defined %}
  42. mysql_certificate:
  43. file.managed:
  44. - name: {{ service.ssl.cert_file }}
  45. - contents_pillar: galera:{{ role }}:ssl:cert
  46. - mode: 0444
  47. - makedirs: true
  48. - require_in:
  49. - service: galera_service
  50. - file: galera_config
  51. {%- else %}
  52. mysql_certificate_exists:
  53. file.exists:
  54. - name: {{ service.ssl.cert_file }}
  55. mysql_certificate:
  56. file.managed:
  57. - name: {{ service.ssl.cert_file }}
  58. - mode: 644
  59. - create: False
  60. - require:
  61. - file: mysql_certificate_exists
  62. - file: galera_ssl_dir
  63. - require_in:
  64. - service: galera_service
  65. - file: galera_config
  66. {%- endif %}
  67. {%- if service.ssl.key is defined %}
  68. mysql_server_key:
  69. file.managed:
  70. - name: {{ service.ssl.key_file }}
  71. - contents_pillar: galera:{{ role }}:ssl:key
  72. - user: root
  73. - group: mysql
  74. - mode: 0440
  75. - makedirs: true
  76. - require:
  77. - pkg: galera_packages
  78. - file: galera_ssl_dir
  79. - require_in:
  80. - service: galera_service
  81. - file: galera_config
  82. {%- else %}
  83. mysql_server_key_exists:
  84. file.exists:
  85. - name: {{ service.ssl.key_file }}
  86. mysql_server_key:
  87. file.managed:
  88. - name: {{ service.ssl.key_file }}
  89. - user: root
  90. - group: mysql
  91. - mode: 0440
  92. - create: False
  93. - require:
  94. - file: mysql_server_key_exists
  95. - pkg: galera_packages
  96. - file: galera_ssl_dir
  97. - require_in:
  98. - service: galera_service
  99. - file: galera_config
  100. {%- endif %}
  101. {%- endif %}