blob: d3a64b072809901efe2e131d3d2fadfddd1d77f8 [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 Komareka9fc6e72017-09-06 15:02:40 +0200153
154Salt engine definition for saltgraph metadata collector
155
156.. code-block:: yaml
157
158 salt:
159 master:
160 engine:
161 graph_metadata:
162 engine: saltgraph
163 host: 127.0.0.1
164 port: 5432
165 user: salt
166 password: salt
167 database: salt
168
169Salt engine definition for sending events from docker events
170
171.. code-block:: yaml
172
173 salt:
174 master:
175 engine:
176 docker_events:
177 docker_url: unix://var/run/docker.sock
178
Ales Komarek54740682017-05-15 07:16:23 +0200179Salt master peer setup for remote certificate signing
Jakub Pavlikd4859842016-05-23 10:48:04 +0200180
181.. code-block:: yaml
182
183 salt:
184 master:
185 peer:
186 ".*":
187 - x509.sign_remote_certificate
Filip Pytlounb4b80592015-10-06 16:28:32 +0200188
Tomáš Kukrál8922aef2017-05-10 10:27:04 +0200189Configure verbosity of state output (used for `salt` command)
190
191.. code-block:: yaml
192
193 salt:
194 master:
Tomáš Kukrál044667b2017-05-11 10:12:15 +0200195 state_output: changes
Tomáš Kukrál8922aef2017-05-10 10:27:04 +0200196
Petr Michalec1f541c42017-08-17 13:30:37 +0200197
Ales Komareke7844d12017-06-08 12:00:01 +0200198Salt synchronise node pillar and modules after start
Ales Komarek54740682017-05-15 07:16:23 +0200199
200.. code-block:: yaml
201
202 salt:
203 master:
204 reactor:
205 salt/minion/*/start:
Ales Komareke7844d12017-06-08 12:00:01 +0200206 - salt://salt/reactor/node_start.sls
Ales Komarek54740682017-05-15 07:16:23 +0200207
Ales Komareke7844d12017-06-08 12:00:01 +0200208Trigger basic node install
209
210.. code-block:: yaml
211
212 salt:
213 master:
214 reactor:
215 salt/minion/install:
216 - salt://salt/reactor/node_install.sls
217
218Sample event to trigger the node installation
219
220.. code-block:: bash
221
222 salt-call event.send 'salt/minion/install'
223
Ales Komarek213fbe02017-08-21 16:39:05 +0200224Run any defined orchestration pipeline
Ales Komarek5c58de32017-06-06 11:49:32 +0200225
226.. code-block:: yaml
227
228 salt:
229 master:
230 reactor:
231 salt/orchestrate/start:
232 - salt://salt/reactor/orchestrate_start.sls
233
Ales Komareke7844d12017-06-08 12:00:01 +0200234Event to trigger the orchestration pipeline
Ales Komarek5c58de32017-06-06 11:49:32 +0200235
236.. code-block:: bash
237
Ales Komareke7844d12017-06-08 12:00:01 +0200238 salt-call event.send 'salt/orchestrate/start' "{'orchestrate': 'salt/orchestrate/infra_install.sls'}"
Ales Komarek5c58de32017-06-06 11:49:32 +0200239
Ales Komarek3ed7c432017-08-24 16:15:49 +0200240Synchronise modules and pillars on minion start.
241
242.. code-block:: yaml
243
244 salt:
245 master:
246 reactor:
247 'salt/minion/*/start':
248 - salt://salt/reactor/minion_start.sls
249
Ales Komarek213fbe02017-08-21 16:39:05 +0200250Add and/or remove the minion key
Ales Komarek5c58de32017-06-06 11:49:32 +0200251
252.. code-block:: yaml
253
254 salt:
255 master:
256 reactor:
Ales Komarek213fbe02017-08-21 16:39:05 +0200257 salt/key/create:
258 - salt://salt/reactor/key_create.sls
259 salt/key/remove:
260 - salt://salt/reactor/key_remove.sls
Ales Komarek5c58de32017-06-06 11:49:32 +0200261
Ales Komarek213fbe02017-08-21 16:39:05 +0200262Event to trigger the key creation
Ales Komarek5c58de32017-06-06 11:49:32 +0200263
264.. code-block:: bash
265
Adam Tengler62188962017-09-04 13:34:44 +0000266 salt-call event.send 'salt/key/create' \
267 > "{'node_id': 'id-of-minion', 'node_host': '172.16.10.100', 'orch_post_create': 'kubernetes.orchestrate.compute_install', 'post_create_pillar': {'node_name': 'id-of-minion'}}"
Ales Komarek5c58de32017-06-06 11:49:32 +0200268
Ales Komarek213fbe02017-08-21 16:39:05 +0200269.. note::
270
271 You can add pass additional `orch_pre_create`, `orch_post_create`,
272 `orch_pre_remove` or `orch_post_remove` parameters to the event to call
273 extra orchestrate files. This can be useful for example for
274 registering/unregistering nodes from the monitoring alarms or dashboards.
275
276 The key creation event needs to be run from other machine than the one
277 being registered.
278
279Event to trigger the key removal
280
281.. code-block:: bash
282
283 salt-call event.send 'salt/key/remove'
Ales Komarek54740682017-05-15 07:16:23 +0200284
Petr Michalec1f541c42017-08-17 13:30:37 +0200285
286Encrypted pillars
287-----------------
288
289Note: NACL + below configuration will be available in Salt > 2017.7.
290
291External resources:
292
293- Tutorial to configure salt + reclass ext_pillar and nacl: http://apealive.net/post/2017-09-salt-nacl-ext-pillar/
294- Saltstack documentation: https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.nacl.html
295
296Configure salt NACL module:
297
298.. code-block:: shell
299
300 pip install --upgrade libnacl===1.5.2
301 salt-call --local nacl.keygen /etc/salt/pki/master/nacl
302
303 local:
304 saved sk_file:/etc/salt/pki/master/nacl pk_file: /etc/salt/pki/master/nacl.pub
305
306
307.. code-block:: yaml
308
309 salt:
310 master:
311 pillar:
312 reclass: *reclass
313 nacl:
314 index: 99
315 nacl:
316 box_type: sealedbox
317 sk_file: /etc/salt/pki/master/nacl
318 pk_file: /etc/salt/pki/master/nacl.pub
319 #sk: None
320 #pk: None
321
322NACL encrypt secrets:
323
324 salt-call --local nacl.enc 'my_secret_value' pk_file=/etc/salt/pki/master/nacl.pub
325 hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q
326 # or
327 salt-run nacl.enc 'myotherpass'
328 ADDFD0Rav6p6+63sojl7Htfrncp5rrDVyeE4BSPO7ipq8fZuLDIVAzQLf4PCbDqi+Fau5KD3/J/E+Pw=
329
330
331NACL encrypted values on pillar:
332
333Use Boxed syntax `NACL[CryptedValue=]` to encode value on pillar:
334
335.. code-block:: yaml
336
337 my_pillar:
338 my_nacl:
339 key0: unencrypted_value
340 key1: NACL[hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q]
341
342NACL large files:
343
344.. code-block:: shell
345 salt-call nacl.enc_file /tmp/cert.crt out=/srv/salt/env/dev/cert.nacl
346 # or more advanced
347 cert=$(cat /tmp/cert.crt)
348 salt-call --out=newline_values_only nacl.enc_pub data="$cert" > /srv/salt/env/dev/cert.nacl
349
350
351NACL within template/native pillars:
352
353 pillarexample:
354 user: root
355 password1: {{salt.nacl.dec('DRB7Q6/X5gGSRCTpZyxS6hlbWj0llUA+uaVyvou3vJ4=')|json}}
356 cert_key: {{salt.nacl.dec_file('/srv/salt/env/dev/certs/example.com/cert.nacl')|json}}
357 cert_key2: {{salt.nacl.dec_file('salt:///certs/example.com/cert2.nacl')|json}}
358
Ales Komarek54740682017-05-15 07:16:23 +0200359Salt syndic
360-----------
361
362The master of masters
363
364.. code-block:: yaml
365
366 salt:
367 master:
368 enabled: true
369 order_masters: True
370
371Lower syndicated master
372
373.. code-block:: yaml
374
375 salt:
376 syndic:
377 enabled: true
378 master:
379 host: master-of-master-host
380 timeout: 5
381
382Syndicated master with multiple master of masters
383
384.. code-block:: yaml
385
386 salt:
387 syndic:
388 enabled: true
389 masters:
390 - host: master-of-master-host1
391 - host: master-of-master-host2
392 timeout: 5
393
394
395Salt-minion proxy
396-----------------
Jiri Broulika0f46682017-04-20 22:45:01 +0200397
398Salt proxy pillar
399
400.. code-block:: yaml
401
402 salt:
403 minion:
Jiri Broulik88275242017-05-24 17:21:17 +0200404 proxy_minion:
Jiri Broulika0f46682017-04-20 22:45:01 +0200405 master: localhost
406 device:
407 vsrx01.mydomain.local:
408 enabled: true
409 engine: napalm
410 csr1000v.mydomain.local:
411 enabled: true
412 engine: napalm
413
414.. note:: This is pillar of the the real salt-minion
415
416
417Proxy pillar for IOS device
418
419.. code-block:: yaml
420
421 proxy:
422 proxytype: napalm
423 driver: ios
424 host: csr1000v.mydomain.local
425 username: root
426 passwd: r00tme
427
428.. note:: This is pillar of the node thats not able to run salt-minion itself
429
430
431Proxy pillar for JunOS device
432
433.. code-block:: yaml
434
435 proxy:
436 proxytype: napalm
437 driver: junos
438 host: vsrx01.mydomain.local
439 username: root
440 passwd: r00tme
441 optional_args:
442 config_format: set
443
444.. note:: This is pillar of the node thats not able to run salt-minion itself
445
Ales Komarek8fb1da82016-08-21 23:52:03 +0200446
447Salt SSH
448--------
449
450Salt SSH with sudoer using key
451
452.. literalinclude:: tests/pillar/master_ssh_minion_key.sls
453 :language: yaml
454
455Salt SSH with sudoer using password
456
457.. literalinclude:: tests/pillar/master_ssh_minion_password.sls
458 :language: yaml
459
460Salt SSH with root using password
461
462.. literalinclude:: tests/pillar/master_ssh_minion_root.sls
463 :language: yaml
464
465
Filip Pytlounb4b80592015-10-06 16:28:32 +0200466Salt minion
467-----------
468
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100469Simplest Salt minion setup with central configuration node
Filip Pytlounb4b80592015-10-06 16:28:32 +0200470
471.. code-block:: yaml
472
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100473.. literalinclude:: tests/pillar/minion_master.sls
474 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200475
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100476Multi-master Salt minion setup
Filip Pytlounb4b80592015-10-06 16:28:32 +0200477
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100478.. literalinclude:: tests/pillar/minion_multi_master.sls
479 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200480
481Salt minion with salt mine options
482
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100483.. literalinclude:: tests/pillar/minion_mine.sls
484 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200485
486Salt minion with graphing dependencies
487
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100488.. literalinclude:: tests/pillar/minion_graph.sls
489 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200490
Ales Komarek54740682017-05-15 07:16:23 +0200491Salt minion behind HTTP proxy
Ondrej Smolac2d3e6f2017-03-26 17:52:40 +0200492
493.. code-block:: yaml
494
495 salt:
496 minion:
497 proxy:
498 host: 127.0.0.1
499 port: 3128
500
Sam Stoelingabb4c04b2017-06-26 15:47:19 -0700501Salt minion to specify non-default HTTP backend. The default tornado backend
502does not respect HTTP proxy settings set as environment variables. This is
503useful for cases where you need to set no_proxy lists.
504
505.. code-block:: yaml
506
507 salt:
508 minion:
509 backend: urllib2
510
511
Ales Komarek54740682017-05-15 07:16:23 +0200512Salt minion with PKI certificate authority (CA)
Ales Komarek5d17e4b2016-04-08 11:53:53 +0200513
514.. literalinclude:: tests/pillar/minion_pki_ca.sls
515 :language: yaml
516
Ales Komarek54740682017-05-15 07:16:23 +0200517Salt minion using PKI certificate
Ales Komarek5d17e4b2016-04-08 11:53:53 +0200518
519.. literalinclude:: tests/pillar/minion_pki_cert.sls
520 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200521
Petr Michalec56066ac2017-06-01 10:52:56 +0200522Salt minion trust CA certificates issued by salt CA on a specific host (ie: salt-master node)
523
524.. code-block:: yaml
525
526 salt:
527 minion:
528 trusted_ca_minions:
529 - cfg01
Ales Komarek8fb1da82016-08-21 23:52:03 +0200530
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100531Salt control (cloud/kvm/docker)
532-------------------------------
Filip Pytlounb4b80592015-10-06 16:28:32 +0200533
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100534Salt cloud with local OpenStack provider
Filip Pytlounb4b80592015-10-06 16:28:32 +0200535
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100536.. literalinclude:: tests/pillar/control_cloud_openstack.sls
537 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200538
539Salt cloud with Digital Ocean provider
540
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100541.. literalinclude:: tests/pillar/control_cloud_digitalocean.sls
542 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200543
Ales Komarek8fb1da82016-08-21 23:52:03 +0200544Salt virt with KVM cluster
Filip Pytlounb4b80592015-10-06 16:28:32 +0200545
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100546.. literalinclude:: tests/pillar/control_virt.sls
547 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200548
Filip Pytlounb4b80592015-10-06 16:28:32 +0200549
550Usage
551=====
552
553Working with salt-cloud
554
555.. code-block:: bash
556
557 salt-cloud -m /path/to/map --assume-yes
558
559Debug LIBCLOUD for salt-cloud connection
560
561.. code-block:: bash
562
563 export LIBCLOUD_DEBUG=/dev/stderr; salt-cloud --list-sizes provider_name --log-level all
564
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100565
Ales Komarek54740682017-05-15 07:16:23 +0200566More Information
567================
Filip Pytlounb4b80592015-10-06 16:28:32 +0200568
569* http://salt.readthedocs.org/en/latest/
570* https://github.com/DanielBryan/salt-state-graph
571* http://karlgrz.com/testing-salt-states-rapidly-with-docker/
572* https://mywushublog.com/2013/03/configuration-management-with-salt-stack/
573* http://russell.ballestrini.net/replace-the-nagios-scheduler-and-nrpe-with-salt-stack/
574* https://github.com/saltstack-formulas/salt-formula
575* http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html
576
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100577
Filip Pytlounb4b80592015-10-06 16:28:32 +0200578salt-cloud
579----------
580
581* http://www.blog.sandro-mathys.ch/2013/07/setting-user-password-when-launching.html
582* http://cloudinit.readthedocs.org/en/latest/topics/examples.html
583* http://salt-cloud.readthedocs.org/en/latest/topics/install/index.html
584* http://docs.saltstack.com/topics/cloud/digitalocean.html
585* http://salt-cloud.readthedocs.org/en/latest/topics/rackspace.html
586* http://salt-cloud.readthedocs.org/en/latest/topics/map.html
587* http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100588
Filip Pytloun954dbd62017-02-02 13:02:03 +0100589
590Documentation and Bugs
591======================
592
593To learn how to install and update salt-formulas, consult the documentation
594available online at:
595
596 http://salt-formulas.readthedocs.io/
597
598In the unfortunate event that bugs are discovered, they should be reported to
599the appropriate issue tracker. Use Github issue tracker for specific salt
600formula:
601
602 https://github.com/salt-formulas/salt-formula-salt/issues
603
604For feature requests, bug reports or blueprints affecting entire ecosystem,
605use Launchpad salt-formulas project:
606
607 https://launchpad.net/salt-formulas
608
609You can also join salt-formulas-users team and subscribe to mailing list:
610
611 https://launchpad.net/~salt-formulas-users
612
613Developers wishing to work on the salt-formulas projects should always base
614their work on master branch and submit pull request against specific formula.
615
616 https://github.com/salt-formulas/salt-formula-salt
617
618Any questions or feedback is always welcome so feel free to join our IRC
619channel:
620
621 #salt-formulas @ irc.freenode.net