2014-12-23 16:02:08 +01:00
|
|
|
{% set defaults = {
|
|
|
|
'baseurl': 'https://github.com/saltstack-formulas',
|
|
|
|
'basedir': '/srv/formulas',
|
|
|
|
'update': False,
|
|
|
|
'options': {},
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
{% set formulas = salt['pillar.get']('salt_formulas:list', {}) %}
|
|
|
|
|
|
|
|
{%- macro formulas_git_opt(env, opt) -%}
|
2015-06-17 16:12:28 +02:00
|
|
|
{%- set value = salt['pillar.get']('salt_formulas:git_opts:{0}:{1}'.format(env, opt),
|
|
|
|
salt['pillar.get']('salt_formulas:git_opts:default:{0}'.format(opt),
|
2014-12-23 16:02:08 +01:00
|
|
|
defaults[opt])) -%}
|
|
|
|
{{ value|yaml }}
|
|
|
|
{%- endmacro -%}
|
|
|
|
|
|
|
|
{%- macro formulas_roots(env) -%}
|
|
|
|
{%- set value = [] -%}
|
2016-02-16 16:20:42 +01:00
|
|
|
{%- for dir in formulas.get(env, []) -%}
|
2015-09-03 20:56:45 +02:00
|
|
|
{%- set basedir = formulas_git_opt(env, 'basedir')|load_yaml -%}
|
|
|
|
{%- do value.append('{0}/{1}'.format(basedir, dir)) -%}
|
2014-12-23 16:02:08 +01:00
|
|
|
{%- endfor -%}
|
|
|
|
{{ value|yaml }}
|
|
|
|
{%- endmacro -%}
|
|
|
|
|
|
|
|
{# Generate file_roots config merging standard salt config and list of
|
|
|
|
enabled formulas #}
|
|
|
|
{%- macro file_roots(input) -%}
|
|
|
|
{%- set processed_envs = [] -%}
|
|
|
|
file_roots:
|
|
|
|
{%- for name, roots in input|dictsort -%}
|
|
|
|
{%- do processed_envs.append(name) %}
|
|
|
|
{{ name }}:
|
|
|
|
{%- for dir in roots %}
|
|
|
|
- {{ dir }}
|
|
|
|
{%- endfor -%}
|
|
|
|
{%- for dir in formulas_roots(name)|load_yaml %}
|
|
|
|
- {{ dir }}
|
|
|
|
{%- endfor -%}
|
|
|
|
{%- endfor -%}
|
|
|
|
{%- for name in formulas -%}
|
|
|
|
{%- if name not in processed_envs %}
|
|
|
|
{{ name }}:
|
|
|
|
{%- for dir in formulas_roots(name)|load_yaml %}
|
|
|
|
- {{ dir }}
|
|
|
|
{%- endfor -%}
|
|
|
|
{%- endif -%}
|
|
|
|
{%- endfor -%}
|
|
|
|
{%- endmacro -%}
|