New version of salt-formula from Saltstack
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.

55 lines
1.4KB

  1. {%- from "salt/map.jinja" import api with context %}
  2. {%- if api.get('enabled', False) %}
  3. salt_api_packages:
  4. pkg.installed:
  5. - names: {{ api.pkgs }}
  6. /etc/salt/master.d/_api.conf:
  7. file.managed:
  8. - source: salt://salt/files/_api.conf
  9. - user: root
  10. - template: jinja
  11. - require:
  12. - pkg: salt_api_packages
  13. - watch_in:
  14. - service: salt_api_service
  15. {%- if api.get('ssl', {}).authority is defined %}
  16. {%- set cert_file = "/etc/ssl/certs/" + api.ssl.get('name', grains.id) + ".crt" %}
  17. {%- set ca_file = "/etc/ssl/certs/ca-" + api.ssl.authority + ".crt" %}
  18. salt_api_init_tls:
  19. cmd.run:
  20. - name: "cat {{ cert_file }} {{ ca_file }} > /etc/ssl/certs/{{ api.ssl.get('name', grains.id) }}-chain.crt"
  21. - creates: /etc/ssl/certs/{{ api.ssl.get('name', grains.id) }}-chain.crt
  22. - watch_in:
  23. - service: salt_api_service
  24. {%- endif %}
  25. salt_api_service:
  26. service.running:
  27. - name: {{ api.service }}
  28. - require:
  29. - pkg: salt_api_packages
  30. - watch:
  31. - file: /etc/salt/master.d/_api.conf
  32. {%- if grains.get('init', None) == 'systemd' %}
  33. salt_api_systemd_override:
  34. file.managed:
  35. - name: /etc/systemd/system/{{ api.service }}.service.d/50-restarts.conf
  36. - source: salt://salt/files/systemd/{{ api.service }}.service_50-restarts
  37. - makedirs: True
  38. salt_api_systemd_reload:
  39. module.wait:
  40. - name: service.systemctl_reload
  41. - onchanges:
  42. - file: salt_api_systemd_override
  43. - watch_in:
  44. - service: salt_api_service
  45. {%- endif %}
  46. {%- endif %}