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.

grains.sls 1.8KB

8 vuotta sitten
8 vuotta sitten
8 vuotta sitten
8 vuotta sitten
8 vuotta sitten
8 vuotta sitten
8 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. salt_minion_grains_pkg_validity_check:
  22. pkg.installed:
  23. - pkgs: {{ minion.grains_validity_pkgs }}
  24. {%- for service_name, service in pillar.items() %}
  25. {%- set support_fragment_file = service_name+'/meta/salt.yml' %}
  26. {%- macro load_support_file() %}{% include support_fragment_file ignore missing %}{% endmacro %}
  27. {%- set support_yaml = load_support_file()|load_yaml %}
  28. {%- if support_yaml %}
  29. {%- for name, grain in support_yaml.get('grain', {}).iteritems() %}
  30. salt_minion_grain_{{ service_name }}_{{ name }}:
  31. file.managed:
  32. - name: /etc/salt/grains.d/{{ name }}
  33. - contents: |
  34. {{ grain|yaml(False)|indent(8) }}
  35. - require:
  36. - file: salt_minion_grains_dir
  37. salt_minion_grain_{{ service_name }}_{{ name }}_validity_check:
  38. cmd.wait:
  39. - name: python -c "import yaml; stream = file('/etc/salt/grains.d/{{ name }}', 'r'); yaml.load(stream); stream.close()"
  40. - require:
  41. - pkg: salt_minion_grains_pkg_validity_check
  42. - watch:
  43. - file: salt_minion_grain_{{ service_name }}_{{ name }}
  44. - watch_in:
  45. - cmd: salt_minion_grains_file
  46. {%- endfor %}
  47. {%- endif %}
  48. {%- endfor %}
  49. salt_minion_grains_file:
  50. cmd.wait:
  51. - name: cat /etc/salt/grains.d/* > /etc/salt/grains
  52. - require:
  53. - file: salt_minion_grains_files
  54. salt_minion_grains_publish:
  55. module.wait:
  56. - name: mine.update
  57. - watch:
  58. - cmd: salt_minion_grains_file
  59. {%- endif %}