qusal/salt/utils/macros/clone-template.sls

36 lines
756 B
Plaintext
Raw Normal View History

2023-11-13 09:33:28 -05:00
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>
SPDX-License-Identifier: AGPL-3.0-or-later
#}
{#
Usage:
1: Import this template:
{% from 'utils/macros/clone-template.sls' import clone_template -%}
2: Set template to clone from and the clone name:
{{ clone_template('debian-minimal', sls_path) }}
#}
2024-01-12 11:22:58 -05:00
{% macro clone_template(source, name, noprefix) -%}
2023-11-13 09:33:28 -05:00
{%- import source ~ "/template.jinja" as template -%}
include:
- {{ source }}.create
2024-01-12 11:22:58 -05:00
{% set prefix = "tpl-" -%}
{% if noprefix is defined -%}
2024-01-12 11:22:58 -05:00
{%- set prefix = "" -%}
{% endif -%}
"{{ prefix }}{{ name }}-clone":
2023-11-13 09:33:28 -05:00
qvm.clone:
- require:
- sls: {{ source }}.create
- source: {{ template.template }}
2024-01-12 11:22:58 -05:00
- name: {{ prefix }}{{ name }}
2023-11-13 09:33:28 -05:00
{% endmacro -%}