New version of salt-formula from Saltstack
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

66 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. - require:
  38. - pkg: salt_minion_dependency_packages
  39. - watch:
  40. - file: salt_minion_grain_{{ service_name }}_{{ name }}
  41. - watch_in:
  42. - cmd: salt_minion_grains_file
  43. {%- endfor %}
  44. {%- endif %}
  45. {%- endfor %}
  46. salt_minion_grains_file:
  47. cmd.wait:
  48. - name: cat /etc/salt/grains.d/* > /etc/salt/grains
  49. - require:
  50. - file: salt_minion_grains_files
  51. salt_minion_grains_publish:
  52. module.wait:
  53. - name: mine.update
  54. - watch:
  55. - cmd: salt_minion_grains_file
  56. {%- endif %}