blob: 4fe8e0fbb1e0270ebf722be60e057073e775c7f6 [file] [log] [blame]
martin f. krafft42c475d2013-06-26 18:39:06 +02001=============================================================
2 reclass recursive external node classification
3=============================================================
4reclass is © 20072013 martin f. krafft <madduck@madduck.net>
5and available under the terms of the Artistic Licence 2.0
6'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
7
8Please make sure to read the generic information in the README file first, or
9alongside this document.
10
11Quick start with Salt
12~~~~~~~~~~~~~~~~~~~~~
13The following steps should get you up and running quickly. You will need to
14decide for yourself where to put your reclass inventory. This can be
martin f. krafft30943272013-07-04 08:32:00 +020015your first base file_root (the default), or it could be /etc/reclass, or
16/srv/salt. The following shall assume the latter.
martin f. krafft42c475d2013-06-26 18:39:06 +020017
18Or you can also just look into ./examples/salt of your reclass checkout,
19where the following steps have already been prepared.
20
21/…/reclass refers to the location of your reclass checkout.
22
martin f. krafft30943272013-07-04 08:32:00 +020023 0. Complete the installation steps described in the section 'Installation'
24 in the main README file.
martin f. krafft367532c2013-06-26 21:08:18 +020025
martin f. krafft30943272013-07-04 08:32:00 +020026 Alternatively, you can also tell Salt via the master config file where to
27 look for reclass, but then you won't be able to interact with reclass
28 through the command line.
martin f. krafft42c475d2013-06-26 18:39:06 +020029
martin f. krafft30943272013-07-04 08:32:00 +020030 1. Copy the two directories 'nodes' and 'classes' from the example
31 subdirectory in the reclass checkout to e.g. /srv/salt.
martin f. krafft42c475d2013-06-26 18:39:06 +020032
martin f. krafft30943272013-07-04 08:32:00 +020033 It's handy to symlink reclass' Salt adapter itself to that directory.
34
35 $ ln -s $(which salt-reclass) /srv/salt/states/reclass
36
37 As you can now just inspect the data right there from the command line:
38
39 $ ./reclass --top
40
41 If you don't want to do this, you can also let reclass know where to look
42 for the inventory with the following contents in
43 $HOME/reclass-config.yml:
martin f. krafft42c475d2013-06-26 18:39:06 +020044
45 storage_type: yaml_fs
46 nodes_uri: /srv/reclass/nodes
47 classes_uri: /srv/reclass/classes
48
martin f. krafft30943272013-07-04 08:32:00 +020049 Or you can reuse the first entry of 'file_roots' under 'base' in the Salt
50 master config.
51
martin f. krafft42c475d2013-06-26 18:39:06 +020052 Note that yaml_fs is currently the only supported storage_type, and it's
53 the default if you don't set it.
54
martin f. krafft30943272013-07-04 08:32:00 +020055 2. Check out your inventory by invoking
martin f. krafft367532c2013-06-26 21:08:18 +020056
martin f. krafft30943272013-07-04 08:32:00 +020057 $ salt-reclass --top
martin f. krafft42c475d2013-06-26 18:39:06 +020058
martin f. krafft367532c2013-06-26 21:08:18 +020059 which should return all the information about all defined nodes, which is
60 only 'localhost' in the example. This is essentially the same information
61 that you would keep in your top.sls file.
martin f. krafft42c475d2013-06-26 18:39:06 +020062
martin f. krafft30943272013-07-04 08:32:00 +020063 If you symlinked the script to your inventory base directory, use
martin f. krafft42c475d2013-06-26 18:39:06 +020064
martin f. krafft30943272013-07-04 08:32:00 +020065 $ ./reclass --top
martin f. krafft42c475d2013-06-26 18:39:06 +020066
martin f. krafft30943272013-07-04 08:32:00 +020067 3. See the pillar information for 'localhost':
martin f. krafft42c475d2013-06-26 18:39:06 +020068
martin f. krafft30943272013-07-04 08:32:00 +020069 $ salt-reclass --pillar localhost
70
71 4. Now add reclass to /etc/salt/master, like so:
72
73 reclass: &reclass
74 inventory_base_uri: /srv/salt
75 reclass_source_path: ~/code/reclass
martin f. krafft42c475d2013-06-26 18:39:06 +020076
martin f. krafft367532c2013-06-26 21:08:18 +020077 master_tops:
martin f. krafft30943272013-07-04 08:32:00 +020078 […]
79 reclass: *reclass
martin f. krafft42c475d2013-06-26 18:39:06 +020080
martin f. krafft367532c2013-06-26 21:08:18 +020081 ext_pillar:
martin f. krafft30943272013-07-04 08:32:00 +020082 - reclass: *reclass
martin f. krafft367532c2013-06-26 21:08:18 +020083
martin f. krafft30943272013-07-04 08:32:00 +020084 If you did not install reclass, you can either specify the source path
85 like above, or you can add it to PYTHONPATH before invoking the Salt
86 master, to ensure that Python can find it:
martin f. krafft367532c2013-06-26 21:08:18 +020087
88 PYTHONPATH=/…/reclass /etc/init.d/salt-master restart
89
martin f. krafft30943272013-07-04 08:32:00 +020090 5. Provided that you have set up 'localhost' as a Salt minion, the following
martin f. krafft367532c2013-06-26 21:08:18 +020091 commands should now return the same data as above, but processed through
92 salt:
93
martin f. krafft30943272013-07-04 08:32:00 +020094 $ salt localhost pillar.items # shows just the parameters
95 $ salt localhost state.show_top # shows only the states (applications)
martin f. krafft367532c2013-06-26 21:08:18 +020096
97 Alternatively, if you don't have the Salt minion running yet:
98
martin f. krafft30943272013-07-04 08:32:00 +020099 # salt-call pillar.items # shows just the parameters
100 # salt-call state.show_top # shows only the states (applications)
martin f. krafft367532c2013-06-26 21:08:18 +0200101
martin f. krafft30943272013-07-04 08:32:00 +0200102 6. You can also invoke reclass directly, which gives a slightly different
martin f. krafft367532c2013-06-26 21:08:18 +0200103 view onto the same data, i.e. before it has been adapted for Salt:
martin f. krafft42c475d2013-06-26 18:39:06 +0200104
martin f. krafft30943272013-07-04 08:32:00 +0200105 $ reclass --inventory
106 $ reclass --nodeinfo localhost
martin f. krafft42c475d2013-06-26 18:39:06 +0200107
108Integration with Salt
109~~~~~~~~~~~~~~~~~~~~~
martin f. krafft367532c2013-06-26 21:08:18 +0200110reclass hooks into Salt at two different points: master_tops and ext_pillar.
111For both, Salt provides plugins. These plugins need to know where to find
martin f. krafft30943272013-07-04 08:32:00 +0200112reclass, so if reclass is not properly installed (but you are running it from
113source), make sure to export PYTHONPATH accordingly before you start your Salt
114master, or specify the path in the master configuration file, as show above.
martin f. krafft42c475d2013-06-26 18:39:06 +0200115
martin f. krafft367532c2013-06-26 21:08:18 +0200116Salt has no concept of "nodes", "applications", "parameters", and "classes".
117Therefore it is necessary to explain how those correspond to Salt. Crudely,
118the following mapping exists:
martin f. krafft42c475d2013-06-26 18:39:06 +0200119
120 nodes hosts
martin f. krafft367532c2013-06-26 21:08:18 +0200121 classes - [*]
122 applications states
123 parameters pillar
martin f. krafft42c475d2013-06-26 18:39:06 +0200124
martin f. krafft367532c2013-06-26 21:08:18 +0200125[*] See Salt issue #5787 for steps into the direction of letting reclass
126provide nodegroup information.
martin f. krafft42c475d2013-06-26 18:39:06 +0200127
martin f. krafft367532c2013-06-26 21:08:18 +0200128Whatever applications you define for a node will become states applicable to
129a host. If those applications are added via ancestor classes, then that's
130fine, but currently, Salt does not do anything with the classes ancestry.
martin f. krafft42c475d2013-06-26 18:39:06 +0200131
martin f. krafft367532c2013-06-26 21:08:18 +0200132Similarly, all parameters that are collected and merged eventually end up in
133the pillar data of a specific node.
martin f. krafft42c475d2013-06-26 18:39:06 +0200134
martin f. krafft367532c2013-06-26 21:08:18 +0200135However, the pillar data of a node include all the information about classes
136and applications, so you can use them to target your Salt calls at groups of
137nodes defined in the reclass inventory, e.g.
martin f. krafft42c475d2013-06-26 18:39:06 +0200138
martin f. krafft367532c2013-06-26 21:08:18 +0200139 salt -I __reclass__:classes:salt_minion test.ping
martin f. krafft42c475d2013-06-26 18:39:06 +0200140
martin f. krafft367532c2013-06-26 21:08:18 +0200141Unfortunately, this does not work yet, please stay tuned, and let me know
142if you figure out a way. Salt issue #5787 is also of relevance.
martin f. krafft42c475d2013-06-26 18:39:06 +0200143
martin f. krafftfa27b9a2013-08-07 16:07:14 +0200144 -- martin f. krafft <madduck@madduck.net> Wed, 07 Aug 2013 16:21:04 +0200