Skip to content

Commit

Permalink
docs(libtofs): explain usage of sub-directory for components
Browse files Browse the repository at this point in the history
  • Loading branch information
baby-gnu committed Jul 30, 2019
1 parent 6b595cd commit 42a75d9
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions docs/TOFS_pattern.rst
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,74 @@ Resulting in:
Note: This does *not* override the default value.
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'
)
}}
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

0 comments on commit 42a75d9

Please sign in to comment.