blob: 049fed1e0c4d2d6649b27bba252cbe17cf883982 [file] [log] [blame]
martin f. krafft8acd49d2013-08-26 21:22:25 +02001==================
2reclass operations
3==================
4
martin f. krafftf4320532013-11-30 17:00:37 +01005YAML FS storage
6---------------
martin f. krafft8acd49d2013-08-26 21:22:25 +02007While |reclass| has been built to support different storage backends through
8plugins, currently only the ``yaml_fs`` storage backend exists. This is a very
9simple, yet powerful, YAML-based backend, using flat files on the filesystem
10(as suggested by the ``_fs`` postfix).
11
12``yaml_fs`` works with two directories, one for node definitions, and another
martin f. krafft16c93802013-11-30 13:23:16 +010013for class definitions. The two directories must not be the same, nor can one
14be a parent of the other.
martin f. krafft8acd49d2013-08-26 21:22:25 +020015
16Files in those directories are YAML-files, specifying key-value pairs. The
17following three keys are read by |reclass|:
18
19============ ================================================================
20Key Description
21============ ================================================================
22classes a list of parent classes
23appliations a list of applications to append to the applications defined by
24 ancestors. If an application name starts with ``~``, it would
25 remove this application from the list, if it had already been
26 added but it does not prevent a future addition.
27 E.g. ``~firewalled``
28parameters key-value pairs to set defaults in class definitions, override
29 existing data, or provide node-specific information in node
30 specifications.
31 \
32 By convention, parameters corresponding to an application
33 should be provided as subkey-value pairs, keyed by the name of
34 the application, e.g.::
35
36 applications:
37 - ssh.server
38 parameters:
39 ssh.server:
40 permit_root_login: no
41============ ================================================================
42
martin f. krafftf4320532013-11-30 17:00:37 +010043Data merging
44------------
45|reclass| has two modes of operation: node information retrieval and inventory
46listing. The second is really just a loop of the first across all defined
47nodes, and needs not be further described.
martin f. krafft8acd49d2013-08-26 21:22:25 +020048
martin f. krafftf4320532013-11-30 17:00:37 +010049When retrieving information about a node, |reclass| first obtains the node
50definition from the storage backend. Then, it iterates the list of classes
51defined for the node and recursively asks the storage backend for each class
52definition (unless already cached).
53
54Next, |reclass| recursively descends each class, looking at the classes it
55defines, and so on, until a leaf node is reached, i.e. a class that references
56no other classes.
57
58Now, the merging starts. At every step, the list of applications and the set
59of parameters at each level is merged into what has been accumulated so far.
60
61Merging of parameters is done "deeply", meaning that lists and dictionaries
martin f. krafft8acd49d2013-08-26 21:22:25 +020062are extended (recursively), rather than replaced. However, a scalar value
63*does* overwrite a dictionary or list value. While the scalar could be
64appended to an existing list, there is sane default assumption in the context
65of a dictionary, so this behaviour seems the most logical.
66
martin f. krafftf4320532013-11-30 17:00:37 +010067After all classes (and the classes they reference) have been visited,
68|reclass| finally merges the applications list and parameters defined for the
69node into what has been accumulated during the processing of the classes, and
70returns the final result.
71
martin f. krafft8acd49d2013-08-26 21:22:25 +020072Parameter interpolation
73------------------------
74Parameters may reference each other, including deep references, e.g.::
75
76 parameters:
77 location: Munich, Germany
78 motd:
79 header: This node sits in ${location}
80 for_demonstration: ${motd:header}
81 dict_reference: ${motd}
82
83After merging and interpolation, which happens automatically inside the
84storage modules, the ``for_demonstration`` parameter will have a value of
85"This node sits in Munich, Germany".
86
87Types are preserved if the value contains nothing but a reference. Hence, the
88value of ``dict_reference`` will actually be a dictionary.
89
90You should now be ready to :doc:`use reclass <usage>`!
91
92.. include:: substs.inc