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.

45 lines
1.4KB

  1. {% set processed_gitdirs = [] %}
  2. {% set processed_basedirs = [] %}
  3. {% from "salt/formulas.jinja" import formulas_git_opt with context %}
  4. # Loop over all formulas listed in pillar data
  5. {% for env, entries in salt['pillar.get']('salt_formulas:list', {}).iteritems() %}
  6. {% for entry in entries %}
  7. {% set basedir = formulas_git_opt(env, 'basedir') %}
  8. {% set gitdir = '{0}/{1}'.format(basedir, entry) %}
  9. {% set update = formulas_git_opt(env, 'update')|load_yaml %}
  10. # Setup the directory hosting the Git repository
  11. {% if basedir not in processed_basedirs %}
  12. {% do processed_basedirs.append(basedir) %}
  13. {{ basedir }}:
  14. file.directory:
  15. {%- for key, value in salt['pillar.get']('salt_formulas:basedir_opts',
  16. {'makedirs': True}).iteritems() %}
  17. - {{ key }}: {{ value }}
  18. {%- endfor %}
  19. {% endif %}
  20. # Setup the formula Git repository
  21. {% if gitdir not in processed_gitdirs %}
  22. {% do processed_gitdirs.append(gitdir) %}
  23. {% set options = formulas_git_opt(env, 'options')|load_yaml %}
  24. {{ gitdir }}:
  25. git.latest:
  26. - name: {{ formulas_git_opt(env, 'baseurl') }}/{{ entry }}.git
  27. - target: {{ gitdir }}
  28. {%- for key, value in options.iteritems() %}
  29. - {{ key }}: {{ value }}
  30. {%- endfor %}
  31. - require:
  32. - file: {{ basedir }}
  33. {%- if not update %}
  34. - unless: test -e {{ gitdir }}
  35. {%- endif %}
  36. {% endif %}
  37. {% endfor %}
  38. {% endfor %}