New version of salt-formula from Saltstack
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

64 lines
1.7KB

  1. {%- from "salt/map.jinja" import minion with context %}
  2. {%- if minion.enabled %}
  3. include:
  4. - salt.minion.service
  5. salt_minion_grains_dir:
  6. file.directory:
  7. - name: /etc/salt/grains.d
  8. - mode: 700
  9. - makedirs: true
  10. - user: root
  11. - require:
  12. - {{ minion.install_state }}
  13. salt_minion_grains_files:
  14. file.managed:
  15. - names:
  16. - /etc/salt/grains
  17. - /etc/salt/grains.d/placeholder
  18. - replace: False
  19. - require:
  20. - file: salt_minion_grains_dir
  21. {%- for service_name, service in pillar.items() %}
  22. {%- set support_fragment_file = service_name+'/meta/salt.yml' %}
  23. {%- macro load_support_file() %}{% include support_fragment_file ignore missing %}{% endmacro %}
  24. {%- set support_yaml = load_support_file()|load_yaml %}
  25. {%- if support_yaml and support_yaml.get('grain', {}) %}
  26. {%- for name, grain in support_yaml.get('grain', {}).iteritems() %}
  27. salt_minion_grain_{{ service_name }}_{{ name }}:
  28. file.managed:
  29. - name: /etc/salt/grains.d/{{ name }}
  30. - contents: |
  31. {{ grain|yaml(False)|indent(8) }}
  32. - require:
  33. - file: salt_minion_grains_dir
  34. salt_minion_grain_{{ service_name }}_{{ name }}_validity_check:
  35. cmd.wait:
  36. - name: python -c "import yaml; stream = file('/etc/salt/grains.d/{{ name }}', 'r'); yaml.load(stream); stream.close()"
  37. - watch:
  38. - file: salt_minion_grain_{{ service_name }}_{{ name }}
  39. - watch_in:
  40. - cmd: salt_minion_grains_file
  41. {%- endfor %}
  42. {%- endif %}
  43. {%- endfor %}
  44. salt_minion_grains_file:
  45. cmd.wait:
  46. - name: cat /etc/salt/grains.d/* > /etc/salt/grains
  47. - require:
  48. - file: salt_minion_grains_files
  49. salt_minion_grains_publish:
  50. module.wait:
  51. - name: mine.update
  52. - watch:
  53. - cmd: salt_minion_grains_file
  54. {%- endif %}