New version of salt-formula from Saltstack
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. {%- from "salt/map.jinja" import master with context %}
  2. {%- if master.enabled %}
  3. {%- for environment_name, environment in master.get('environment', {}).iteritems() %}
  4. {%- if master.base_environment == environment_name %}
  5. {%- set priorities = {} %}
  6. {%- set args = {} %}
  7. {%- set formulas = environment.get('formula', {}) %}
  8. {%- for formula_name, formula in formulas.iteritems() %}
  9. {%- if salt['file.file_exists'](master.dir.files+'/'+environment_name+'/'+formula_name+'/meta/salt.yml') %}
  10. {%- set grains_fragment_file = formula_name+'/meta/salt.yml' %}
  11. {%- macro load_grains_file() %}{% include grains_fragment_file %}{% endmacro %}
  12. {%- set grains_yaml = load_grains_file()|load_yaml %}
  13. {%- for state, priority in grains_yaml['orchestrate'].iteritems() %}
  14. {%- do priorities.update({ formula_name+'.'+state: grains_yaml['orchestrate'][state]['priority'] }) %}
  15. {%- set arguments = [] %}
  16. {%- for arg_name, arg_value in grains_yaml['orchestrate'][state].iteritems() %}
  17. {%- if 'priority' not in arg_name %}
  18. {%- do arguments.append({arg_name: arg_value}) %}
  19. {%- endif %}
  20. {%- endfor %}
  21. {%- if arguments %}
  22. {%- do args.update({ formula_name+'.'+state: arguments }) %}
  23. {%- endif %}
  24. {%- endfor %}
  25. {%- else %}
  26. {%- do priorities.update({ formula_name: 10000 }) %}
  27. {%- endif %}
  28. {%- endfor %}
  29. {{ master.dir.files }}/{{ environment_name }}/orchestrate:
  30. file.directory:
  31. - user: root
  32. - group: root
  33. - mode: 755
  34. - makedirs: True
  35. {{ master.dir.files }}/{{ environment_name }}/orchestrate/init.sls:
  36. file.managed:
  37. - source: salt://salt/files/orchestrate.sls
  38. - user: root
  39. - template: jinja
  40. - defaults:
  41. priorities: {{ priorities }}
  42. args: {{ args }}
  43. {%- endif %}
  44. {%- endfor %}
  45. {%- endif %}