blob: 1b04a2cc2aa4c6c21afc0ef54e3b376e13da33b8 [file] [log] [blame]
Filip Pytlounb4b80592015-10-06 16:28:32 +02001
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +03002=====
3Usage
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 +020013Sample Metadata
14===============
15
Ales Komarekd768f1c2018-01-30 22:37:18 +010016Salt Master
Filip Pytlounb4b80592015-10-06 16:28:32 +020017-----------
18
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +030019Salt master with base formulas and pillar metadata back end:
Filip Pytlounb4b80592015-10-06 16:28:32 +020020
Ales Komarek8ba9c0b2016-02-21 14:59:59 +010021.. literalinclude:: tests/pillar/master_single_pillar.sls
22 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +020023
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +030024Salt master with reclass ENC metadata back end:
Filip Pytlounb4b80592015-10-06 16:28:32 +020025
Ales Komarek8ba9c0b2016-02-21 14:59:59 +010026.. literalinclude:: tests/pillar/master_single_reclass.sls
27 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +020028
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +030029Salt master with Architect ENC metadata back end:
Ales Komarek459407b2018-01-18 17:16:31 +010030
31.. code-block:: yaml
32
33 salt:
34 master:
35 enabled: true
36 pillar:
37 engine: architect
38 project: project-name
39 host: architect-api
40 port: 8181
41 username: salt
42 password: password
43
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +030044Salt master with multiple ``ext_pillars``:
Petr Michalec1f541c42017-08-17 13:30:37 +020045
Dzmitry Stremkouski7b15d8a2018-08-11 22:02:45 +020046.. code-block:: yaml
47
48 salt:
49 master:
50 enabled: true
51 pillar:
52 engine: salt
53 source:
54 engine: local
55 ext_pillars:
56 1:
57 module: cmd_json
58 params: '"echo {\"arg\": \"val\"}"'
59 2:
60 module: cmd_yaml
61 params: /usr/local/bin/get_yml.sh
Petr Michalec1f541c42017-08-17 13:30:37 +020062
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +030063Salt master with API:
Filip Pytlounb4b80592015-10-06 16:28:32 +020064
Ales Komarekb2c8ff62016-08-22 00:20:01 +020065.. literalinclude:: tests/pillar/master_api.sls
66 :language: yaml
Ales Komarekcdb280f2016-07-27 15:37:51 +020067
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +030068Salt master with defined user ACLs:
Ales Komarekcdb280f2016-07-27 15:37:51 +020069
Ales Komarekb2c8ff62016-08-22 00:20:01 +020070.. literalinclude:: tests/pillar/master_acl.sls
71 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +020072
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +030073Salt master with preset minions:
Filip Pytlounb4b80592015-10-06 16:28:32 +020074
75.. code-block:: yaml
76
77 salt:
78 master:
79 enabled: true
Filip Pytlounb4b80592015-10-06 16:28:32 +020080 minions:
81 - name: 'node1.system.location.domain.com'
82
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +030083Salt master with pip based installation (optional):
Adam Tenglercaedd972016-05-04 16:44:00 +020084
85.. code-block:: yaml
86
87 salt:
88 master:
89 enabled: true
90 ...
91 source:
92 engine: pip
93 version: 2016.3.0rc2
94
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +030095Install formula through system package management:
Adam Tengler3eb85ad2016-05-06 02:52:40 +020096
97.. code-block:: yaml
98
99 salt:
100 master:
101 enabled: true
102 ...
103 environment:
104 prd:
Petr Michalec7a2f1d22017-05-17 22:08:32 +0200105 keystone:
Adam Tengler3eb85ad2016-05-06 02:52:40 +0200106 source: pkg
107 name: salt-formula-keystone
Petr Michalec7a2f1d22017-05-17 22:08:32 +0200108 nova:
109 source: pkg
110 name: salt-formula-keystone
111 version: 0.1+0~20160818133412.24~1.gbp6e1ebb
112 postresql:
113 source: pkg
114 name: salt-formula-postgresql
115 version: purged
116
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300117Formula keystone is installed latest version and the formulas
118without version are installed in one call to aptpkg module.
119If the version attribute is present sls iterates over formulas
120and take action to install specific version or remove it.
121The version attribute may have these values
122``[latest|purged|removed|<VERSION>]``.
Adam Tengler3eb85ad2016-05-06 02:52:40 +0200123
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300124Clone master branch of keystone formula as local feature branch:
Adam Tengler3eb85ad2016-05-06 02:52:40 +0200125
126.. code-block:: yaml
127
128 salt:
129 master:
130 enabled: true
131 ...
132 environment:
133 dev:
134 formula:
135 keystone:
136 source: git
137 address: git@github.com:openstack/salt-formula-keystone.git
138 revision: master
139 branch: feature
140
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300141Salt master with specified formula refs (for example, for Gerrit
142review):
Adam Tengler3eb85ad2016-05-06 02:52:40 +0200143
144.. code-block:: yaml
145
146 salt:
147 master:
148 enabled: true
149 ...
150 environment:
151 dev:
152 formula:
153 keystone:
154 source: git
155 address: https://git.openstack.org/openstack/salt-formula-keystone
156 revision: refs/changes/56/123456/1
157
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300158Salt master logging configuration:
Oleksii Chupryn7b7102a2018-05-11 10:32:11 +0300159
160.. code-block:: yaml
161
162 salt:
163 master:
164 enabled: true
165 log:
166 level: warning
167 file: '/var/log/salt/master'
168 level_logfile: warning
169
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300170Salt minion logging configuration:
Oleksii Chupryn7b7102a2018-05-11 10:32:11 +0300171
172.. code-block:: yaml
173
174 salt:
175 minion:
176 enabled: true
177 log:
178 level: info
179 file: '/var/log/salt/minion'
180 level_logfile: warning
181
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300182Salt master with logging handlers:
Filip Pytlounb4b80592015-10-06 16:28:32 +0200183
184.. code-block:: yaml
185
186 salt:
187 master:
188 enabled: true
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100189 handler:
190 handler01:
191 engine: udp
192 bind:
193 host: 127.0.0.1
194 port: 9999
Filip Pytlounb4b80592015-10-06 16:28:32 +0200195 minion:
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100196 handler:
197 handler01:
198 engine: udp
199 bind:
200 host: 127.0.0.1
201 port: 9999
202 handler02:
203 engine: zmq
204 bind:
205 host: 127.0.0.1
206 port: 9999
207
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300208Salt engine definition for saltgraph metadata collector:
Ales Komareka9fc6e72017-09-06 15:02:40 +0200209
210.. code-block:: yaml
211
212 salt:
213 master:
214 engine:
215 graph_metadata:
216 engine: saltgraph
217 host: 127.0.0.1
218 port: 5432
219 user: salt
220 password: salt
221 database: salt
222
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300223Salt engine definition for Architect service:
Ales Komarek459407b2018-01-18 17:16:31 +0100224
225.. code-block:: yaml
226
227 salt:
228 master:
229 engine:
230 architect:
231 engine: architect
232 project: project-name
233 host: architect-api
234 port: 8181
235 username: salt
236 password: password
237
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300238Salt engine definition for sending events from docker events:
Ales Komareka9fc6e72017-09-06 15:02:40 +0200239
240.. code-block:: yaml
241
242 salt:
243 master:
244 engine:
245 docker_events:
246 docker_url: unix://var/run/docker.sock
247
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300248Salt master peer setup for remote certificate signing:
Jakub Pavlikd4859842016-05-23 10:48:04 +0200249
250.. code-block:: yaml
251
252 salt:
253 master:
254 peer:
255 ".*":
256 - x509.sign_remote_certificate
Filip Pytlounb4b80592015-10-06 16:28:32 +0200257
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300258Salt master backup configuration:
Ales Komarekb2ada522017-12-07 11:31:32 +0100259
260.. code-block:: yaml
261
262 salt:
263 master:
264 backup: true
265 initial_data:
266 engine: backupninja
Jiri Broulik3e281642018-03-02 18:17:21 +0100267 home_dir: remote-backup-home-dir
Ales Komarekb2ada522017-12-07 11:31:32 +0100268 source: backup-node-host
269 host: original-salt-master-id
270
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300271Configure verbosity of state output (used for :command:`salt`
272command):
Tomáš Kukrál8922aef2017-05-10 10:27:04 +0200273
274.. code-block:: yaml
275
276 salt:
277 master:
Tomáš Kukrál044667b2017-05-11 10:12:15 +0200278 state_output: changes
Tomáš Kukrál8922aef2017-05-10 10:27:04 +0200279
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300280Pass pillar render error to minion log:
Ales Komarekd768f1c2018-01-30 22:37:18 +0100281
282.. note:: When set to `False` this option is great for debuging.
283 However it is not recomended for any production environment as it may contain
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300284 templating data as passwords, and so on, that minion should not expose.
Ales Komarekd768f1c2018-01-30 22:37:18 +0100285
286.. code-block:: yaml
287
288 salt:
289 master:
290 pillar_safe_render_error: False
291
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300292Enable Windows repository support:
Ales Komarekf44e64c2018-05-29 10:22:31 +0200293
294.. code-block:: yaml
295
296 salt:
297 master:
298 win_repo:
299 source: git
300 address: https://github.com/saltstack/salt-winrepo-ng
301 revision: master
302
Ivan Suzdal7e2a2ca2018-08-23 12:31:19 +0400303Configure a gitfs_remotes resource:
304
305.. code-block:: yaml
306
307 salt:
308 master:
309 gitfs_remotes:
310 salt_formula:
311 url: https://github.com/salt-formulas/salt-formula-salt.git
312 enabled: true
313 params:
314 base: master
315
316Read more about gitfs resource options in the official Salt documentation.
317
318
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300319Event/Reactor systems
Ales Komarekd768f1c2018-01-30 22:37:18 +0100320~~~~~~~~~~~~~~~~~~~~~
Petr Michalec1f541c42017-08-17 13:30:37 +0200321
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300322Salt to synchronize node pillar and modules after start:
Ales Komarek54740682017-05-15 07:16:23 +0200323
324.. code-block:: yaml
325
326 salt:
327 master:
328 reactor:
329 salt/minion/*/start:
Ales Komareke7844d12017-06-08 12:00:01 +0200330 - salt://salt/reactor/node_start.sls
Ales Komarek54740682017-05-15 07:16:23 +0200331
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300332Trigger basic node install:
Ales Komareke7844d12017-06-08 12:00:01 +0200333
334.. code-block:: yaml
335
336 salt:
337 master:
338 reactor:
339 salt/minion/install:
340 - salt://salt/reactor/node_install.sls
341
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300342Sample event to trigger the node installation:
Ales Komareke7844d12017-06-08 12:00:01 +0200343
344.. code-block:: bash
345
346 salt-call event.send 'salt/minion/install'
347
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300348Run any defined orchestration pipeline:
Ales Komarek5c58de32017-06-06 11:49:32 +0200349
350.. code-block:: yaml
351
352 salt:
353 master:
354 reactor:
355 salt/orchestrate/start:
356 - salt://salt/reactor/orchestrate_start.sls
357
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300358Event to trigger the orchestration pipeline:
Ales Komarek5c58de32017-06-06 11:49:32 +0200359
360.. code-block:: bash
361
Ales Komareke7844d12017-06-08 12:00:01 +0200362 salt-call event.send 'salt/orchestrate/start' "{'orchestrate': 'salt/orchestrate/infra_install.sls'}"
Ales Komarek5c58de32017-06-06 11:49:32 +0200363
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300364Synchronise modules and pillars on minion start:
Ales Komarek3ed7c432017-08-24 16:15:49 +0200365
366.. code-block:: yaml
367
368 salt:
369 master:
370 reactor:
371 'salt/minion/*/start':
372 - salt://salt/reactor/minion_start.sls
373
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300374Add and/or remove the minion key:
Ales Komarek5c58de32017-06-06 11:49:32 +0200375
376.. code-block:: yaml
377
378 salt:
379 master:
380 reactor:
Ales Komarek213fbe02017-08-21 16:39:05 +0200381 salt/key/create:
382 - salt://salt/reactor/key_create.sls
383 salt/key/remove:
384 - salt://salt/reactor/key_remove.sls
Ales Komarek5c58de32017-06-06 11:49:32 +0200385
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300386Event to trigger the key creation:
Ales Komarek5c58de32017-06-06 11:49:32 +0200387
388.. code-block:: bash
389
Adam Tengler62188962017-09-04 13:34:44 +0000390 salt-call event.send 'salt/key/create' \
391 > "{'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 +0200392
Ales Komarek213fbe02017-08-21 16:39:05 +0200393.. note::
394
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300395 You can add pass additional ``orch_pre_create``, ``orch_post_create``,
396 ``orch_pre_remove`` or ``orch_post_remove`` parameters to the event
397 to call extra orchestrate files. This can be useful for example for
Ales Komarek213fbe02017-08-21 16:39:05 +0200398 registering/unregistering nodes from the monitoring alarms or dashboards.
399
400 The key creation event needs to be run from other machine than the one
401 being registered.
402
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300403Event to trigger the key removal:
Ales Komarek213fbe02017-08-21 16:39:05 +0200404
405.. code-block:: bash
406
407 salt-call event.send 'salt/key/remove'
Ales Komarek54740682017-05-15 07:16:23 +0200408
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300409Control VM provisioning:
Dzmitry Stremkouski7ee23402018-04-10 00:43:48 +0200410
411.. code-block:: yaml
412
Dzmitry Stremkouski97927ee2018-08-23 23:20:38 +0200413 _param:
414 private-ipv4: &private-ipv4
415 - id: private-ipv4
416 type: ipv4
417 link: ens2
418 netmask: 255.255.255.0
419 routes:
420 - gateway: 192.168.0.1
421 netmask: 0.0.0.0
422 network: 0.0.0.0
Dzmitry Stremkouski7ee23402018-04-10 00:43:48 +0200423 virt:
424 disk:
425 three_disks:
426 - system:
427 size: 4096
428 image: ubuntu.qcow
429 - repository_snapshot:
430 size: 8192
431 image: snapshot.qcow
432 - cinder-volume:
433 size: 2048
Ondrej Smolae6bcb292018-04-13 10:56:39 +0200434 nic:
435 control:
436 - name: nic01
437 bridge: br-pxe
438 model: virtio
439 - name: nic02
440 bridge: br-cp
441 model: virtio
442 - name: nic03
443 bridge: br-store-front
444 model: virtio
445 - name: nic04
446 bridge: br-public
447 model: virtio
Dzmitry Stremkouskib8acf1f2018-06-28 12:56:23 +0200448 - name: nic05
449 bridge: br-prv
450 model: virtio
451 virtualport:
452 type: openvswitch
Ondrej Smolae6bcb292018-04-13 10:56:39 +0200453
Dzmitry Stremkouski7ee23402018-04-10 00:43:48 +0200454 salt:
455 control:
456 enabled: true
457 virt_enabled: true
458 size:
459 medium_three_disks:
460 cpu: 2
461 ram: 4
462 disk_profile: three_disks
463 cluster:
464 mycluster:
465 domain: neco.virt.domain.com
466 engine: virt
Martin Horak9e11aa22018-09-17 06:46:59 +0200467 # Cluster global settings
Ondrej Smolac7f6cfc2018-05-21 15:55:08 +0200468 rng: false
Martin Horak9e11aa22018-09-17 06:46:59 +0200469 enable_vnc: True
Dzmitry Stremkouski97927ee2018-08-23 23:20:38 +0200470 cloud_init:
471 user_data:
472 disable_ec2_metadata: true
473 resize_rootfs: True
474 timezone: UTC
475 ssh_deletekeys: True
476 ssh_genkeytypes: ['rsa', 'dsa', 'ecdsa']
477 ssh_svcname: ssh
478 locale: en_US.UTF-8
479 disable_root: true
480 apt_preserve_sources_list: false
481 apt:
482 sources_list: ""
483 sources:
484 ubuntu.list:
485 source: ${linux:system:repo:ubuntu:source}
486 mcp_saltstack.list:
487 source: ${linux:system:repo:mcp_saltstack:source}
Dzmitry Stremkouski7ee23402018-04-10 00:43:48 +0200488 node:
489 ubuntu1:
490 provider: node01.domain.com
491 image: ubuntu.qcow
492 size: medium
493 img_dest: /var/lib/libvirt/ssdimages
Martin Horak9e11aa22018-09-17 06:46:59 +0200494 # Node settings override cluster global ones
495 enable_vnc: False
Dzmitry Stremkouski7ee23402018-04-10 00:43:48 +0200496 rng:
497 backend: /dev/urandom
498 model: random
499 rate:
500 period: '1800'
501 bytes: '1500'
Alexandru Avadanii00f187a2018-06-24 20:36:44 +0200502 # Custom per-node loader definition (e.g. for AArch64 UEFI)
503 loader:
504 readonly: yes
505 type: pflash
506 path: /usr/share/AAVMF/AAVMF_CODE.fd
507 machine: virt-2.11 # Custom per-node virt machine type
508 cpu_mode: host-passthrough
Pavel Cizinskyf03c4e82018-09-10 14:56:11 +0200509 cpuset: '1-4'
Ondrej Smolae6bcb292018-04-13 10:56:39 +0200510 mac:
511 nic01: AC:DE:48:AA:AA:AA
512 nic02: AC:DE:48:AA:AA:BB
Dzmitry Stremkouski97927ee2018-08-23 23:20:38 +0200513 # netconfig affects: hostname during boot
514 # manual interfaces configuration
515 cloud_init:
516 network_data:
517 networks:
518 - <<: *private-ipv4
519 ip_address: 192.168.0.161
Ondrej Smolae6bcb292018-04-13 10:56:39 +0200520
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300521To enable Redis plugin for the Salt caching subsystem, use the
522below pillar structure:
Oleh Hryhorovca6b9172018-06-21 14:21:35 +0000523
524.. code-block:: yaml
525
526 salt:
527 master:
528 cache:
529 plugin: redis
530 host: localhost
531 port: 6379
532 db: '0'
533 password: pass_word
534 bank_prefix: 'MCP'
535 bank_keys_prefix: 'MCPKEY'
536 key_prefix: 'KEY'
537 separator: '@'
Ondrej Smolae6bcb292018-04-13 10:56:39 +0200538
Petr Michalecdf75d682018-02-07 13:43:53 +0100539Jinja options
540-------------
541
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300542Use the following options to update default Jinja renderer options.
543Salt recognize Jinja options for templates and for the ``sls`` files.
Petr Michalecdf75d682018-02-07 13:43:53 +0100544
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300545For full list of options, see Jinja documentation:
546http://jinja.pocoo.org/docs/api/#high-level-api
Petr Michalecdf75d682018-02-07 13:43:53 +0100547
548.. code-block:: yaml
549
Petr Michalecdf75d682018-02-07 13:43:53 +0100550 salt:
551 renderer:
552 # for templates
553 jinja: &jina_env
554 # Default Jinja environment options
555 block_start_string: '{%'
556 block_end_string: '%}'
557 variable_start_string: '{{'
558 variable_end_string: '}}'
559 comment_start_string: '{#'
560 comment_end_string: '#}'
561 keep_trailing_newline: False
562 newline_sequence: '\n'
563
564 # Next two are enabled by default in Salt
565 trim_blocks: True
566 lstrip_blocks: True
567
568 # Next two are not enabled by default in Salt
569 # but worth to consider to enable in future for salt-formulas
570 line_statement_prefix: '%'
571 line_comment_prefix: '##'
572
573 # for .sls state files
574 jinja_sls: *jinja_env
575
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300576With the ``line_statement/comment* _prefix`` options enabled following
577code statements are valid:
Petr Michalecdf75d682018-02-07 13:43:53 +0100578
579.. code-block:: yaml
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300580
Petr Michalecdf75d682018-02-07 13:43:53 +0100581 %- set myvar = 'one'
582
583 ## You can mix even with '{%'
584 {%- set myvar = 'two' %} ## comment
585 %- set mylist = ['one', 'two', 'three'] ## comment
586
587 ## comment
588 %- for item in mylist: ## comment
589 {{- item }}
590 %- endfor
591
Petr Michalecdf75d682018-02-07 13:43:53 +0100592Encrypted pillars
Ales Komarekd768f1c2018-01-30 22:37:18 +0100593~~~~~~~~~~~~~~~~~
Petr Michalec1f541c42017-08-17 13:30:37 +0200594
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300595.. note:: NACL and the below configuration will be available in Salt > 2017.7.
Petr Michalec1f541c42017-08-17 13:30:37 +0200596
597External resources:
598
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300599- Tutorial to configure the Salt and Reclass ``ext_pillar`` and NACL:
600 http://apealive.net/post/2017-09-salt-nacl-ext-pillar/
601- SaltStack documentation:
602 https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.nacl.html
Petr Michalec1f541c42017-08-17 13:30:37 +0200603
604Configure salt NACL module:
605
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300606.. code-block:: bash
Petr Michalec1f541c42017-08-17 13:30:37 +0200607
608 pip install --upgrade libnacl===1.5.2
609 salt-call --local nacl.keygen /etc/salt/pki/master/nacl
610
611 local:
612 saved sk_file:/etc/salt/pki/master/nacl pk_file: /etc/salt/pki/master/nacl.pub
613
Petr Michalec1f541c42017-08-17 13:30:37 +0200614.. code-block:: yaml
615
616 salt:
617 master:
618 pillar:
619 reclass: *reclass
620 nacl:
621 index: 99
622 nacl:
623 box_type: sealedbox
624 sk_file: /etc/salt/pki/master/nacl
625 pk_file: /etc/salt/pki/master/nacl.pub
626 #sk: None
627 #pk: None
628
629NACL encrypt secrets:
630
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300631.. code-block:: bash
632
Petr Michalec1f541c42017-08-17 13:30:37 +0200633 salt-call --local nacl.enc 'my_secret_value' pk_file=/etc/salt/pki/master/nacl.pub
634 hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q
635 # or
636 salt-run nacl.enc 'myotherpass'
637 ADDFD0Rav6p6+63sojl7Htfrncp5rrDVyeE4BSPO7ipq8fZuLDIVAzQLf4PCbDqi+Fau5KD3/J/E+Pw=
638
Petr Michalec1f541c42017-08-17 13:30:37 +0200639NACL encrypted values on pillar:
640
641Use Boxed syntax `NACL[CryptedValue=]` to encode value on pillar:
642
643.. code-block:: yaml
644
645 my_pillar:
646 my_nacl:
647 key0: unencrypted_value
648 key1: NACL[hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q]
649
650NACL large files:
651
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300652.. code-block:: bash
653
Petr Michalec1f541c42017-08-17 13:30:37 +0200654 salt-call nacl.enc_file /tmp/cert.crt out=/srv/salt/env/dev/cert.nacl
655 # or more advanced
656 cert=$(cat /tmp/cert.crt)
657 salt-call --out=newline_values_only nacl.enc_pub data="$cert" > /srv/salt/env/dev/cert.nacl
658
Petr Michalec1f541c42017-08-17 13:30:37 +0200659NACL within template/native pillars:
660
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300661.. code-block:: yaml
662
Petr Michalec1f541c42017-08-17 13:30:37 +0200663 pillarexample:
664 user: root
665 password1: {{salt.nacl.dec('DRB7Q6/X5gGSRCTpZyxS6hlbWj0llUA+uaVyvou3vJ4=')|json}}
666 cert_key: {{salt.nacl.dec_file('/srv/salt/env/dev/certs/example.com/cert.nacl')|json}}
667 cert_key2: {{salt.nacl.dec_file('salt:///certs/example.com/cert2.nacl')|json}}
668
Ales Komarekd768f1c2018-01-30 22:37:18 +0100669Salt Syndic
Ales Komarek54740682017-05-15 07:16:23 +0200670-----------
671
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300672The master of masters:
Ales Komarek54740682017-05-15 07:16:23 +0200673
674.. code-block:: yaml
675
676 salt:
677 master:
678 enabled: true
679 order_masters: True
680
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300681Lower syndicated master:
Ales Komarek54740682017-05-15 07:16:23 +0200682
683.. code-block:: yaml
684
685 salt:
686 syndic:
687 enabled: true
688 master:
689 host: master-of-master-host
690 timeout: 5
691
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300692Syndicated master with multiple master of masters:
Ales Komarek54740682017-05-15 07:16:23 +0200693
694.. code-block:: yaml
695
696 salt:
697 syndic:
698 enabled: true
699 masters:
700 - host: master-of-master-host1
701 - host: master-of-master-host2
702 timeout: 5
703
Ales Komarekd768f1c2018-01-30 22:37:18 +0100704Salt Minion
705-----------
706
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300707Minion ID by default triggers dependency on Linux formula, as it uses fqdn
708configured from `linux.system.name` and `linux.system.domain` pillar.
709To override, provide exact minion ID you require. The same can be set for
710master ID rendered at ``master.conf``.
Petr Michaleccfd93e12018-06-26 18:11:44 +0200711
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300712 .. code-block:: yaml
Petr Michaleccfd93e12018-06-26 18:11:44 +0200713
714 salt:
715 minion:
716 id: minion1.production
717 master:
718 id: master.production
719
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300720Simplest Salt minion setup with central configuration node:
Ales Komarekd768f1c2018-01-30 22:37:18 +0100721
722.. literalinclude:: tests/pillar/minion_master.sls
723 :language: yaml
724
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300725Multi-master Salt minion setup:
Ales Komarekd768f1c2018-01-30 22:37:18 +0100726
727.. literalinclude:: tests/pillar/minion_multi_master.sls
728 :language: yaml
729
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300730Salt minion with salt mine options:
Ales Komarekd768f1c2018-01-30 22:37:18 +0100731
732.. literalinclude:: tests/pillar/minion_mine.sls
733 :language: yaml
734
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300735Salt minion with graphing dependencies:
Ales Komarekd768f1c2018-01-30 22:37:18 +0100736
737.. literalinclude:: tests/pillar/minion_graph.sls
738 :language: yaml
739
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300740Salt minion behind HTTP proxy:
Ales Komarekd768f1c2018-01-30 22:37:18 +0100741
742.. code-block:: yaml
743
744 salt:
745 minion:
746 proxy:
747 host: 127.0.0.1
748 port: 3128
749
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300750Salt minion to specify non-default HTTP backend. The default
751tornado backend does not respect HTTP proxy settings set as
752environment variables. This is useful for cases where you need
753to set no_proxy lists.
Ales Komarekd768f1c2018-01-30 22:37:18 +0100754
755.. code-block:: yaml
756
757 salt:
758 minion:
759 backend: urllib2
760
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300761Salt minion with PKI certificate authority (CA):
Ales Komarekd768f1c2018-01-30 22:37:18 +0100762
763.. literalinclude:: tests/pillar/minion_pki_ca.sls
764 :language: yaml
765
766Salt minion using PKI certificate
767
768.. literalinclude:: tests/pillar/minion_pki_cert.sls
769 :language: yaml
770
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300771Salt minion trust CA certificates issued by salt CA on a
772specific host (ie: salt-master node):
Ales Komarekd768f1c2018-01-30 22:37:18 +0100773
774.. code-block:: yaml
775
776 salt:
777 minion:
778 trusted_ca_minions:
779 - cfg01
780
Ales Komarekd768f1c2018-01-30 22:37:18 +0100781Salt Minion Proxy
782~~~~~~~~~~~~~~~~~
Jiri Broulika0f46682017-04-20 22:45:01 +0200783
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300784Salt proxy pillar:
Jiri Broulika0f46682017-04-20 22:45:01 +0200785
786.. code-block:: yaml
787
788 salt:
789 minion:
Jiri Broulik88275242017-05-24 17:21:17 +0200790 proxy_minion:
Jiri Broulika0f46682017-04-20 22:45:01 +0200791 master: localhost
792 device:
793 vsrx01.mydomain.local:
794 enabled: true
795 engine: napalm
796 csr1000v.mydomain.local:
797 enabled: true
798 engine: napalm
799
800.. note:: This is pillar of the the real salt-minion
801
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300802Proxy pillar for IOS device:
Jiri Broulika0f46682017-04-20 22:45:01 +0200803
804.. code-block:: yaml
805
806 proxy:
807 proxytype: napalm
808 driver: ios
809 host: csr1000v.mydomain.local
810 username: root
811 passwd: r00tme
812
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300813.. note:: This is pillar of the node thats not able to run
814 salt-minion itself.
Jiri Broulika0f46682017-04-20 22:45:01 +0200815
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300816Proxy pillar for JunOS device:
Jiri Broulika0f46682017-04-20 22:45:01 +0200817
818.. code-block:: yaml
819
820 proxy:
821 proxytype: napalm
822 driver: junos
823 host: vsrx01.mydomain.local
824 username: root
825 passwd: r00tme
826 optional_args:
827 config_format: set
828
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300829.. note:: This pillar applies to the node that can not run
830 salt-minion itself.
Ales Komarek8fb1da82016-08-21 23:52:03 +0200831
832Salt SSH
Ales Komarekd768f1c2018-01-30 22:37:18 +0100833~~~~~~~~
Ales Komarek8fb1da82016-08-21 23:52:03 +0200834
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300835Salt SSH with sudoer using key:
Ales Komarek8fb1da82016-08-21 23:52:03 +0200836
837.. literalinclude:: tests/pillar/master_ssh_minion_key.sls
838 :language: yaml
839
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300840Salt SSH with sudoer using password:
Ales Komarek8fb1da82016-08-21 23:52:03 +0200841
842.. literalinclude:: tests/pillar/master_ssh_minion_password.sls
843 :language: yaml
844
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300845Salt SSH with root using password:
Ales Komarek8fb1da82016-08-21 23:52:03 +0200846
847.. literalinclude:: tests/pillar/master_ssh_minion_root.sls
848 :language: yaml
849
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100850Salt control (cloud/kvm/docker)
851-------------------------------
Filip Pytlounb4b80592015-10-06 16:28:32 +0200852
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300853Salt cloud with local OpenStack provider:
Filip Pytlounb4b80592015-10-06 16:28:32 +0200854
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100855.. literalinclude:: tests/pillar/control_cloud_openstack.sls
856 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200857
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300858Salt cloud with Digital Ocean provider:
Filip Pytlounb4b80592015-10-06 16:28:32 +0200859
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100860.. literalinclude:: tests/pillar/control_cloud_digitalocean.sls
861 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200862
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300863Salt virt with KVM cluster:
Filip Pytlounb4b80592015-10-06 16:28:32 +0200864
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100865.. literalinclude:: tests/pillar/control_virt.sls
866 :language: yaml
Filip Pytlounb4b80592015-10-06 16:28:32 +0200867
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300868Salt virt with custom destination for image file:
Mateusz Los4c7cd2d2018-01-09 11:46:07 +0100869
870.. literalinclude:: tests/pillar/control_virt_custom.sls
871 :language: yaml
872
Filip Pytlounb4b80592015-10-06 16:28:32 +0200873Usage
874=====
875
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300876Working with salt-cloud:
Filip Pytlounb4b80592015-10-06 16:28:32 +0200877
878.. code-block:: bash
879
880 salt-cloud -m /path/to/map --assume-yes
881
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300882Debug LIBCLOUD for salt-cloud connection:
Filip Pytlounb4b80592015-10-06 16:28:32 +0200883
884.. code-block:: bash
885
886 export LIBCLOUD_DEBUG=/dev/stderr; salt-cloud --list-sizes provider_name --log-level all
887
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300888Read more
889=========
Filip Pytlounb4b80592015-10-06 16:28:32 +0200890
891* http://salt.readthedocs.org/en/latest/
892* https://github.com/DanielBryan/salt-state-graph
893* http://karlgrz.com/testing-salt-states-rapidly-with-docker/
894* https://mywushublog.com/2013/03/configuration-management-with-salt-stack/
895* http://russell.ballestrini.net/replace-the-nagios-scheduler-and-nrpe-with-salt-stack/
896* https://github.com/saltstack-formulas/salt-formula
897* http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html
898
899salt-cloud
900----------
901
902* http://www.blog.sandro-mathys.ch/2013/07/setting-user-password-when-launching.html
903* http://cloudinit.readthedocs.org/en/latest/topics/examples.html
904* http://salt-cloud.readthedocs.org/en/latest/topics/install/index.html
905* http://docs.saltstack.com/topics/cloud/digitalocean.html
906* http://salt-cloud.readthedocs.org/en/latest/topics/rackspace.html
907* http://salt-cloud.readthedocs.org/en/latest/topics/map.html
908* http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html
Ales Komarek8ba9c0b2016-02-21 14:59:59 +0100909
Filip Pytloun954dbd62017-02-02 13:02:03 +0100910Documentation and Bugs
911======================
912
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300913* http://salt-formulas.readthedocs.io/
914 Learn how to install and update salt-formulas
Filip Pytloun954dbd62017-02-02 13:02:03 +0100915
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300916* https://github.com/salt-formulas/salt-formula-salt/issues
917 In the unfortunate event that bugs are discovered, report the issue to the
918 appropriate issue tracker. Use the Github issue tracker for a specific salt
919 formula
Filip Pytloun954dbd62017-02-02 13:02:03 +0100920
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300921* https://launchpad.net/salt-formulas
922 For feature requests, bug reports, or blueprints affecting the entire
923 ecosystem, use the Launchpad salt-formulas project
Filip Pytloun954dbd62017-02-02 13:02:03 +0100924
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300925* https://launchpad.net/~salt-formulas-users
926 Join the salt-formulas-users team and subscribe to mailing list if required
Filip Pytloun954dbd62017-02-02 13:02:03 +0100927
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300928* https://github.com/salt-formulas/salt-formula-salt
929 Develop the salt-formulas projects in the master branch and then submit pull
930 requests against a specific formula
Filip Pytloun954dbd62017-02-02 13:02:03 +0100931
OlgaGusarenkof1fd82e2018-07-31 01:20:49 +0300932* #salt-formulas @ irc.freenode.net
933 Use this IRC channel in case of any questions or feedback which is always
934 welcome
Filip Pytloun954dbd62017-02-02 13:02:03 +0100935