mirror of
https://github.com/saltstack-formulas/openssh-formula.git
synced 2026-10-02 10:05:09 +02:00
feat(semantic-release): implement for this formula
* Close #165 * Move existing `.kitchen.yml` => `kitchen.vagrant.yml` * Semi-automated using https://github.com/myii/ssf-formula/pull/30 * Fix errors shown below: ```bash openssh-formula$ yamllint -s . ./pillar.example 49:3 error duplication of key "AllowUsers" in mapping (key-duplicates) 57:3 error duplication of key "DenyUsers" in mapping (key-duplicates) 63:3 error duplication of key "AllowGroups" in mapping (key-duplicates) 70:3 error duplication of key "DenyGroups" in mapping (key-duplicates) 79:24 warning truthy value should be one of [false, true] (truthy) 80:29 warning truthy value should be one of [false, true] (truthy) 118:4 warning missing starting space in comment (comments) 119:4 warning missing starting space in comment (comments) 119:89 error line too long (122 > 88 characters) (line-length) 120:4 warning missing starting space in comment (comments) 120:89 error line too long (144 > 88 characters) (line-length) 147:30 warning truthy value should be one of [false, true] (truthy) 148:21 warning truthy value should be one of [false, true] (truthy) 149:19 warning truthy value should be one of [false, true] (truthy) 150:32 warning truthy value should be one of [false, true] (truthy) 151:26 warning truthy value should be one of [false, true] (truthy) 152:31 warning truthy value should be one of [false, true] (truthy) 153:32 warning truthy value should be one of [false, true] (truthy) 154:29 warning truthy value should be one of [false, true] (truthy) 155:34 warning truthy value should be one of [false, true] (truthy) 175:8 warning missing starting space in comment (comments) 175:89 error line too long (152 > 88 characters) (line-length) 176:8 warning missing starting space in comment (comments) 176:89 error line too long (126 > 88 characters) (line-length) 177:8 warning missing starting space in comment (comments) 177:89 error line too long (148 > 88 characters) (line-length) 213:18 warning truthy value should be one of [false, true] (truthy) 219:18 warning truthy value should be one of [false, true] (truthy) 225:18 warning truthy value should be one of [false, true] (truthy) 241:22 warning truthy value should be one of [false, true] (truthy) 243:22 warning truthy value should be one of [false, true] (truthy) 244:20 warning truthy value should be one of [false, true] (truthy) 245:21 warning truthy value should be one of [false, true] (truthy) 254:24 warning truthy value should be one of [false, true] (truthy) 255:22 warning truthy value should be one of [false, true] (truthy) 256:23 warning truthy value should be one of [false, true] (truthy) 265:22 warning truthy value should be one of [false, true] (truthy) 268:21 warning truthy value should be one of [false, true] (truthy) 269:20 warning truthy value should be one of [false, true] (truthy) 270:21 warning truthy value should be one of [false, true] (truthy) 279:26 warning truthy value should be one of [false, true] (truthy) 280:24 warning truthy value should be one of [false, true] (truthy) 281:25 warning truthy value should be one of [false, true] (truthy) 307:16 warning truthy value should be one of [false, true] (truthy) 308:6 warning missing starting space in comment (comments) 314:6 warning missing starting space in comment (comments) 316:24 warning truthy value should be one of [false, true] (truthy) 339:89 error line too long (546 > 88 characters) (line-length) 340:89 error line too long (546 > 88 characters) (line-length) 341:89 error line too long (546 > 88 characters) (line-length) 342:89 error line too long (546 > 88 characters) (line-length) 344:4 warning missing starting space in comment (comments) 345:4 warning missing starting space in comment (comments) 357:19 warning truthy value should be one of [false, true] (truthy) ./openssh/osfamilymap.yaml 1:1 warning missing document start "---" (document-start) ./openssh/osfingermap.yaml 1:1 warning missing document start "---" (document-start) ./openssh/osmap.yaml 1:1 warning missing document start "---" (document-start) ./openssh/defaults.yaml 1:1 warning missing document start "---" (document-start) 3:18 warning truthy value should be one of [false, true] (truthy) 6:34 warning too few spaces before comment (comments) 10:25 warning truthy value should be one of [false, true] (truthy) 12:32 warning too few spaces before comment (comments) 16:24 warning truthy value should be one of [false, true] (truthy) 18:24 warning too few spaces before comment (comments) 20:42 warning too few spaces before comment (comments) 27:6 warning missing starting space in comment (comments) ```
This commit is contained in:
+80
-5
@@ -39,7 +39,7 @@ Using SaltStack is a simple and effective way to implement configuration managem
|
||||
|
||||
To avoid this situation we can use the `pillar mechanism <http://docs.saltstack.com/en/latest/topics/pillar/>`_, which is designed to provide controlled access to data from the minions based on some selection rules. As pillar data could be easily integrated in the `Jinja <http://docs.saltstack.com/en/latest/topics/tutorials/pillar.html>`_ templates, it is a good mechanism to store values to be used in the final rendering of state files and templates.
|
||||
|
||||
There are a variety of approaches on the usage of pillar and templates as seen in the `saltstack-formulas <https://github.com/saltstack-formulas>`_' repositories. `Some <https://github.com/saltstack-formulas/nginx-formula/pull/18>`_ `developments <https://github.com/saltstack-formulas/php-formula/pull/14>`_ stress the initial purpose of pillar data into a storage for most of the possible variables for a determined system configuration. This, in my opinion, is shifting too much load from the original template files approach. Adding up some `non-trivial Jinja <https://github.com/spsoit/nginx-formula/blob/81de880fe0276dd9488ffa15bc78944c0fc2b919/nginx/ng/files/nginx.conf>`_ code as essential part of composing the state file definitely makes SaltStack state files (hence formulas) more difficult to read. The extreme of this approach is that we could end up with a new render mechanism, implemented in Jinja, storing everything needed in pillar data to compose configurations. Additionally, we are establishing a strong dependency with the Jinja renderer.
|
||||
There are a variety of approaches on the usage of pillar and templates as seen in the `saltstack-formulas <https://github.com/saltstack-formulas>`_' repositories. `Some <https://github.com/saltstack-formulas/nginx-formula/pull/18>`_ `developments <https://github.com/saltstack-formulas/php-formula/pull/14>`_ stress the initial purpose of pillar data into a storage for most of the possible variables for a determined system configuration. This, in my opinion, is shifting too much load from the original template files approach. Adding up some `non-trivial Jinja <https://github.com/saltstack-formulas/nginx-formula/blob/f74254c07e188bd448eaf1c5f9c802d78c4c005e/nginx/files/default/nginx.conf>`_ code as essential part of composing the state file definitely makes SaltStack state files (hence formulas) more difficult to read. The extreme of this approach is that we could end up with a new render mechanism, implemented in Jinja, storing everything needed in pillar data to compose configurations. Additionally, we are establishing a strong dependency with the Jinja renderer.
|
||||
|
||||
In opposition to the *put the code in file_roots and the data in pillars* approach, there is the *pillar as a store for a set of key-values* approach. A full-blown configuration file abstracted in pillar and jinja is complicated to develop, understand and maintain. I think a better and simpler approach is to keep a configuration file templated using just a basic (non-extensive but extensible) set of pillar values.
|
||||
|
||||
@@ -325,6 +325,7 @@ We can simplify the ``conf.sls`` with the new ``files_switch`` macro to use in t
|
||||
|
||||
|
||||
* This uses ``config.get``, searching for ``ntp:tofs:source_files:Configure NTP`` to determine the list of template files to use.
|
||||
* If this returns a result, the default of ``['/etc/ntp.conf.jinja']`` will be appended to it.
|
||||
* If this does not yield any results, the default of ``['/etc/ntp.conf.jinja']`` will be used.
|
||||
|
||||
In ``libtofs.jinja``, we define this new macro ``files_switch``.
|
||||
@@ -426,7 +427,6 @@ The list of ``source_files`` can be given:
|
||||
tofs:
|
||||
source_files:
|
||||
Configure NTP:
|
||||
- '/etc/ntp.conf.jinja'
|
||||
- '/etc/ntp.conf_alt.jinja'
|
||||
|
||||
Resulting in:
|
||||
@@ -434,10 +434,85 @@ Resulting in:
|
||||
.. code-block:: sls
|
||||
|
||||
- source:
|
||||
- salt://ntp/files/theminion/etc/ntp.conf.jinja
|
||||
- salt://ntp/files/theminion/etc/ntp.conf_alt.jinja
|
||||
- salt://ntp/files/Debian/etc/ntp.conf.jinja
|
||||
- salt://ntp/files/theminion/etc/ntp.conf.jinja
|
||||
- salt://ntp/files/Debian/etc/ntp.conf_alt.jinja
|
||||
- salt://ntp/files/default/etc/ntp.conf.jinja
|
||||
- salt://ntp/files/Debian/etc/ntp.conf.jinja
|
||||
- salt://ntp/files/default/etc/ntp.conf_alt.jinja
|
||||
- salt://ntp/files/default/etc/ntp.conf.jinja
|
||||
|
||||
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',
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user