mirror of
https://github.com/saltstack-formulas/salt-formula.git
synced 2024-12-26 04:46:09 +01:00
91b666c75f
* Ensure options for formulas `git.latest` are also based on defaults * Prevent erroneous remote tracking branch modification by `salt.formulas` #238 * Allow multiple envs to use the same gitdir for `salt.formulas` * Ensure `gitdir` original branch is checked out after formulas `git.latest` * Fix erroneous comment re: merging in `salt` pillar
59 lines
1.7 KiB
Django/Jinja
59 lines
1.7 KiB
Django/Jinja
{% set defaults = {
|
|
'baseurl': 'https://github.com/saltstack-formulas',
|
|
'basedir': '/srv/formulas',
|
|
'update': False,
|
|
'options': {
|
|
'branch': 'master',
|
|
},
|
|
}
|
|
%}
|
|
{% set formulas = salt['pillar.get']('salt_formulas:list', {}) %}
|
|
|
|
{%- macro formulas_git_opt(env, opt) -%}
|
|
{%- 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),
|
|
defaults[opt])) -%}
|
|
{{ value|yaml }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro formulas_opts_for_git_latest(env) -%}
|
|
{%- set options = defaults['options'] or {} -%}
|
|
{%- do options.update(salt['pillar.get']('salt_formulas:git_opts:default:options') or {}) -%}
|
|
{%- do options.update(salt['pillar.get']('salt_formulas:git_opts:{0}:options'.format(env)) or {}) -%}
|
|
{{ options|yaml }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro formulas_roots(env) -%}
|
|
{%- set value = [] -%}
|
|
{%- for dir in formulas.get(env, []) -%}
|
|
{%- set basedir = formulas_git_opt(env, 'basedir')|load_yaml -%}
|
|
{%- do value.append('{0}/{1}'.format(basedir, dir)) -%}
|
|
{%- 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 -%}
|