martin f. krafft | 8acd49d | 2013-08-26 21:22:25 +0200 | [diff] [blame^] | 1 | ================== |
| 2 | reclass operations |
| 3 | ================== |
| 4 | |
| 5 | Data merging |
| 6 | ------------ |
| 7 | While |reclass| has been built to support different storage backends through |
| 8 | plugins, currently only the ``yaml_fs`` storage backend exists. This is a very |
| 9 | simple, 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 |
| 13 | for class definitions. It is possible to use a single directory for both, but |
| 14 | that could get messy and is therefore not recommended. |
| 15 | |
| 16 | Files in those directories are YAML-files, specifying key-value pairs. The |
| 17 | following three keys are read by |reclass|: |
| 18 | |
| 19 | ============ ================================================================ |
| 20 | Key Description |
| 21 | ============ ================================================================ |
| 22 | classes a list of parent classes |
| 23 | appliations 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`` |
| 28 | parameters 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 | |
| 43 | |reclass| starts out reading a node definition file, obtains the list of |
| 44 | classes, then reads the files corresponding to these classes, recursively |
| 45 | reading parent classes, and finally merges the applications list and the |
| 46 | parameters. |
| 47 | |
| 48 | Merging of parameters is done recursively, meaning that lists and dictionaries |
| 49 | are extended (recursively), rather than replaced. However, a scalar value |
| 50 | *does* overwrite a dictionary or list value. While the scalar could be |
| 51 | appended to an existing list, there is sane default assumption in the context |
| 52 | of a dictionary, so this behaviour seems the most logical. |
| 53 | |
| 54 | Parameter interpolation |
| 55 | ------------------------ |
| 56 | Parameters may reference each other, including deep references, e.g.:: |
| 57 | |
| 58 | parameters: |
| 59 | location: Munich, Germany |
| 60 | motd: |
| 61 | header: This node sits in ${location} |
| 62 | for_demonstration: ${motd:header} |
| 63 | dict_reference: ${motd} |
| 64 | |
| 65 | After merging and interpolation, which happens automatically inside the |
| 66 | storage modules, the ``for_demonstration`` parameter will have a value of |
| 67 | "This node sits in Munich, Germany". |
| 68 | |
| 69 | Types are preserved if the value contains nothing but a reference. Hence, the |
| 70 | value of ``dict_reference`` will actually be a dictionary. |
| 71 | |
| 72 | You should now be ready to :doc:`use reclass <usage>`! |
| 73 | |
| 74 | .. include:: substs.inc |