martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 1 | ============================================================= |
| 2 | reclass — recursive external node classification |
| 3 | ============================================================= |
| 4 | reclass is © 2007–2013 martin f. krafft <madduck@madduck.net> |
| 5 | and available under the terms of the Artistic Licence 2.0 |
| 6 | ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
| 7 | |
| 8 | Please make sure to read the generic information in the README file first, or |
| 9 | alongside this document. |
| 10 | |
| 11 | Quick start with Salt |
| 12 | ~~~~~~~~~~~~~~~~~~~~~ |
| 13 | The following steps should get you up and running quickly. You will need to |
| 14 | decide for yourself where to put your reclass inventory. This can be |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 15 | your first base file_root (the default), or it could be /etc/reclass, or |
| 16 | /srv/salt. The following shall assume the latter. |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 17 | |
| 18 | Or you can also just look into ./examples/salt of your reclass checkout, |
| 19 | where the following steps have already been prepared. |
| 20 | |
| 21 | /…/reclass refers to the location of your reclass checkout. |
| 22 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 23 | 0. Complete the installation steps described in the section 'Installation' |
| 24 | in the main README file. |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 25 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 26 | 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. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 29 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 30 | 1. Copy the two directories 'nodes' and 'classes' from the example |
| 31 | subdirectory in the reclass checkout to e.g. /srv/salt. |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 32 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 33 | 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. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 44 | |
| 45 | storage_type: yaml_fs |
| 46 | nodes_uri: /srv/reclass/nodes |
| 47 | classes_uri: /srv/reclass/classes |
| 48 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 49 | Or you can reuse the first entry of 'file_roots' under 'base' in the Salt |
| 50 | master config. |
| 51 | |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 52 | 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. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 55 | 2. Check out your inventory by invoking |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 56 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 57 | $ salt-reclass --top |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 58 | |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 59 | 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. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 62 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 63 | If you symlinked the script to your inventory base directory, use |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 64 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 65 | $ ./reclass --top |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 66 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 67 | 3. See the pillar information for 'localhost': |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 68 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 69 | $ 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. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 76 | |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 77 | master_tops: |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 78 | […] |
| 79 | reclass: *reclass |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 80 | |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 81 | ext_pillar: |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 82 | - reclass: *reclass |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 83 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 84 | 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. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 87 | |
| 88 | PYTHONPATH=/…/reclass /etc/init.d/salt-master restart |
| 89 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 90 | 5. Provided that you have set up 'localhost' as a Salt minion, the following |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 91 | commands should now return the same data as above, but processed through |
| 92 | salt: |
| 93 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 94 | $ salt localhost pillar.items # shows just the parameters |
| 95 | $ salt localhost state.show_top # shows only the states (applications) |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 96 | |
| 97 | Alternatively, if you don't have the Salt minion running yet: |
| 98 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 99 | # salt-call pillar.items # shows just the parameters |
| 100 | # salt-call state.show_top # shows only the states (applications) |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 101 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 102 | 6. You can also invoke reclass directly, which gives a slightly different |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 103 | view onto the same data, i.e. before it has been adapted for Salt: |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 104 | |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 105 | $ reclass --inventory |
| 106 | $ reclass --nodeinfo localhost |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 107 | |
| 108 | Integration with Salt |
| 109 | ~~~~~~~~~~~~~~~~~~~~~ |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 110 | reclass hooks into Salt at two different points: master_tops and ext_pillar. |
| 111 | For both, Salt provides plugins. These plugins need to know where to find |
martin f. krafft | 3094327 | 2013-07-04 08:32:00 +0200 | [diff] [blame] | 112 | reclass, so if reclass is not properly installed (but you are running it from |
| 113 | source), make sure to export PYTHONPATH accordingly before you start your Salt |
| 114 | master, or specify the path in the master configuration file, as show above. |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 115 | |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 116 | Salt has no concept of "nodes", "applications", "parameters", and "classes". |
| 117 | Therefore it is necessary to explain how those correspond to Salt. Crudely, |
| 118 | the following mapping exists: |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 119 | |
| 120 | nodes hosts |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 121 | classes - [*] |
| 122 | applications states |
| 123 | parameters pillar |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 124 | |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 125 | [*] See Salt issue #5787 for steps into the direction of letting reclass |
| 126 | provide nodegroup information. |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 127 | |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 128 | Whatever applications you define for a node will become states applicable to |
| 129 | a host. If those applications are added via ancestor classes, then that's |
| 130 | fine, but currently, Salt does not do anything with the classes ancestry. |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 131 | |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 132 | Similarly, all parameters that are collected and merged eventually end up in |
| 133 | the pillar data of a specific node. |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 134 | |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 135 | However, the pillar data of a node include all the information about classes |
| 136 | and applications, so you can use them to target your Salt calls at groups of |
| 137 | nodes defined in the reclass inventory, e.g. |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 138 | |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 139 | salt -I __reclass__:classes:salt_minion test.ping |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 140 | |
martin f. krafft | 367532c | 2013-06-26 21:08:18 +0200 | [diff] [blame] | 141 | Unfortunately, this does not work yet, please stay tuned, and let me know |
| 142 | if you figure out a way. Salt issue #5787 is also of relevance. |
martin f. krafft | 42c475d | 2013-06-26 18:39:06 +0200 | [diff] [blame] | 143 | |
martin f. krafft | fa27b9a | 2013-08-07 16:07:14 +0200 | [diff] [blame^] | 144 | -- martin f. krafft <madduck@madduck.net> Wed, 07 Aug 2013 16:21:04 +0200 |