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