blob: 26e7723cbd05383636bfd5a254f6e9e81d7ddf96 [file] [log] [blame]
Filip Pytloun49768a42015-10-06 16:28:32 +02001
Aleš Komárek586daae2017-02-06 19:47:06 +01002===============
Ales Komareka4f836f2017-05-17 13:12:51 +02003Reclass Formula
Aleš Komárek586daae2017-02-06 19:47:06 +01004===============
Filip Pytloun49768a42015-10-06 16:28:32 +02005
Petr Ruzickab4f74632017-11-16 15:47:07 +01006reclass 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
Filip Pytloun49768a42015-10-06 16:28:32 +020010
Ales Komareka4f836f2017-05-17 13:12:51 +020011Sample Metadata
12===============
Filip Pytloun49768a42015-10-06 16:28:32 +020013
Petr Ruzickab4f74632017-11-16 15:47:07 +010014Install 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
32If 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 Pytloun49768a42015-10-06 16:28:32 +020041Reclass storage with data fetched from git
42
Ales Komarek51e459c2017-02-19 08:47:46 +010043.. literalinclude:: tests/pillar/storage_git.sls
44 :language: yaml
Filip Pytloun49768a42015-10-06 16:28:32 +020045
46Reclass storage with local data source
47
Ales Komarek51e459c2017-02-19 08:47:46 +010048.. literalinclude:: tests/pillar/storage_local.sls
49 :language: yaml
Filip Pytloun49768a42015-10-06 16:28:32 +020050
Ales Komarekf0942d72017-05-23 10:10:37 +020051Reclass storage with archive data source
52
53.. literalinclude:: tests/pillar/storage_archive.sls
54 :language: yaml
55
56Reclass storage with archive data source with content hash check
57
58.. literalinclude:: tests/pillar/storage_archive_public.sls
59 :language: yaml
60
Ales Komareka4a9f572016-12-03 20:15:50 +010061Reclass model with single node definition
62
Ales Komarek51e459c2017-02-19 08:47:46 +010063.. literalinclude:: tests/pillar/generate_single.sls
64 :language: yaml
Ales Komareka4a9f572016-12-03 20:15:50 +010065
66Reclass model with multiple node defined
67
Ales Komarek51e459c2017-02-19 08:47:46 +010068.. literalinclude:: tests/pillar/generate_multi.sls
69 :language: yaml
Ales Komareka4a9f572016-12-03 20:15:50 +010070
Ales Komarek968ebba2017-08-24 15:46:29 +020071Reclass model with multiple node defined and interpolation enabled
72
73.. literalinclude:: tests/pillar/generate_multi_interpolate.sls
74 :language: yaml
75
Ales Komareka4f836f2017-05-17 13:12:51 +020076Reclass storage with simple class mappings
Filip Pytloun49768a42015-10-06 16:28:32 +020077
Ales Komarek51e459c2017-02-19 08:47:46 +010078.. literalinclude:: tests/pillar/class_mapping.sls
79 :language: yaml
Filip Pytloun49768a42015-10-06 16:28:32 +020080
Ales Komareka4f836f2017-05-17 13:12:51 +020081Reclass models with dynamic node classification
Filip Pytloun49768a42015-10-06 16:28:32 +020082
Ales Komareka4f836f2017-05-17 13:12:51 +020083.. literalinclude:: tests/pillar/node_classify.sls
84 :language: yaml
85
Ales Komarek052aea12017-08-21 14:17:32 +020086Classify 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
98Event 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 Karpina82b3e82018-08-06 15:52:07 +0300111Confirmation 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 Komarek052aea12017-08-21 14:17:32 +0200127Event to trigger the node declassification
128
129.. code-block:: bash
130
131 salt-call event.send 'reclass/minion/declassify'
132
Dzmitry Stremkouskif81cf8f2018-04-18 19:26:31 +0200133Nodes definitions generator
134===========================
135
136Generate nodes definitions by running:
137
138.. code-block:: bash
139
140 salt-call state.sls reclass.storage -l debug
141
142Remove unnecessary files from nodes/_generated:
143
144.. code-block:: yaml
145
146 reclass:
147 storage:
148 reclass_nodes_cleanup: true
149
150Static 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
168Multiple 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 Komareka4f836f2017-05-17 13:12:51 +0200192
Adam Tenglera2f260a2018-07-12 17:35:28 +0000193Multiple 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 Komareka4f836f2017-05-17 13:12:51 +0200224More Information
225================
Filip Pytloun49768a42015-10-06 16:28:32 +0200226
227* http://reclass.pantsfullofunix.net/index.html
228* http://reclass.pantsfullofunix.net/operations.html
Ales Komarek51e459c2017-02-19 08:47:46 +0100229
Filip Pytloun2ea4e6a2017-02-02 13:02:03 +0100230
231Documentation and Bugs
232======================
233
234To learn how to install and update salt-formulas, consult the documentation
235available online at:
236
237 http://salt-formulas.readthedocs.io/
238
239In the unfortunate event that bugs are discovered, they should be reported to
240the appropriate issue tracker. Use Github issue tracker for specific salt
241formula:
242
243 https://github.com/salt-formulas/salt-formula-reclass/issues
244
245For feature requests, bug reports or blueprints affecting entire ecosystem,
246use Launchpad salt-formulas project:
247
248 https://launchpad.net/salt-formulas
249
250You can also join salt-formulas-users team and subscribe to mailing list:
251
252 https://launchpad.net/~salt-formulas-users
253
254Developers wishing to work on the salt-formulas projects should always base
255their work on master branch and submit pull request against specific formula.
256
257 https://github.com/salt-formulas/salt-formula-reclass
258
259Any questions or feedback is always welcome so feel free to join our IRC
260channel:
261
262 #salt-formulas @ irc.freenode.net