Filip Pytloun | 49768a4 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 2 | ===== |
| 3 | Usage |
| 4 | ===== |
Filip Pytloun | 49768a4 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 5 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 6 | Reclass is an external node classifier (ENC) as can be used with automation |
Ales Komarek | 51e459c | 2017-02-19 08:47:46 +0100 | [diff] [blame] | 7 | tools, such as Puppet, Salt, and Ansible. It is also a stand-alone tool for |
| 8 | merging data sources recursively. |
| 9 | |
Ales Komarek | a4f836f | 2017-05-17 13:12:51 +0200 | [diff] [blame] | 10 | Sample Metadata |
| 11 | =============== |
Filip Pytloun | 49768a4 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 12 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 13 | Install sources from [repository, git, pip]: |
Petr Ruzicka | b4f7463 | 2017-11-16 15:47:07 +0100 | [diff] [blame] | 14 | |
| 15 | .. code-block:: yaml |
| 16 | |
| 17 | salt: |
| 18 | source: |
| 19 | engine: pkg |
| 20 | ... |
| 21 | source: |
| 22 | engine: git |
| 23 | repo: git+https://github.com/salt-formulas/reclass |
| 24 | branch: master |
| 25 | ... |
| 26 | source: |
| 27 | engine: pip |
| 28 | ... |
| 29 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 30 | If reclass is pre-installed, set the engine to None to avoid updates: |
Petr Ruzicka | b4f7463 | 2017-11-16 15:47:07 +0100 | [diff] [blame] | 31 | |
| 32 | .. code-block:: yaml |
| 33 | |
| 34 | salt: |
| 35 | source: |
| 36 | engine: None |
| 37 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 38 | Reclass storage with data fetched from git: |
Petr Ruzicka | b4f7463 | 2017-11-16 15:47:07 +0100 | [diff] [blame] | 39 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 40 | .. code-block:: yaml |
Filip Pytloun | 49768a4 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 41 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 42 | See tests/pillar/storage_git.sls |
Filip Pytloun | 49768a4 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 43 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 44 | Reclass storage with local data source: |
Filip Pytloun | 49768a4 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 45 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 46 | .. code-block:: yaml |
Filip Pytloun | 49768a4 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 47 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 48 | See tests/pillar/storage_local.sls |
Ales Komarek | f0942d7 | 2017-05-23 10:10:37 +0200 | [diff] [blame] | 49 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 50 | Reclass storage with archive data source: |
Ales Komarek | f0942d7 | 2017-05-23 10:10:37 +0200 | [diff] [blame] | 51 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 52 | .. code-block:: yaml |
Ales Komarek | f0942d7 | 2017-05-23 10:10:37 +0200 | [diff] [blame] | 53 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 54 | See tests/pillar/storage_archive.sls |
Ales Komarek | f0942d7 | 2017-05-23 10:10:37 +0200 | [diff] [blame] | 55 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 56 | Reclass storage with archive data source with content hash check: |
Ales Komarek | a4a9f57 | 2016-12-03 20:15:50 +0100 | [diff] [blame] | 57 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 58 | .. code-block:: yaml |
Ales Komarek | a4a9f57 | 2016-12-03 20:15:50 +0100 | [diff] [blame] | 59 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 60 | See tests/pillar/storage_archive_public.sls |
Ales Komarek | a4a9f57 | 2016-12-03 20:15:50 +0100 | [diff] [blame] | 61 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 62 | Reclass model with single node definition: |
Ales Komarek | a4a9f57 | 2016-12-03 20:15:50 +0100 | [diff] [blame] | 63 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 64 | .. code-block:: yaml |
Ales Komarek | 968ebba | 2017-08-24 15:46:29 +0200 | [diff] [blame] | 65 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 66 | See tests/pillar/generate_single.sls |
Ales Komarek | 968ebba | 2017-08-24 15:46:29 +0200 | [diff] [blame] | 67 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 68 | Reclass model with multiple node defined: |
Filip Pytloun | 49768a4 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 69 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 70 | .. code-block:: yaml |
| 71 | |
| 72 | See tests/pillar/generate_multi.sls |
| 73 | |
| 74 | Reclass model with multiple node defined and interpolation enabled: |
| 75 | |
| 76 | .. code-block:: yaml |
| 77 | |
| 78 | See tests/pillar/generate_multi_interpolate.sls |
| 79 | |
| 80 | Reclass storage with simple class mappings: |
| 81 | |
| 82 | .. code-block:: yaml |
| 83 | |
| 84 | See tests/pillar/class_mapping.sls |
Filip Pytloun | 49768a4 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 85 | |
Ales Komarek | a4f836f | 2017-05-17 13:12:51 +0200 | [diff] [blame] | 86 | Reclass models with dynamic node classification |
Filip Pytloun | 49768a4 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 87 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 88 | .. code-block:: yaml |
Ales Komarek | a4f836f | 2017-05-17 13:12:51 +0200 | [diff] [blame] | 89 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 90 | See tests/pillar/node_classify.sls |
| 91 | |
| 92 | Classify node after creation and unclassify on node deletion: |
Ales Komarek | 052aea1 | 2017-08-21 14:17:32 +0200 | [diff] [blame] | 93 | |
| 94 | .. code-block:: yaml |
| 95 | |
| 96 | salt: |
| 97 | master: |
| 98 | reactor: |
| 99 | reclass/minion/classify: |
| 100 | - salt://reclass/reactor/node_register.sls |
| 101 | reclass/minion/declassify: |
| 102 | - salt://reclass/reactor/node_unregister.sls |
| 103 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 104 | Event to trigger the node classification: |
Ales Komarek | 052aea1 | 2017-08-21 14:17:32 +0200 | [diff] [blame] | 105 | |
| 106 | .. code-block:: bash |
| 107 | |
| 108 | salt-call event.send 'reclass/minion/classify' "{'node_master_ip': '$config_host', 'node_ip': '${node_ip}', 'node_domain': '$node_domain', 'node_cluster': '$node_cluster', 'node_hostname': '$node_hostname', 'node_os': '$node_os'}" |
| 109 | |
| 110 | .. note:: |
| 111 | |
| 112 | You can send any parameters in the event payload, all will be checked |
| 113 | against dynamic node classification conditions. |
| 114 | |
| 115 | Both actions will use the minion ID as the node_name to be updated. |
| 116 | |
Mykyta Karpin | a82b3e8 | 2018-08-06 15:52:07 +0300 | [diff] [blame] | 117 | Confirmation of node classification |
| 118 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 119 | Currently, Salt does not allow getting confirmation on minion upon successful |
| 120 | reactor execution on event. However, there can be issues with reactor in Salt |
| 121 | 2017.7 (https://github.com/saltstack/salt/issues/47539) or reactor register |
| 122 | state can fail if pillar failed to render, so node registration confirmation |
| 123 | may be needed. To enable this functionality, add the |
| 124 | ``node_confirm_registration`` parameter to event data with value ``true``: |
Mykyta Karpin | a82b3e8 | 2018-08-06 15:52:07 +0300 | [diff] [blame] | 125 | |
| 126 | .. code-block:: bash |
| 127 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 128 | salt-call event.send 'reclass/minion/classify' "{'node_master_ip': '$config_host', 'node_ip': '${node_ip}', 'node_domain': '$node_domain', 'node_cluster': '$node_cluster', 'node_hostname': '$node_hostname', 'node_os': '$node_os', node_confirm_registration: true}" |
Mykyta Karpin | a82b3e8 | 2018-08-06 15:52:07 +0300 | [diff] [blame] | 129 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 130 | Then on minion side execute: |
Ales Komarek | 052aea1 | 2017-08-21 14:17:32 +0200 | [diff] [blame] | 131 | |
| 132 | .. code-block:: bash |
| 133 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 134 | salt-call mine.get 'salt:master' ${minion_id}_classified pillar |
| 135 | |
| 136 | If ``true`` is returned, then registration has passed successfully. |
| 137 | |
| 138 | |
| 139 | Event to trigger the node declassification: |
| 140 | |
| 141 | .. code-block:: bash |
| 142 | |
| 143 | salt-call event.send 'reclass/minion/declassify' |
Ales Komarek | 052aea1 | 2017-08-21 14:17:32 +0200 | [diff] [blame] | 144 | |
Dzmitry Stremkouski | f81cf8f | 2018-04-18 19:26:31 +0200 | [diff] [blame] | 145 | Nodes definitions generator |
| 146 | =========================== |
| 147 | |
| 148 | Generate nodes definitions by running: |
| 149 | |
| 150 | .. code-block:: bash |
| 151 | |
| 152 | salt-call state.sls reclass.storage -l debug |
| 153 | |
| 154 | Remove unnecessary files from nodes/_generated: |
| 155 | |
| 156 | .. code-block:: yaml |
| 157 | |
| 158 | reclass: |
| 159 | storage: |
| 160 | reclass_nodes_cleanup: true |
| 161 | |
| 162 | Static node definition: |
| 163 | |
| 164 | .. code-block:: yaml |
| 165 | |
| 166 | reclass: |
| 167 | storage: |
| 168 | enabled: true |
| 169 | node: |
| 170 | openstack_benchmark_node01: |
| 171 | classes: |
| 172 | - cluster.example.openstack.benchmark |
| 173 | domain: example.com |
| 174 | name: bmk01 |
| 175 | params: |
| 176 | linux_system_codename: xenial |
| 177 | salt_master_host: 192.168.0.253 |
| 178 | single_address: 192.168.2.95 |
| 179 | |
| 180 | Multiple nodes definitions (using generator): |
| 181 | |
| 182 | .. code-block:: yaml |
| 183 | |
| 184 | reclass: |
| 185 | storage: |
| 186 | enabled: true |
| 187 | node: |
| 188 | openstack_compute_rack01: |
| 189 | classes: |
| 190 | - cluster.example.openstack.compute |
| 191 | domain: example.com |
| 192 | name: cmp<<count>> |
| 193 | params: |
| 194 | linux_system_codename: xenial |
| 195 | salt_master_host: 192.168.0.253 |
| 196 | repeat: |
| 197 | start: 1 |
| 198 | count: 50 |
| 199 | digits: 3 |
| 200 | params: |
| 201 | single_address: |
| 202 | start: 101 |
| 203 | value: 192.168.2.<<count>> |
Ales Komarek | a4f836f | 2017-05-17 13:12:51 +0200 | [diff] [blame] | 204 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 205 | Multiple nodes definitions (using generator) with IP address comprehension. |
| 206 | Ranges are named and formatting symbol of the same name is replaced by IP |
| 207 | address from the corresponding range: |
Adam Tengler | a2f260a | 2018-07-12 17:35:28 +0000 | [diff] [blame] | 208 | |
| 209 | .. code-block:: yaml |
| 210 | |
| 211 | reclass: |
| 212 | storage: |
| 213 | enabled: true |
| 214 | node: |
| 215 | openstack_compute_rack01: |
| 216 | classes: |
| 217 | - cluster.example.openstack.compute |
| 218 | domain: example.com |
| 219 | name: cmp<<count>> |
| 220 | params: |
| 221 | linux_system_codename: xenial |
| 222 | salt_master_host: 192.168.0.253 |
| 223 | repeat: |
| 224 | ip_ranges: |
| 225 | single_address: '172.16.10.97-172.16.10.98' |
| 226 | tenant_address: '172.16.20.97-172.16.20.98' |
Adam Tengler | 82074b0 | 2018-08-10 15:58:06 +0000 | [diff] [blame] | 227 | network_ranges: |
| 228 | sriov_address: '10.10.0.1/24-10.10.50.1/24' |
Adam Tengler | a2f260a | 2018-07-12 17:35:28 +0000 | [diff] [blame] | 229 | start: 1 |
| 230 | count: 50 |
| 231 | digits: 3 |
| 232 | params: |
| 233 | single_address: |
| 234 | start: 101 |
| 235 | value: 192.168.2.<<single_address>> |
| 236 | tenant_address: |
| 237 | start: 101 |
| 238 | value: 192.168.2.<<tenant_address>> |
| 239 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 240 | Read more |
| 241 | ========= |
Filip Pytloun | 49768a4 | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 242 | |
| 243 | * http://reclass.pantsfullofunix.net/index.html |
| 244 | * http://reclass.pantsfullofunix.net/operations.html |
Ales Komarek | 51e459c | 2017-02-19 08:47:46 +0100 | [diff] [blame] | 245 | |
Filip Pytloun | 2ea4e6a | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 246 | Documentation and Bugs |
| 247 | ====================== |
| 248 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 249 | * http://salt-formulas.readthedocs.io/ |
| 250 | Learn how to install and update salt-formulas |
Filip Pytloun | 2ea4e6a | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 251 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 252 | * https://github.com/salt-formulas/salt-formula-reclass/issues |
| 253 | In the unfortunate event that bugs are discovered, report the issue to the |
| 254 | appropriate issue tracker. Use the Github issue tracker for a specific salt |
| 255 | formula |
Filip Pytloun | 2ea4e6a | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 256 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 257 | * https://launchpad.net/salt-formulas |
| 258 | For feature requests, bug reports, or blueprints affecting the entire |
| 259 | ecosystem, use the Launchpad salt-formulas project |
Filip Pytloun | 2ea4e6a | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 260 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 261 | * https://launchpad.net/~salt-formulas-users |
| 262 | Join the salt-formulas-users team and subscribe to mailing list if required |
Filip Pytloun | 2ea4e6a | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 263 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 264 | * https://github.com/salt-formulas/salt-formula-reclass |
| 265 | Develop the salt-formulas projects in the master branch and then submit pull |
| 266 | requests against a specific formula |
Filip Pytloun | 2ea4e6a | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 267 | |
OlgaGusarenko | af7ffb2 | 2018-07-31 01:07:13 +0300 | [diff] [blame] | 268 | * #salt-formulas @ irc.freenode.net |
| 269 | Use this IRC channel in case of any questions or feedback which is always |
| 270 | welcome |