blob: c4a41f802da6ce1ddec1afd03a0459dd562ebf11 [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
Ales Komarekb2ada522017-12-07 11:31:32 +0100189
190Salt master backup configuration
191
192.. code-block:: yaml
193
194 salt:
195 master:
196 backup: true
197 initial_data:
198 engine: backupninja
199 source: backup-node-host
200 host: original-salt-master-id
201
Tomáš Kukrál8922aef2017-05-10 10:27:04 +0200202Configure verbosity of state output (used for `salt` command)
203
204.. code-block:: yaml
205
206 salt:
207 master:
Tomáš Kukrál044667b2017-05-11 10:12:15 +0200208 state_output: changes
Tomáš Kukrál8922aef2017-05-10 10:27:04 +0200209
Petr Michalec1f541c42017-08-17 13:30:37 +0200210
Ales Komareke7844d12017-06-08 12:00:01 +0200211Salt synchronise node pillar and modules after start
Ales Komarek54740682017-05-15 07:16:23 +0200212
213.. code-block:: yaml
214
215 salt:
216 master:
217 reactor:
218 salt/minion/*/start:
Ales Komareke7844d12017-06-08 12:00:01 +0200219 - salt://salt/reactor/node_start.sls
Ales Komarek54740682017-05-15 07:16:23 +0200220
Ales Komareke7844d12017-06-08 12:00:01 +0200221Trigger basic node install
222
223.. code-block:: yaml
224
225 salt:
226 master:
227 reactor:
228 salt/minion/install:
229 - salt://salt/reactor/node_install.sls
230
231Sample event to trigger the node installation
232
233.. code-block:: bash
234
235 salt-call event.send 'salt/minion/install'
236
Ales Komarek213fbe02017-08-21 16:39:05 +0200237Run any defined orchestration pipeline
Ales Komarek5c58de32017-06-06 11:49:32 +0200238
239.. code-block:: yaml
240
241 salt:
242 master:
243 reactor:
244 salt/orchestrate/start:
245 - salt://salt/reactor/orchestrate_start.sls
246
Ales Komareke7844d12017-06-08 12:00:01 +0200247Event to trigger the orchestration pipeline
Ales Komarek5c58de32017-06-06 11:49:32 +0200248
249.. code-block:: bash
250
Ales Komareke7844d12017-06-08 12:00:01 +0200251 salt-call event.send 'salt/orchestrate/start' "{'orchestrate': 'salt/orchestrate/infra_install.sls'}"
Ales Komarek5c58de32017-06-06 11:49:32 +0200252
Ales Komarek3ed7c432017-08-24 16:15:49 +0200253Synchronise modules and pillars on minion start.
254
255.. code-block:: yaml
256
257 salt:
258 master:
259 reactor:
260 'salt/minion/*/start':
261 - salt://salt/reactor/minion_start.sls
262
Ales Komarek213fbe02017-08-21 16:39:05 +0200263Add and/or remove the minion key
Ales Komarek5c58de32017-06-06 11:49:32 +0200264
265.. code-block:: yaml
266
267 salt:
268 master:
269 reactor:
Ales Komarek213fbe02017-08-21 16:39:05 +0200270 salt/key/create:
271 - salt://salt/reactor/key_create.sls
272 salt/key/remove:
273 - salt://salt/reactor/key_remove.sls
Ales Komarek5c58de32017-06-06 11:49:32 +0200274
Ales Komarek213fbe02017-08-21 16:39:05 +0200275Event to trigger the key creation
Ales Komarek5c58de32017-06-06 11:49:32 +0200276
277.. code-block:: bash
278
Adam Tengler62188962017-09-04 13:34:44 +0000279 salt-call event.send 'salt/key/create' \
280 > "{'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 +0200281
Ales Komarek213fbe02017-08-21 16:39:05 +0200282.. note::
283
284 You can add pass additional `orch_pre_create`, `orch_post_create`,
285 `orch_pre_remove` or `orch_post_remove` parameters to the event to call
286 extra orchestrate files. This can be useful for example for
287 registering/unregistering nodes from the monitoring alarms or dashboards.
288
289 The key creation event needs to be run from other machine than the one
290 being registered.
291
292Event to trigger the key removal
293
294.. code-block:: bash
295
296 salt-call event.send 'salt/key/remove'
Ales Komarek54740682017-05-15 07:16:23 +0200297
Petr Michalec1f541c42017-08-17 13:30:37 +0200298
299Encrypted pillars
300-----------------
301
302Note: NACL + below configuration will be available in Salt > 2017.7.
303
304External resources:
305
306- Tutorial to configure salt + reclass ext_pillar and nacl: http://apealive.net/post/2017-09-salt-nacl-ext-pillar/
307- Saltstack documentation: https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.nacl.html
308
309Configure salt NACL module:
310
311.. code-block:: shell
312
313 pip install --upgrade libnacl===1.5.2
314 salt-call --local nacl.keygen /etc/salt/pki/master/nacl
315
316 local:
317 saved sk_file:/etc/salt/pki/master/nacl pk_file: /etc/salt/pki/master/nacl.pub
318
319
320.. code-block:: yaml
321
322 salt:
323 master:
324 pillar:
325 reclass: *reclass
326 nacl:
327 index: 99
328 nacl:
329 box_type: sealedbox
330 sk_file: /etc/salt/pki/master/nacl
331 pk_file: /etc/salt/pki/master/nacl.pub
332 #sk: None
333 #pk: None
334
335NACL encrypt secrets:
336
337 salt-call --local nacl.enc 'my_secret_value' pk_file=/etc/salt/pki/master/nacl.pub
338 hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q
339 # or
340 salt-run nacl.enc 'myotherpass'
341 ADDFD0Rav6p6+63sojl7Htfrncp5rrDVyeE4BSPO7ipq8fZuLDIVAzQLf4PCbDqi+Fau5KD3/J/E+Pw=
342
343
344NACL encrypted values on pillar:
345
346Use Boxed syntax `NACL[CryptedValue=]` to encode value on pillar:
347
348.. code-block:: yaml
349
350 my_pillar:
351 my_nacl:
352 key0: unencrypted_value
353 key1: NACL[hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q]
354
355NACL large files:
356
357.. code-block:: shell
358 salt-call nacl.enc_file /tmp/cert.crt out=/srv/salt/env/dev/cert.nacl
359 # or more advanced
360 cert=$(cat /tmp/cert.crt)
361 salt-call --out=newline_values_only nacl.enc_pub data="$cert" > /srv/salt/env/dev/cert.nacl
362
363
364NACL within template/native pillars:
365
366 pillarexample:
367 user: root
368 password1: {{salt.nacl.dec('DRB7Q6/X5gGSRCTpZyxS6hlbWj0llUA+uaVyvou3vJ4=')|json}}
369 cert_key: {{salt.nacl.dec_file('/srv/salt/env/dev/certs/example.com/cert.nacl')|json}}
370 cert_key2: {{salt.nacl.dec_file('salt:///certs/example.com/cert2.nacl')|json}}
371
Ales Komarek54740682017-05-15 07:16:23 +0200372Salt syndic
373-----------
374
375The master of masters
376
377.. code-block:: yaml
378
379 salt:
380 master:
381 enabled: true
382 order_masters: True
383
384Lower syndicated master
385
386.. code-block:: yaml
387
388 salt:
389 syndic:
390 enabled: true
391 master:
392 host: master-of-master-host
393 timeout: 5
394
395Syndicated master with multiple master of masters
396
397.. code-block:: yaml
398
399 salt:
400 syndic:
401 enabled: true
402 masters:
403 - host: master-of-master-host1
404 - host: master-of-master-host2
405 timeout: 5
406
407
408Salt-minion proxy
409-----------------
Jiri Broulika0f46682017-04-20 22:45:01 +0200410
411Salt proxy pillar
412
413.. code-block:: yaml
414
415 salt:
416 minion:
Jiri Broulik88275242017-05-24 17:21:17 +0200417 proxy_minion:
Jiri Broulika0f46682017-04-20 22:45:01 +0200418 master: localhost
419 device:
420 vsrx01.mydomain.local:
421 enabled: true
422 engine: napalm
423 csr1000v.mydomain.local:
424 enabled: true
425 engine: napalm
426
427.. note:: This is pillar of the the real salt-minion
428
429
430Proxy pillar for IOS device
431
432.. code-block:: yaml
433
434 proxy:
435 proxytype: napalm
436 driver: ios
437 host: csr1000v.mydomain.local
438 username: root
439 passwd: r00tme
440
441.. note:: This is pillar of the node thats not able to run salt-minion itself
442
443
444Proxy pillar for JunOS device
445
446.. code-block:: yaml
447
448 proxy:
449 proxytype: napalm
450 driver: junos
451 host: vsrx01.mydomain.local
452 username: root
453 passwd: r00tme
454 optional_args:
455 config_format: set
456
457.. note:: This is pillar of the node thats not able to run salt-minion itself
458
Ales Komarek8fb1da82016-08-21 23:52:03 +0200459
460Salt SSH
461--------
462
463Salt SSH with sudoer using key
464
465.. literalinclude:: tests/pillar/master_ssh_minion_key.sls
466 :language: yaml
467
468Salt SSH with sudoer using password
469
470.. literalinclude:: tests/pillar/master_ssh_minion_password.sls
471 :language: yaml
472
473Salt SSH with root using password
474
475.. literalinclude:: tests/pillar/master_ssh_minion_root.sls
476 :language: yaml
477
478
Filip Pytlounb4b80592015-10-06 16:28:32 +0200479Salt minion
480-----------
481
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100482Simplest Salt minion setup with central configuration node
Filip Pytlounb4b80592015-10-06 16:28:32 +0200483
484.. code-block:: yaml
485
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100486.. literalinclude:: tests/pillar/minion_master.sls
487 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200488
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100489Multi-master Salt minion setup
Filip Pytlounb4b80592015-10-06 16:28:32 +0200490
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100491.. literalinclude:: tests/pillar/minion_multi_master.sls
492 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200493
494Salt minion with salt mine options
495
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100496.. literalinclude:: tests/pillar/minion_mine.sls
497 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200498
499Salt minion with graphing dependencies
500
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100501.. literalinclude:: tests/pillar/minion_graph.sls
502 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200503
Ales Komarek54740682017-05-15 07:16:23 +0200504Salt minion behind HTTP proxy
Ondrej Smolac2d3e6f2017-03-26 17:52:40 +0200505
506.. code-block:: yaml
507
508 salt:
509 minion:
510 proxy:
511 host: 127.0.0.1
512 port: 3128
513
Sam Stoelingabb4c04b2017-06-26 15:47:19 -0700514Salt minion to specify non-default HTTP backend. The default tornado backend
515does not respect HTTP proxy settings set as environment variables. This is
516useful for cases where you need to set no_proxy lists.
517
518.. code-block:: yaml
519
520 salt:
521 minion:
522 backend: urllib2
523
524
Ales Komarek54740682017-05-15 07:16:23 +0200525Salt minion with PKI certificate authority (CA)
Ales Komarek5d17e4b2016-04-08 11:53:53 +0200526
527.. literalinclude:: tests/pillar/minion_pki_ca.sls
528 :language: yaml
529
Ales Komarek54740682017-05-15 07:16:23 +0200530Salt minion using PKI certificate
Ales Komarek5d17e4b2016-04-08 11:53:53 +0200531
532.. literalinclude:: tests/pillar/minion_pki_cert.sls
533 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200534
Petr Michalec56066ac2017-06-01 10:52:56 +0200535Salt minion trust CA certificates issued by salt CA on a specific host (ie: salt-master node)
536
537.. code-block:: yaml
538
539 salt:
540 minion:
541 trusted_ca_minions:
542 - cfg01
Ales Komarek8fb1da82016-08-21 23:52:03 +0200543
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100544Salt control (cloud/kvm/docker)
545-------------------------------
Filip Pytlounb4b80592015-10-06 16:28:32 +0200546
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100547Salt cloud with local OpenStack provider
Filip Pytlounb4b80592015-10-06 16:28:32 +0200548
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100549.. literalinclude:: tests/pillar/control_cloud_openstack.sls
550 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200551
552Salt cloud with Digital Ocean provider
553
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100554.. literalinclude:: tests/pillar/control_cloud_digitalocean.sls
555 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200556
Ales Komarek8fb1da82016-08-21 23:52:03 +0200557Salt virt with KVM cluster
Filip Pytlounb4b80592015-10-06 16:28:32 +0200558
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100559.. literalinclude:: tests/pillar/control_virt.sls
560 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200561
Filip Pytlounb4b80592015-10-06 16:28:32 +0200562
563Usage
564=====
565
566Working with salt-cloud
567
568.. code-block:: bash
569
570 salt-cloud -m /path/to/map --assume-yes
571
572Debug LIBCLOUD for salt-cloud connection
573
574.. code-block:: bash
575
576 export LIBCLOUD_DEBUG=/dev/stderr; salt-cloud --list-sizes provider_name --log-level all
577
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100578
Ales Komarek54740682017-05-15 07:16:23 +0200579More Information
580================
Filip Pytlounb4b80592015-10-06 16:28:32 +0200581
582* http://salt.readthedocs.org/en/latest/
583* https://github.com/DanielBryan/salt-state-graph
584* http://karlgrz.com/testing-salt-states-rapidly-with-docker/
585* https://mywushublog.com/2013/03/configuration-management-with-salt-stack/
586* http://russell.ballestrini.net/replace-the-nagios-scheduler-and-nrpe-with-salt-stack/
587* https://github.com/saltstack-formulas/salt-formula
588* http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html
589
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100590
Filip Pytlounb4b80592015-10-06 16:28:32 +0200591salt-cloud
592----------
593
594* http://www.blog.sandro-mathys.ch/2013/07/setting-user-password-when-launching.html
595* http://cloudinit.readthedocs.org/en/latest/topics/examples.html
596* http://salt-cloud.readthedocs.org/en/latest/topics/install/index.html
597* http://docs.saltstack.com/topics/cloud/digitalocean.html
598* http://salt-cloud.readthedocs.org/en/latest/topics/rackspace.html
599* http://salt-cloud.readthedocs.org/en/latest/topics/map.html
600* http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100601
Filip Pytloun954dbd62017-02-02 13:02:03 +0100602
603Documentation and Bugs
604======================
605
606To learn how to install and update salt-formulas, consult the documentation
607available online at:
608
609 http://salt-formulas.readthedocs.io/
610
611In the unfortunate event that bugs are discovered, they should be reported to
612the appropriate issue tracker. Use Github issue tracker for specific salt
613formula:
614
615 https://github.com/salt-formulas/salt-formula-salt/issues
616
617For feature requests, bug reports or blueprints affecting entire ecosystem,
618use Launchpad salt-formulas project:
619
620 https://launchpad.net/salt-formulas
621
622You can also join salt-formulas-users team and subscribe to mailing list:
623
624 https://launchpad.net/~salt-formulas-users
625
626Developers wishing to work on the salt-formulas projects should always base
627their work on master branch and submit pull request against specific formula.
628
629 https://github.com/salt-formulas/salt-formula-salt
630
631Any questions or feedback is always welcome so feel free to join our IRC
632channel:
633
634 #salt-formulas @ irc.freenode.net