chore: use semantic-release
cross-formula standard structure
* Automated using `ssf-formula` (v0.6.0)
This commit is contained in:
parent
c10a47e2b3
commit
cc106e3276
@ -444,3 +444,75 @@ Resulting in:
|
|||||||
Note: This does *not* override the default value.
|
Note: This does *not* override the default value.
|
||||||
Rather, the value from the pillar/config is prepended to the default.
|
Rather, the value from the pillar/config is prepended to the default.
|
||||||
|
|
||||||
|
Using sub-directories for ``components``
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
If your formula is composed of several components, you may prefer to provides files under sub-directories, like in the `systemd-formula <https://github.com/saltstack-formulas/systemd-formula>`_.
|
||||||
|
|
||||||
|
.. code-block::
|
||||||
|
|
||||||
|
/srv/saltstack/systemd-formula/
|
||||||
|
systemd/
|
||||||
|
init.sls
|
||||||
|
libtofs.jinja
|
||||||
|
map.jinja
|
||||||
|
networkd/
|
||||||
|
init.sls
|
||||||
|
files/
|
||||||
|
default/
|
||||||
|
network/
|
||||||
|
99-default.link
|
||||||
|
resolved/
|
||||||
|
init.sls
|
||||||
|
files/
|
||||||
|
default/
|
||||||
|
resolved.conf
|
||||||
|
timesyncd/
|
||||||
|
init.sls
|
||||||
|
files/
|
||||||
|
Arch/
|
||||||
|
resolved.conf
|
||||||
|
Debian/
|
||||||
|
resolved.conf
|
||||||
|
default/
|
||||||
|
resolved.conf
|
||||||
|
Ubuntu/
|
||||||
|
resolved.conf
|
||||||
|
|
||||||
|
For example, the following ``formula.component.config`` SLS:
|
||||||
|
|
||||||
|
.. code-block:: sls
|
||||||
|
|
||||||
|
{%- from "formula/libtofs.jinja" import files_switch with context %}
|
||||||
|
|
||||||
|
formula configuration file:
|
||||||
|
file.managed:
|
||||||
|
- name: /etc/formula.conf
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- mode: 644
|
||||||
|
- template: jinja
|
||||||
|
- source: {{ files_switch(['formula.conf'],
|
||||||
|
lookup='formula',
|
||||||
|
use_subpath=True
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
|
||||||
|
will be rendered on a ``Debian`` minion named ``salt-formula.ci.local`` as:
|
||||||
|
|
||||||
|
.. code-block:: sls
|
||||||
|
|
||||||
|
formula configuration file:
|
||||||
|
file.managed:
|
||||||
|
- name: /etc/formula.conf
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- mode: 644
|
||||||
|
- template: jinja
|
||||||
|
- source:
|
||||||
|
- salt://formula/component/files/salt-formula.ci.local/formula.conf
|
||||||
|
- salt://formula/component/files/Debian/formula.conf
|
||||||
|
- salt://formula/component/files/default/formula.conf
|
||||||
|
- salt://formula/files/salt-formula.ci.local/formula.conf
|
||||||
|
- salt://formula/files/Debian/formula.conf
|
||||||
|
- salt://formula/files/default/formula.conf
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
lookup=None,
|
lookup=None,
|
||||||
default_files_switch=['id', 'os_family'],
|
default_files_switch=['id', 'os_family'],
|
||||||
indent_width=6,
|
indent_width=6,
|
||||||
v1_path_prefix='') %}
|
use_subpath=False) %}
|
||||||
{#-
|
{#-
|
||||||
Returns a valid value for the "source" parameter of a "file.managed"
|
Returns a valid value for the "source" parameter of a "file.managed"
|
||||||
state function. This makes easier the usage of the Template Override and
|
state function. This makes easier the usage of the Template Override and
|
||||||
@ -17,8 +17,8 @@
|
|||||||
use as selector switch of the directories under
|
use as selector switch of the directories under
|
||||||
"<path_prefix>/files"
|
"<path_prefix>/files"
|
||||||
* indent_witdh: indentation of the result value to conform to YAML
|
* indent_witdh: indentation of the result value to conform to YAML
|
||||||
* v1_path_prefix: (deprecated) only used for injecting a path prefix into
|
* use_subpath: defaults to `False` but if set, lookup the source file
|
||||||
the source, to support older TOFS configs
|
recursively from the current state directory up to `tplroot`
|
||||||
|
|
||||||
Example (based on a `tplroot` of `xxx`):
|
Example (based on a `tplroot` of `xxx`):
|
||||||
|
|
||||||
@ -64,10 +64,15 @@
|
|||||||
{%- set src_files = src_files + source_files %}
|
{%- set src_files = src_files + source_files %}
|
||||||
{#- Only add to [''] when supporting older TOFS implementations #}
|
{#- Only add to [''] when supporting older TOFS implementations #}
|
||||||
{%- set path_prefix_exts = [''] %}
|
{%- set path_prefix_exts = [''] %}
|
||||||
{%- if v1_path_prefix != '' %}
|
{%- if use_subpath and tplroot != tpldir %}
|
||||||
{%- do path_prefix_exts.append(v1_path_prefix) %}
|
{#- Walk directory tree to find {{ files_dir }} #}
|
||||||
|
{%- set subpath_parts = tpldir.lstrip(tplroot).lstrip('/').split('/') %}
|
||||||
|
{%- for path in subpath_parts %}
|
||||||
|
{%- set subpath = subpath_parts[0:loop.index] | join('/') %}
|
||||||
|
{%- do path_prefix_exts.append('/' ~ subpath) %}
|
||||||
|
{%- endfor %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- for path_prefix_ext in path_prefix_exts %}
|
{%- for path_prefix_ext in path_prefix_exts|reverse %}
|
||||||
{%- set path_prefix_inc_ext = path_prefix ~ path_prefix_ext %}
|
{%- set path_prefix_inc_ext = path_prefix ~ path_prefix_ext %}
|
||||||
{#- For older TOFS implementation, use `files_switch` from the config #}
|
{#- For older TOFS implementation, use `files_switch` from the config #}
|
||||||
{#- Use the default, new method otherwise #}
|
{#- Use the default, new method otherwise #}
|
||||||
|
Loading…
Reference in New Issue
Block a user