blob: 1b61ae17e30e0e490a149e044129942618ae388c [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
111Event to trigger the node declassification
112
113.. code-block:: bash
114
115 salt-call event.send 'reclass/minion/declassify'
116
Dzmitry Stremkouskif81cf8f2018-04-18 19:26:31 +0200117Nodes definitions generator
118===========================
119
120Generate nodes definitions by running:
121
122.. code-block:: bash
123
124 salt-call state.sls reclass.storage -l debug
125
126Remove unnecessary files from nodes/_generated:
127
128.. code-block:: yaml
129
130 reclass:
131 storage:
132 reclass_nodes_cleanup: true
133
134Static node definition:
135
136.. code-block:: yaml
137
138 reclass:
139 storage:
140 enabled: true
141 node:
142 openstack_benchmark_node01:
143 classes:
144 - cluster.example.openstack.benchmark
145 domain: example.com
146 name: bmk01
147 params:
148 linux_system_codename: xenial
149 salt_master_host: 192.168.0.253
150 single_address: 192.168.2.95
151
152Multiple nodes definitions (using generator):
153
154.. code-block:: yaml
155
156 reclass:
157 storage:
158 enabled: true
159 node:
160 openstack_compute_rack01:
161 classes:
162 - cluster.example.openstack.compute
163 domain: example.com
164 name: cmp<<count>>
165 params:
166 linux_system_codename: xenial
167 salt_master_host: 192.168.0.253
168 repeat:
169 start: 1
170 count: 50
171 digits: 3
172 params:
173 single_address:
174 start: 101
175 value: 192.168.2.<<count>>
Ales Komareka4f836f2017-05-17 13:12:51 +0200176
177More Information
178================
Filip Pytloun49768a42015-10-06 16:28:32 +0200179
180* http://reclass.pantsfullofunix.net/index.html
181* http://reclass.pantsfullofunix.net/operations.html
Ales Komarek51e459c2017-02-19 08:47:46 +0100182
Filip Pytloun2ea4e6a2017-02-02 13:02:03 +0100183
184Documentation and Bugs
185======================
186
187To learn how to install and update salt-formulas, consult the documentation
188available online at:
189
190 http://salt-formulas.readthedocs.io/
191
192In the unfortunate event that bugs are discovered, they should be reported to
193the appropriate issue tracker. Use Github issue tracker for specific salt
194formula:
195
196 https://github.com/salt-formulas/salt-formula-reclass/issues
197
198For feature requests, bug reports or blueprints affecting entire ecosystem,
199use Launchpad salt-formulas project:
200
201 https://launchpad.net/salt-formulas
202
203You can also join salt-formulas-users team and subscribe to mailing list:
204
205 https://launchpad.net/~salt-formulas-users
206
207Developers wishing to work on the salt-formulas projects should always base
208their work on master branch and submit pull request against specific formula.
209
210 https://github.com/salt-formulas/salt-formula-reclass
211
212Any questions or feedback is always welcome so feel free to join our IRC
213channel:
214
215 #salt-formulas @ irc.freenode.net