Saltstack Official Salt Formula
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.

52 lines
1.4KB

  1. {% set defaults = {
  2. 'baseurl': 'https://github.com/saltstack-formulas',
  3. 'basedir': '/srv/formulas',
  4. 'update': False,
  5. 'options': {},
  6. }
  7. %}
  8. {% set formulas = salt['pillar.get']('salt_formulas:list', {}) %}
  9. {%- macro formulas_git_opt(env, opt) -%}
  10. {%- set value = salt['pillar.get']('salt_formulas:git_opts:{0}:{1}'.format(env, opt),
  11. salt['pillar.get']('salt_formulas:git_opts:default:{0}'.format(opt),
  12. defaults[opt])) -%}
  13. {{ value|yaml }}
  14. {%- endmacro -%}
  15. {%- macro formulas_roots(env) -%}
  16. {%- set value = [] -%}
  17. {%- for repo,f_name in formulas.get(env, {}).items() -%}
  18. {%- for dir in f_name -%}
  19. {%- set basedir = formulas_git_opt(env, 'basedir')|load_yaml -%}
  20. {%- do value.append('{0}/{1}'.format(basedir, dir)) -%}
  21. {%- endfor -%}
  22. {%- endfor -%}
  23. {{ value|yaml }}
  24. {%- endmacro -%}
  25. {# Generate file_roots config merging standard salt config and list of
  26. enabled formulas #}
  27. {%- macro file_roots(input) -%}
  28. {%- set processed_envs = [] -%}
  29. file_roots:
  30. {%- for name, roots in input|dictsort -%}
  31. {%- do processed_envs.append(name) %}
  32. {{ name }}:
  33. {%- for dir in roots %}
  34. - {{ dir }}
  35. {%- endfor -%}
  36. {%- for dir in formulas_roots(name)|load_yaml %}
  37. - {{ dir }}
  38. {%- endfor -%}
  39. {%- endfor -%}
  40. {%- for name in formulas -%}
  41. {%- if name not in processed_envs %}
  42. {{ name }}:
  43. {%- for dir in formulas_roots(name)|load_yaml %}
  44. - {{ dir }}
  45. {%- endfor -%}
  46. {%- endif -%}
  47. {%- endfor -%}
  48. {%- endmacro -%}