blob: 2cb9608662819273155dcf0e841eb2cb9c889c0d [file] [log] [blame]
Filip Pytloun49768a42015-10-06 16:28:32 +02001
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +03002=====
3Usage
4=====
Filip Pytloun49768a42015-10-06 16:28:32 +02005
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +03006Reclass is an external node classifier (ENC) as can be used with automation
Ales Komarek51e459c2017-02-19 08:47:46 +01007tools, such as Puppet, Salt, and Ansible. It is also a stand-alone tool for
8merging data sources recursively.
9
Ales Komareka4f836f2017-05-17 13:12:51 +020010Sample Metadata
11===============
Filip Pytloun49768a42015-10-06 16:28:32 +020012
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030013Install sources from [repository, git, pip]:
Petr Ruzickab4f74632017-11-16 15:47:07 +010014
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
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030030If reclass is pre-installed, set the engine to None to avoid updates:
Petr Ruzickab4f74632017-11-16 15:47:07 +010031
32.. code-block:: yaml
33
34 salt:
35 source:
36 engine: None
37
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030038Reclass storage with data fetched from git:
Petr Ruzickab4f74632017-11-16 15:47:07 +010039
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030040.. code-block:: yaml
Filip Pytloun49768a42015-10-06 16:28:32 +020041
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030042 See tests/pillar/storage_git.sls
Filip Pytloun49768a42015-10-06 16:28:32 +020043
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030044Reclass storage with local data source:
Filip Pytloun49768a42015-10-06 16:28:32 +020045
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030046.. code-block:: yaml
Filip Pytloun49768a42015-10-06 16:28:32 +020047
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030048 See tests/pillar/storage_local.sls
Ales Komarekf0942d72017-05-23 10:10:37 +020049
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030050Reclass storage with archive data source:
Ales Komarekf0942d72017-05-23 10:10:37 +020051
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030052.. code-block:: yaml
Ales Komarekf0942d72017-05-23 10:10:37 +020053
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030054 See tests/pillar/storage_archive.sls
Ales Komarekf0942d72017-05-23 10:10:37 +020055
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030056Reclass storage with archive data source with content hash check:
Ales Komareka4a9f572016-12-03 20:15:50 +010057
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030058.. code-block:: yaml
Ales Komareka4a9f572016-12-03 20:15:50 +010059
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030060 See tests/pillar/storage_archive_public.sls
Ales Komareka4a9f572016-12-03 20:15:50 +010061
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030062Reclass model with single node definition:
Ales Komareka4a9f572016-12-03 20:15:50 +010063
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030064.. code-block:: yaml
Ales Komarek968ebba2017-08-24 15:46:29 +020065
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030066 See tests/pillar/generate_single.sls
Ales Komarek968ebba2017-08-24 15:46:29 +020067
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030068Reclass model with multiple node defined:
Filip Pytloun49768a42015-10-06 16:28:32 +020069
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030070.. code-block:: yaml
71
72 See tests/pillar/generate_multi.sls
73
74Reclass model with multiple node defined and interpolation enabled:
75
76.. code-block:: yaml
77
78 See tests/pillar/generate_multi_interpolate.sls
79
80Reclass storage with simple class mappings:
81
82.. code-block:: yaml
83
84 See tests/pillar/class_mapping.sls
Filip Pytloun49768a42015-10-06 16:28:32 +020085
Ales Komareka4f836f2017-05-17 13:12:51 +020086Reclass models with dynamic node classification
Filip Pytloun49768a42015-10-06 16:28:32 +020087
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030088.. code-block:: yaml
Ales Komareka4f836f2017-05-17 13:12:51 +020089
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +030090 See tests/pillar/node_classify.sls
91
92Classify node after creation and unclassify on node deletion:
Ales Komarek052aea12017-08-21 14:17:32 +020093
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
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +0300104Event to trigger the node classification:
Ales Komarek052aea12017-08-21 14:17:32 +0200105
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 Karpina82b3e82018-08-06 15:52:07 +0300117Confirmation of node classification
118
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +0300119Currently, Salt does not allow getting confirmation on minion upon successful
120reactor execution on event. However, there can be issues with reactor in Salt
1212017.7 (https://github.com/saltstack/salt/issues/47539) or reactor register
122state can fail if pillar failed to render, so node registration confirmation
123may be needed. To enable this functionality, add the
124``node_confirm_registration`` parameter to event data with value ``true``:
Mykyta Karpina82b3e82018-08-06 15:52:07 +0300125
126.. code-block:: bash
127
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +0300128 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 Karpina82b3e82018-08-06 15:52:07 +0300129
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +0300130Then on minion side execute:
Ales Komarek052aea12017-08-21 14:17:32 +0200131
132.. code-block:: bash
133
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +0300134 salt-call mine.get 'salt:master' ${minion_id}_classified pillar
135
136If ``true`` is returned, then registration has passed successfully.
137
138
139Event to trigger the node declassification:
140
141.. code-block:: bash
142
143 salt-call event.send 'reclass/minion/declassify'
Ales Komarek052aea12017-08-21 14:17:32 +0200144
Dzmitry Stremkouskif81cf8f2018-04-18 19:26:31 +0200145Nodes definitions generator
146===========================
147
148Generate nodes definitions by running:
149
150.. code-block:: bash
151
152 salt-call state.sls reclass.storage -l debug
153
154Remove unnecessary files from nodes/_generated:
155
156.. code-block:: yaml
157
158 reclass:
159 storage:
160 reclass_nodes_cleanup: true
161
162Static 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
180Multiple 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 Komareka4f836f2017-05-17 13:12:51 +0200204
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +0300205Multiple nodes definitions (using generator) with IP address comprehension.
206Ranges are named and formatting symbol of the same name is replaced by IP
207address from the corresponding range:
Adam Tenglera2f260a2018-07-12 17:35:28 +0000208
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 Tengler82074b02018-08-10 15:58:06 +0000227 network_ranges:
228 sriov_address: '10.10.0.1/24-10.10.50.1/24'
Adam Tenglera2f260a2018-07-12 17:35:28 +0000229 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
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +0300240Read more
241=========
Filip Pytloun49768a42015-10-06 16:28:32 +0200242
243* http://reclass.pantsfullofunix.net/index.html
244* http://reclass.pantsfullofunix.net/operations.html
Ales Komarek51e459c2017-02-19 08:47:46 +0100245
Filip Pytloun2ea4e6a2017-02-02 13:02:03 +0100246Documentation and Bugs
247======================
248
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +0300249* http://salt-formulas.readthedocs.io/
250 Learn how to install and update salt-formulas
Filip Pytloun2ea4e6a2017-02-02 13:02:03 +0100251
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +0300252* 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 Pytloun2ea4e6a2017-02-02 13:02:03 +0100256
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +0300257* 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 Pytloun2ea4e6a2017-02-02 13:02:03 +0100260
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +0300261* https://launchpad.net/~salt-formulas-users
262 Join the salt-formulas-users team and subscribe to mailing list if required
Filip Pytloun2ea4e6a2017-02-02 13:02:03 +0100263
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +0300264* 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 Pytloun2ea4e6a2017-02-02 13:02:03 +0100267
OlgaGusarenkoaf7ffb22018-07-31 01:07:13 +0300268* #salt-formulas @ irc.freenode.net
269 Use this IRC channel in case of any questions or feedback which is always
270 welcome