50 lines
1.9 KiB
Django/Jinja
50 lines
1.9 KiB
Django/Jinja
{#- Get the `tplroot` from `tpldir` #}
|
|
{%- set tplroot = tpldir.split('/')[0] %}
|
|
{#- Start imports as #}
|
|
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
|
|
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
|
|
{%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %}
|
|
{%- import_yaml tplroot ~ "/osmap.yaml" as osmap %}
|
|
{%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %}
|
|
|
|
{%- set defaults = salt['grains.filter_by'](default_settings,
|
|
default='grafana',
|
|
merge=salt['grains.filter_by'](osfamilymap, grain='os_family',
|
|
merge=salt['grains.filter_by'](osarchmap, grain='osarch',
|
|
merge=salt['grains.filter_by'](osmap, grain='os',
|
|
merge=salt['grains.filter_by'](osfingermap, grain='osfinger',
|
|
merge=salt['pillar.get']('grafana:lookup', default={})
|
|
)
|
|
)
|
|
)
|
|
)
|
|
) %}
|
|
|
|
{#- Merge the grafana pillar #}
|
|
{%- set grafana = salt['pillar.get']('grafana', default=defaults, merge=True) %}
|
|
|
|
{#- archive jinja #}
|
|
{%- if grafana.pkg.use_upstream_archive %}
|
|
{%- set name = 'grafana-%s.%s-%s'|format(grafana.version, grafana.kernel, grafana.arch) %}
|
|
{%- set uri = grafana.pkg.archive.uri + '/' + name %}
|
|
{%- do grafana.pkg.archive.update({
|
|
'name': grafana.pkg.archive.name + '/' + name,
|
|
'source': uri + '.' + grafana.pkg.archive.archive_suffix,
|
|
'source_hash': uri + '.' + grafana.pkg.archive.archive_suffix + '.sha256',
|
|
'archive_format': grafana.pkg.archive.archive_format
|
|
}) %}
|
|
{%- do grafana.environ.append('export PATH=${PATH}:' + grafana.pkg.archive.name + '/bin') %}
|
|
{%- endif %}
|
|
|
|
{#- Contactenate arguments #}
|
|
{%- macro concat_args(args) %}
|
|
{%- set args = args|dictsort %}
|
|
{%- if args|length > 0 %}
|
|
{%- for k,v in args -%}
|
|
{%- if not k or not v %}{% continue %}{% endif -%}
|
|
--{{ k }}={{ v }}
|
|
{%- if not loop.last %} {% endif -%}
|
|
{%- endfor -%}
|
|
{%- endif -%}
|
|
{%- endmacro %}
|