Browse Source

chore: use `semantic-release` cross-formula standard structure

* Automated using `ssf-formula` (v0.6.0)
tags/v2.2.1
Imran Iqbal 5 years ago
parent
commit
34af78ad40
2 changed files with 83 additions and 6 deletions
  1. +72
    -0
      docs/TOFS_pattern.rst
  2. +11
    -6
      nginx/libtofs.jinja

+ 72
- 0
docs/TOFS_pattern.rst View File

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

+ 11
- 6
nginx/libtofs.jinja View File

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
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
the source, to support older TOFS configs
* use_subpath: defaults to `False` but if set, lookup the source file
recursively from the current state directory up to `tplroot`


Example (based on a `tplroot` of `xxx`): Example (based on a `tplroot` of `xxx`):


{%- 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 != '' %}
{%- do path_prefix_exts.append(v1_path_prefix) %}
{%- if use_subpath and tplroot != tpldir %}
{#- 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…
Cancel
Save