blob: e4317eed91912bcb249e297c30b874644025d8c0 [file] [log] [blame]
Filip Pytlounb4b80592015-10-06 16:28:32 +02001
Ales Komarek54740682017-05-15 07:16:23 +02002============
3Salt Formula
4============
Filip Pytlounb4b80592015-10-06 16:28:32 +02005
Ales Komarek54740682017-05-15 07:16:23 +02006Salt is a new approach to infrastructure management. Easy enough to get
7running in minutes, scalable enough to manage tens of thousands of servers,
8and fast enough to communicate with them in seconds.
Filip Pytlounb4b80592015-10-06 16:28:32 +02009
Ales Komarek54740682017-05-15 07:16:23 +020010Salt delivers a dynamic communication bus for infrastructures that can be used
11for orchestration, remote execution, configuration management and much more.
Filip Pytlounb4b80592015-10-06 16:28:32 +020012
Ales Komarek54740682017-05-15 07:16:23 +020013
14Sample Metadata
15===============
16
Filip Pytlounb4b80592015-10-06 16:28:32 +020017
18Salt master
19-----------
20
Ales Komarek54740682017-05-15 07:16:23 +020021Salt master with base formulas and pillar metadata backend
Filip Pytlounb4b80592015-10-06 16:28:32 +020022
Ales Komarek8ba9c0b2016-02-21 14:59:59 +010023.. literalinclude:: tests/pillar/master_single_pillar.sls
24 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +020025
Ales Komarek54740682017-05-15 07:16:23 +020026Salt master with reclass ENC metadata backend
Filip Pytlounb4b80592015-10-06 16:28:32 +020027
Ales Komarek8ba9c0b2016-02-21 14:59:59 +010028.. literalinclude:: tests/pillar/master_single_reclass.sls
29 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +020030
Petr Michalec1f541c42017-08-17 13:30:37 +020031Salt master with multiple ext_pillars
32
33.. literalinclude:: tests/pillar/master_single_extpillars.sls
34 :language: yaml
35
Filip Pytlounb4b80592015-10-06 16:28:32 +020036Salt master with API
37
Ales Komarekb2c8ff62016-08-22 00:20:01 +020038.. literalinclude:: tests/pillar/master_api.sls
39 :language: yaml
Ales Komarekcdb280f2016-07-27 15:37:51 +020040
41Salt master with defined user ACLs
42
Ales Komarekb2c8ff62016-08-22 00:20:01 +020043.. literalinclude:: tests/pillar/master_acl.sls
44 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +020045
46Salt master with preset minions
47
48.. code-block:: yaml
49
50 salt:
51 master:
52 enabled: true
Filip Pytlounb4b80592015-10-06 16:28:32 +020053 minions:
54 - name: 'node1.system.location.domain.com'
55
Ales Komarek54740682017-05-15 07:16:23 +020056Salt master with pip based installation (optional)
Adam Tenglercaedd972016-05-04 16:44:00 +020057
58.. code-block:: yaml
59
60 salt:
61 master:
62 enabled: true
63 ...
64 source:
65 engine: pip
66 version: 2016.3.0rc2
67
Ales Komarek54740682017-05-15 07:16:23 +020068Install formula through system package management
Adam Tengler3eb85ad2016-05-06 02:52:40 +020069
70.. code-block:: yaml
71
72 salt:
73 master:
74 enabled: true
75 ...
76 environment:
77 prd:
Petr Michalec7a2f1d22017-05-17 22:08:32 +020078 keystone:
Adam Tengler3eb85ad2016-05-06 02:52:40 +020079 source: pkg
80 name: salt-formula-keystone
Petr Michalec7a2f1d22017-05-17 22:08:32 +020081 nova:
82 source: pkg
83 name: salt-formula-keystone
84 version: 0.1+0~20160818133412.24~1.gbp6e1ebb
85 postresql:
86 source: pkg
87 name: salt-formula-postgresql
88 version: purged
89
90Formula keystone is installed latest version and the formulas without version are installed in one call to aptpkg module.
91If the version attribute is present sls iterates over formulas and take action to install specific version or remove it.
92The version attribute may have these values ``[latest|purged|removed|<VERSION>]``.
Adam Tengler3eb85ad2016-05-06 02:52:40 +020093
94Clone master branch of keystone formula as local feature branch
95
96.. code-block:: yaml
97
98 salt:
99 master:
100 enabled: true
101 ...
102 environment:
103 dev:
104 formula:
105 keystone:
106 source: git
107 address: git@github.com:openstack/salt-formula-keystone.git
108 revision: master
109 branch: feature
110
111Salt master with specified formula refs (for example for Gerrit review)
112
113.. code-block:: yaml
114
115 salt:
116 master:
117 enabled: true
118 ...
119 environment:
120 dev:
121 formula:
122 keystone:
123 source: git
124 address: https://git.openstack.org/openstack/salt-formula-keystone
125 revision: refs/changes/56/123456/1
126
Ales Komarek54740682017-05-15 07:16:23 +0200127Salt master with logging handlers
Filip Pytlounb4b80592015-10-06 16:28:32 +0200128
129.. code-block:: yaml
130
131 salt:
132 master:
133 enabled: true
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100134 handler:
135 handler01:
136 engine: udp
137 bind:
138 host: 127.0.0.1
139 port: 9999
Filip Pytlounb4b80592015-10-06 16:28:32 +0200140 minion:
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100141 handler:
142 handler01:
143 engine: udp
144 bind:
145 host: 127.0.0.1
146 port: 9999
147 handler02:
148 engine: zmq
149 bind:
150 host: 127.0.0.1
151 port: 9999
152
Ales Komarek54740682017-05-15 07:16:23 +0200153Salt master peer setup for remote certificate signing
Jakub Pavlikd4859842016-05-23 10:48:04 +0200154
155.. code-block:: yaml
156
157 salt:
158 master:
159 peer:
160 ".*":
161 - x509.sign_remote_certificate
Filip Pytlounb4b80592015-10-06 16:28:32 +0200162
Tomáš Kukrál8922aef2017-05-10 10:27:04 +0200163Configure verbosity of state output (used for `salt` command)
164
165.. code-block:: yaml
166
167 salt:
168 master:
Tomáš Kukrál044667b2017-05-11 10:12:15 +0200169 state_output: changes
Tomáš Kukrál8922aef2017-05-10 10:27:04 +0200170
Petr Michalec1f541c42017-08-17 13:30:37 +0200171
Ales Komareke7844d12017-06-08 12:00:01 +0200172Salt synchronise node pillar and modules after start
Ales Komarek54740682017-05-15 07:16:23 +0200173
174.. code-block:: yaml
175
176 salt:
177 master:
178 reactor:
179 salt/minion/*/start:
Ales Komareke7844d12017-06-08 12:00:01 +0200180 - salt://salt/reactor/node_start.sls
Ales Komarek54740682017-05-15 07:16:23 +0200181
Ales Komareke7844d12017-06-08 12:00:01 +0200182Trigger basic node install
183
184.. code-block:: yaml
185
186 salt:
187 master:
188 reactor:
189 salt/minion/install:
190 - salt://salt/reactor/node_install.sls
191
192Sample event to trigger the node installation
193
194.. code-block:: bash
195
196 salt-call event.send 'salt/minion/install'
197
198Run any orchestration pipeline
Ales Komarek5c58de32017-06-06 11:49:32 +0200199
200.. code-block:: yaml
201
202 salt:
203 master:
204 reactor:
205 salt/orchestrate/start:
206 - salt://salt/reactor/orchestrate_start.sls
207
Ales Komareke7844d12017-06-08 12:00:01 +0200208Event to trigger the orchestration pipeline
Ales Komarek5c58de32017-06-06 11:49:32 +0200209
210.. code-block:: bash
211
Ales Komareke7844d12017-06-08 12:00:01 +0200212 salt-call event.send 'salt/orchestrate/start' "{'orchestrate': 'salt/orchestrate/infra_install.sls'}"
Ales Komarek5c58de32017-06-06 11:49:32 +0200213
Ales Komareke7844d12017-06-08 12:00:01 +0200214Classify node after start
Ales Komarek5c58de32017-06-06 11:49:32 +0200215
216.. code-block:: yaml
217
218 salt:
219 master:
220 reactor:
221 reclass/minion/classify:
222 - salt://reclass/reactor/node_register.sls
223
Ales Komareke7844d12017-06-08 12:00:01 +0200224Event to trigger the node classification
Ales Komarek5c58de32017-06-06 11:49:32 +0200225
226.. code-block:: bash
227
228 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'}"
229
Ales Komarek54740682017-05-15 07:16:23 +0200230
Petr Michalec1f541c42017-08-17 13:30:37 +0200231
232Encrypted pillars
233-----------------
234
235Note: NACL + below configuration will be available in Salt > 2017.7.
236
237External resources:
238
239- Tutorial to configure salt + reclass ext_pillar and nacl: http://apealive.net/post/2017-09-salt-nacl-ext-pillar/
240- Saltstack documentation: https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.nacl.html
241
242Configure salt NACL module:
243
244.. code-block:: shell
245
246 pip install --upgrade libnacl===1.5.2
247 salt-call --local nacl.keygen /etc/salt/pki/master/nacl
248
249 local:
250 saved sk_file:/etc/salt/pki/master/nacl pk_file: /etc/salt/pki/master/nacl.pub
251
252
253.. code-block:: yaml
254
255 salt:
256 master:
257 pillar:
258 reclass: *reclass
259 nacl:
260 index: 99
261 nacl:
262 box_type: sealedbox
263 sk_file: /etc/salt/pki/master/nacl
264 pk_file: /etc/salt/pki/master/nacl.pub
265 #sk: None
266 #pk: None
267
268NACL encrypt secrets:
269
270 salt-call --local nacl.enc 'my_secret_value' pk_file=/etc/salt/pki/master/nacl.pub
271 hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q
272 # or
273 salt-run nacl.enc 'myotherpass'
274 ADDFD0Rav6p6+63sojl7Htfrncp5rrDVyeE4BSPO7ipq8fZuLDIVAzQLf4PCbDqi+Fau5KD3/J/E+Pw=
275
276
277NACL encrypted values on pillar:
278
279Use Boxed syntax `NACL[CryptedValue=]` to encode value on pillar:
280
281.. code-block:: yaml
282
283 my_pillar:
284 my_nacl:
285 key0: unencrypted_value
286 key1: NACL[hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q]
287
288NACL large files:
289
290.. code-block:: shell
291 salt-call nacl.enc_file /tmp/cert.crt out=/srv/salt/env/dev/cert.nacl
292 # or more advanced
293 cert=$(cat /tmp/cert.crt)
294 salt-call --out=newline_values_only nacl.enc_pub data="$cert" > /srv/salt/env/dev/cert.nacl
295
296
297NACL within template/native pillars:
298
299 pillarexample:
300 user: root
301 password1: {{salt.nacl.dec('DRB7Q6/X5gGSRCTpZyxS6hlbWj0llUA+uaVyvou3vJ4=')|json}}
302 cert_key: {{salt.nacl.dec_file('/srv/salt/env/dev/certs/example.com/cert.nacl')|json}}
303 cert_key2: {{salt.nacl.dec_file('salt:///certs/example.com/cert2.nacl')|json}}
304
Ales Komarek54740682017-05-15 07:16:23 +0200305Salt syndic
306-----------
307
308The master of masters
309
310.. code-block:: yaml
311
312 salt:
313 master:
314 enabled: true
315 order_masters: True
316
317Lower syndicated master
318
319.. code-block:: yaml
320
321 salt:
322 syndic:
323 enabled: true
324 master:
325 host: master-of-master-host
326 timeout: 5
327
328Syndicated master with multiple master of masters
329
330.. code-block:: yaml
331
332 salt:
333 syndic:
334 enabled: true
335 masters:
336 - host: master-of-master-host1
337 - host: master-of-master-host2
338 timeout: 5
339
340
341Salt-minion proxy
342-----------------
Jiri Broulika0f46682017-04-20 22:45:01 +0200343
344Salt proxy pillar
345
346.. code-block:: yaml
347
348 salt:
349 minion:
Jiri Broulik88275242017-05-24 17:21:17 +0200350 proxy_minion:
Jiri Broulika0f46682017-04-20 22:45:01 +0200351 master: localhost
352 device:
353 vsrx01.mydomain.local:
354 enabled: true
355 engine: napalm
356 csr1000v.mydomain.local:
357 enabled: true
358 engine: napalm
359
360.. note:: This is pillar of the the real salt-minion
361
362
363Proxy pillar for IOS device
364
365.. code-block:: yaml
366
367 proxy:
368 proxytype: napalm
369 driver: ios
370 host: csr1000v.mydomain.local
371 username: root
372 passwd: r00tme
373
374.. note:: This is pillar of the node thats not able to run salt-minion itself
375
376
377Proxy pillar for JunOS device
378
379.. code-block:: yaml
380
381 proxy:
382 proxytype: napalm
383 driver: junos
384 host: vsrx01.mydomain.local
385 username: root
386 passwd: r00tme
387 optional_args:
388 config_format: set
389
390.. note:: This is pillar of the node thats not able to run salt-minion itself
391
Ales Komarek8fb1da82016-08-21 23:52:03 +0200392
393Salt SSH
394--------
395
396Salt SSH with sudoer using key
397
398.. literalinclude:: tests/pillar/master_ssh_minion_key.sls
399 :language: yaml
400
401Salt SSH with sudoer using password
402
403.. literalinclude:: tests/pillar/master_ssh_minion_password.sls
404 :language: yaml
405
406Salt SSH with root using password
407
408.. literalinclude:: tests/pillar/master_ssh_minion_root.sls
409 :language: yaml
410
411
Filip Pytlounb4b80592015-10-06 16:28:32 +0200412Salt minion
413-----------
414
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100415Simplest Salt minion setup with central configuration node
Filip Pytlounb4b80592015-10-06 16:28:32 +0200416
417.. code-block:: yaml
418
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100419.. literalinclude:: tests/pillar/minion_master.sls
420 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200421
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100422Multi-master Salt minion setup
Filip Pytlounb4b80592015-10-06 16:28:32 +0200423
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100424.. literalinclude:: tests/pillar/minion_multi_master.sls
425 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200426
427Salt minion with salt mine options
428
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100429.. literalinclude:: tests/pillar/minion_mine.sls
430 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200431
432Salt minion with graphing dependencies
433
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100434.. literalinclude:: tests/pillar/minion_graph.sls
435 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200436
Ales Komarek54740682017-05-15 07:16:23 +0200437Salt minion behind HTTP proxy
Ondrej Smolac2d3e6f2017-03-26 17:52:40 +0200438
439.. code-block:: yaml
440
441 salt:
442 minion:
443 proxy:
444 host: 127.0.0.1
445 port: 3128
446
Sam Stoelingabb4c04b2017-06-26 15:47:19 -0700447Salt minion to specify non-default HTTP backend. The default tornado backend
448does not respect HTTP proxy settings set as environment variables. This is
449useful for cases where you need to set no_proxy lists.
450
451.. code-block:: yaml
452
453 salt:
454 minion:
455 backend: urllib2
456
457
Ales Komarek54740682017-05-15 07:16:23 +0200458Salt minion with PKI certificate authority (CA)
Ales Komarek5d17e4b2016-04-08 11:53:53 +0200459
460.. literalinclude:: tests/pillar/minion_pki_ca.sls
461 :language: yaml
462
Ales Komarek54740682017-05-15 07:16:23 +0200463Salt minion using PKI certificate
Ales Komarek5d17e4b2016-04-08 11:53:53 +0200464
465.. literalinclude:: tests/pillar/minion_pki_cert.sls
466 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200467
Petr Michalec56066ac2017-06-01 10:52:56 +0200468Salt minion trust CA certificates issued by salt CA on a specific host (ie: salt-master node)
469
470.. code-block:: yaml
471
472 salt:
473 minion:
474 trusted_ca_minions:
475 - cfg01
Ales Komarek8fb1da82016-08-21 23:52:03 +0200476
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100477Salt control (cloud/kvm/docker)
478-------------------------------
Filip Pytlounb4b80592015-10-06 16:28:32 +0200479
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100480Salt cloud with local OpenStack provider
Filip Pytlounb4b80592015-10-06 16:28:32 +0200481
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100482.. literalinclude:: tests/pillar/control_cloud_openstack.sls
483 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200484
485Salt cloud with Digital Ocean provider
486
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100487.. literalinclude:: tests/pillar/control_cloud_digitalocean.sls
488 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200489
Ales Komarek8fb1da82016-08-21 23:52:03 +0200490Salt virt with KVM cluster
Filip Pytlounb4b80592015-10-06 16:28:32 +0200491
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100492.. literalinclude:: tests/pillar/control_virt.sls
493 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200494
Filip Pytlounb4b80592015-10-06 16:28:32 +0200495
496Usage
497=====
498
499Working with salt-cloud
500
501.. code-block:: bash
502
503 salt-cloud -m /path/to/map --assume-yes
504
505Debug LIBCLOUD for salt-cloud connection
506
507.. code-block:: bash
508
509 export LIBCLOUD_DEBUG=/dev/stderr; salt-cloud --list-sizes provider_name --log-level all
510
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100511
Ales Komarek54740682017-05-15 07:16:23 +0200512More Information
513================
Filip Pytlounb4b80592015-10-06 16:28:32 +0200514
515* http://salt.readthedocs.org/en/latest/
516* https://github.com/DanielBryan/salt-state-graph
517* http://karlgrz.com/testing-salt-states-rapidly-with-docker/
518* https://mywushublog.com/2013/03/configuration-management-with-salt-stack/
519* http://russell.ballestrini.net/replace-the-nagios-scheduler-and-nrpe-with-salt-stack/
520* https://github.com/saltstack-formulas/salt-formula
521* http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html
522
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100523
Filip Pytlounb4b80592015-10-06 16:28:32 +0200524salt-cloud
525----------
526
527* http://www.blog.sandro-mathys.ch/2013/07/setting-user-password-when-launching.html
528* http://cloudinit.readthedocs.org/en/latest/topics/examples.html
529* http://salt-cloud.readthedocs.org/en/latest/topics/install/index.html
530* http://docs.saltstack.com/topics/cloud/digitalocean.html
531* http://salt-cloud.readthedocs.org/en/latest/topics/rackspace.html
532* http://salt-cloud.readthedocs.org/en/latest/topics/map.html
533* http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100534
Filip Pytloun954dbd62017-02-02 13:02:03 +0100535
536Documentation and Bugs
537======================
538
539To learn how to install and update salt-formulas, consult the documentation
540available online at:
541
542 http://salt-formulas.readthedocs.io/
543
544In the unfortunate event that bugs are discovered, they should be reported to
545the appropriate issue tracker. Use Github issue tracker for specific salt
546formula:
547
548 https://github.com/salt-formulas/salt-formula-salt/issues
549
550For feature requests, bug reports or blueprints affecting entire ecosystem,
551use Launchpad salt-formulas project:
552
553 https://launchpad.net/salt-formulas
554
555You can also join salt-formulas-users team and subscribe to mailing list:
556
557 https://launchpad.net/~salt-formulas-users
558
559Developers wishing to work on the salt-formulas projects should always base
560their work on master branch and submit pull request against specific formula.
561
562 https://github.com/salt-formulas/salt-formula-salt
563
564Any questions or feedback is always welcome so feel free to join our IRC
565channel:
566
567 #salt-formulas @ irc.freenode.net