blob: ba61d01b2458544de67feab3079a85a3b8fb4815 [file] [log] [blame]
Aleš Komárek63572992017-04-11 13:16:44 +02001============
2Linux Fomula
3============
Filip Pytlounf5383a42015-10-06 16:28:32 +02004
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03005Linux Operating Systems:
Filip Pytlounf5383a42015-10-06 16:28:32 +02006
7* Ubuntu
8* CentOS
9* RedHat
10* Fedora
11* Arch
12
Aleš Komárek63572992017-04-11 13:16:44 +020013Sample Pillars
Filip Pytlounf5383a42015-10-06 16:28:32 +020014==============
15
Aleš Komárek63572992017-04-11 13:16:44 +020016Linux System
Filip Pytlounf5383a42015-10-06 16:28:32 +020017------------
18
19Basic Linux box
20
21.. code-block:: yaml
22
23 linux:
24 system:
25 enabled: true
26 name: 'node1'
27 domain: 'domain.com'
28 cluster: 'system'
29 environment: prod
30 timezone: 'Europe/Prague'
31 utc: true
32
azvyagintsev967af132017-06-12 12:25:24 +030033Linux with system users, some with password set:
OlgaGusarenko2828f5f2018-07-30 19:37:05 +030034
35.. warning:: If no ``password`` variable is passed,
36 any predifined password will be removed.
Filip Pytlounf5383a42015-10-06 16:28:32 +020037
38.. code-block:: yaml
39
40 linux:
41 system:
42 ...
43 user:
44 jdoe:
45 name: 'jdoe'
46 enabled: true
47 sudo: true
48 shell: /bin/bash
49 full_name: 'Jonh Doe'
50 home: '/home/jdoe'
Martin Polreich4fcd5c02018-07-16 09:41:51 +020051 home_dir_mode: 755
Filip Pytlounf5383a42015-10-06 16:28:32 +020052 email: 'jonh@doe.com'
Dzmitry Stremkouskia0d8b2d2018-10-22 14:12:05 +020053 unique: false
Dzmitry Stremkouskifae59fb2018-11-21 10:10:10 +010054 groups:
55 - db-ops
56 - salt-ops
57 optional_groups:
58 - docker
Filip Pytlounf5383a42015-10-06 16:28:32 +020059 jsmith:
60 name: 'jsmith'
61 enabled: true
azvyagintsev967af132017-06-12 12:25:24 +030062 full_name: 'With clear password'
Filip Pytlounf5383a42015-10-06 16:28:32 +020063 home: '/home/jsmith'
azvyagintsev967af132017-06-12 12:25:24 +030064 hash_password: true
65 password: "userpassword"
66 mark:
67 name: 'mark'
68 enabled: true
69 full_name: "unchange password'
70 home: '/home/mark'
71 password: false
72 elizabeth:
73 name: 'elizabeth'
74 enabled: true
75 full_name: 'With hased password'
76 home: '/home/elizabeth'
77 password: "$6$nUI7QEz3$dFYjzQqK5cJ6HQ38KqG4gTWA9eJu3aKx6TRVDFh6BVJxJgFWg2akfAA7f1fCxcSUeOJ2arCO6EEI6XXnHXxG10"
Filip Pytlounf5383a42015-10-06 16:28:32 +020078
Dzmitry Stremkouskia2960ad2019-09-04 14:15:09 +020079Remove users data completely:
80
81.. code-block:: yaml
82
83 linux:
84 system:
85 user:
86 example:
87 email: disabled
88 enabled: false
89 full_name: disabled
90 name: example
91 force_delete: True
92
Dmitry Teselkinc7814732019-02-21 16:40:23 +030093Setting user defaults
94---------------------
95Default parameters that will be used by `useradd` command could be configured
96the following way:
97
98.. code-block:: yaml
99
100 linux:
101 system:
102 ...
103 defaults:
104 user:
105 shell: <SHELL>
106 gid: <GROUP>
107 home: <HOME>
108 inactdays: <INACTIVE>
109 expire: <EXPIRE>
110 skeleton: <SKEL>
111 create_mail_spool: <CREATE_MAIL_SPOOL>
112
113Other parameters that are used when creating user profile could be configured
114as well, acting as global defaults:
115
116.. code-block:: yaml
117
118 linux:
119 system:
120 ...
121 defaults:
122 user:
123 ...
124 maxdays: <PASS_MAX_DAYS>
125 mindays: <PASS_MIN_DAYS>
126 warndays: <PASS_WARN_AGE>
127
128.. note::
129
130 The three options above ('maxdays', 'mindays', 'warndays') could be
131 overriden in linux:system:login_defs using their 'real' names.
132 The reason they could be defined here is that it's quite logical to
133 have these parameters related to configuration of user account
134 behaviour in one place.
135
136
Dmitry Teselkin47e41f42018-09-27 14:10:09 +0300137Configure password expiration parameters
138----------------------------------------
139The following login.defs parameters can be overridden per-user:
140
141* PASS_MAX_DAYS
142* PASS_MIN_DAYS
143* PASS_WARN_DAYS
Dmitry Teselkin47e41f42018-09-27 14:10:09 +0300144
145.. code-block:: yaml
146
147 linux:
148 system:
149 ...
150 user:
151 jdoe:
152 name: 'jdoe'
153 enabled: true
154 ...
155 maxdays: <PASS_MAX_DAYS>
156 mindays: <PASS_MIN_DAYS>
Dmitry Teselkinc7814732019-02-21 16:40:23 +0300157 warndays: <PASS_WARN_AGE>
Dmitry Teselkin47e41f42018-09-27 14:10:09 +0300158
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100159Configure sudo for users and groups under ``/etc/sudoers.d/``.
160This ways ``linux.system.sudo`` pillar map to actual sudo attributes:
161
162.. code-block:: jinja
Aleš Komárek63572992017-04-11 13:16:44 +0200163
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100164 # simplified template:
165 Cmds_Alias {{ alias }}={{ commands }}
166 {{ user }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
167 %{{ group }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
168
169 # when rendered:
170 saltuser1 ALL=(ALL) NOPASSWD: ALL
171
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100172.. code-block:: yaml
Aleš Komárek63572992017-04-11 13:16:44 +0200173
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100174 linux:
175 system:
176 sudo:
177 enabled: true
Tomas Kammd8eb3002017-05-08 19:30:29 +0200178 aliases:
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100179 host:
180 LOCAL:
181 - localhost
182 PRODUCTION:
183 - db1
184 - db2
185 runas:
186 DBA:
187 - postgres
188 - mysql
189 SALT:
190 - root
191 command:
192 # Note: This is not 100% safe when ALL keyword is used, user still may modify configs and hide his actions.
193 # Best practice is to specify full list of commands user is allowed to run.
194 SUPPORT_RESTRICTED:
195 - /bin/vi /etc/sudoers*
196 - /bin/vim /etc/sudoers*
197 - /bin/nano /etc/sudoers*
198 - /bin/emacs /etc/sudoers*
199 - /bin/su - root
200 - /bin/su -
201 - /bin/su
202 - /usr/sbin/visudo
203 SUPPORT_SHELLS:
204 - /bin/sh
205 - /bin/ksh
206 - /bin/bash
207 - /bin/rbash
208 - /bin/dash
209 - /bin/zsh
210 - /bin/csh
211 - /bin/fish
212 - /bin/tcsh
213 - /usr/bin/login
214 - /usr/bin/su
215 - /usr/su
216 ALL_SALT_SAFE:
217 - /usr/bin/salt state*
218 - /usr/bin/salt service*
219 - /usr/bin/salt pillar*
220 - /usr/bin/salt grains*
221 - /usr/bin/salt saltutil*
222 - /usr/bin/salt-call state*
223 - /usr/bin/salt-call service*
224 - /usr/bin/salt-call pillar*
225 - /usr/bin/salt-call grains*
226 - /usr/bin/salt-call saltutil*
227 SALT_TRUSTED:
228 - /usr/bin/salt*
229 users:
230 # saltuser1 with default values: saltuser1 ALL=(ALL) NOPASSWD: ALL
231 saltuser1: {}
232 saltuser2:
233 hosts:
234 - LOCAL
235 # User Alias DBA
236 DBA:
237 hosts:
238 - ALL
239 commands:
240 - ALL_SALT_SAFE
241 groups:
242 db-ops:
243 hosts:
244 - ALL
245 - '!PRODUCTION'
246 runas:
247 - DBA
248 commands:
249 - /bin/cat *
250 - /bin/less *
251 - /bin/ls *
252 salt-ops:
253 hosts:
254 - 'ALL'
255 runas:
256 - SALT
257 commands:
258 - SUPPORT_SHELLS
259 salt-ops-2nd:
260 name: salt-ops
261 nopasswd: false
Jakub Josef7a9d9b92017-05-16 11:39:01 +0200262 setenv: true # Enable sudo -E option
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100263 runas:
264 - DBA
265 commands:
266 - ALL
267 - '!SUPPORT_SHELLS'
268 - '!SUPPORT_RESTRICTED'
269
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300270Linux with package, latest version:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200271
272.. code-block:: yaml
273
274 linux:
275 system:
276 ...
277 package:
278 package-name:
279 version: latest
280
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300281Linux with package from certail repo, version with no upgrades:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200282
283.. code-block:: yaml
284
285 linux:
286 system:
287 ...
288 package:
289 package-name:
290 version: 2132.323
291 repo: 'custom-repo'
292 hold: true
293
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300294Linux with package from certail repo, version with no GPG
295verification:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200296
297.. code-block:: yaml
298
299 linux:
300 system:
301 ...
302 package:
303 package-name:
304 version: 2132.323
305 repo: 'custom-repo'
306 verify: false
307
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300308Linux with autoupdates (automatically install security package
309updates):
Bruno Binet69a9d8d2017-02-16 22:34:32 +0100310
311.. code-block:: yaml
312
313 linux:
314 system:
315 ...
316 autoupdates:
317 enabled: true
318 mail: root@localhost
319 mail_only_on_error: true
320 remove_unused_dependencies: false
321 automatic_reboot: true
322 automatic_reboot_time: "02:00"
323
Dmitry Teselkin0f084a02018-08-29 14:46:38 +0300324Managing cron tasks
325-------------------
326
327There are two data structures that are related to managing cron itself and
328cron tasks:
329
330.. code-block:: yaml
331
332 linux:
333 system:
334 cron:
335
336and
337
338.. code-block:: yaml
339
340 linux:
341 system:
342 job:
343
344`linux:system:cron` manages cron packages, services, and '/etc/cron.allow' file.
345
346'deny' files are managed the only way - we're ensuring they are absent, that's
347a requirement from CIS 5.1.8
348
349'cron' pillar structure is the following:
350
351.. code-block:: yaml
352
353 linux:
354 system:
355 cron:
356 enabled: true
357 pkgs: [ <cron packages> ]
358 services: [ <cron services> ]
359 user:
360 <username>:
361 enabled: true
362
363To add user to '/etc/cron.allow' use 'enabled' key as shown above.
364
365'/etc/cron.deny' is not managed as CIS 5.1.8 requires it was removed.
366
367A user would be ignored if any of the following is true:
368* user is disabled in `linux:system:user:<username>`
369* user is disabled in `linux:system:cron:user:<username>`
370
371`linux:system:job` manages individual cron tasks.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300372
373By default, it will use name as an identifier, unless identifier key is
Filip Pytloun91222222017-08-04 10:55:27 +0200374explicitly set or False (then it will use Salt's default behavior which is
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300375identifier same as command resulting in not being able to change it):
Filip Pytlounf5383a42015-10-06 16:28:32 +0200376
377.. code-block:: yaml
378
379 linux:
380 system:
381 ...
382 job:
383 cmd1:
384 command: '/cmd/to/run'
Filip Pytloun91222222017-08-04 10:55:27 +0200385 identifier: cmd1
Filip Pytlounf5383a42015-10-06 16:28:32 +0200386 enabled: true
387 user: 'root'
388 hour: 2
389 minute: 0
390
Dmitry Teselkin0f084a02018-08-29 14:46:38 +0300391Managing 'at' tasks
392-------------------
393
394Pillar for managing `at` tasks is similar to one for `cron` tasks:
395
396.. code-block:: yaml
397
398 linux:
399 system:
400 at:
401 enabled: true
402 pkgs: [ <at packages> ]
403 services: [ <at services> ]
404 user:
405 <username>:
406 enabled: true
407
408To add a user to '/etc/at.allow' use 'enabled' key as shown above.
409
410'/etc/at.deny' is not managed as CIS 5.1.8 requires it was removed.
411
412A user will be ignored if any of the following is true:
413* user is disabled in `linux:system:user:<username>`
414* user is disabled in `linux:system:at:user:<username>`
415
416
Filip Pytlound0a29e72015-11-30 15:23:34 +0100417Linux security limits (limit sensu user memory usage to max 1GB):
418
419.. code-block:: yaml
420
421 linux:
422 system:
423 ...
424 limit:
425 sensu:
426 enabled: true
427 domain: sensu
428 limits:
429 - type: hard
430 item: as
431 value: 1000000
432
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300433Enable autologin on ``tty1`` (may work only for Ubuntu 14.04):
Filip Pytloun7fee0542015-10-15 11:19:24 +0200434
435.. code-block:: yaml
436
437 linux:
438 system:
439 console:
440 tty1:
441 autologin: root
Filip Pytloun281d0202016-01-29 14:03:51 +0100442 # Enable serial console
443 ttyS0:
444 autologin: root
445 rate: 115200
446 term: xterm
Filip Pytloun7fee0542015-10-15 11:19:24 +0200447
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300448To disable set autologin to ``false``.
Filip Pytloun7fee0542015-10-15 11:19:24 +0200449
Filip Pytloun7731b852016-02-01 11:13:47 +0100450Set ``policy-rc.d`` on Debian-based systems. Action can be any available
451command in ``while true`` loop and ``case`` context.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300452Following will disallow dpkg to stop/start services for the Cassandra
453package automatically:
Filip Pytloun7731b852016-02-01 11:13:47 +0100454
455.. code-block:: yaml
456
457 linux:
458 system:
459 policyrcd:
460 - package: cassandra
461 action: exit 101
462 - package: '*'
463 action: switch
464
Filip Pytlounc49445a2016-04-04 14:23:20 +0200465Set system locales:
466
467.. code-block:: yaml
468
469 linux:
470 system:
471 locale:
472 en_US.UTF-8:
473 default: true
Filip Pytlounee1745f2016-04-04 17:39:41 +0200474 "cs_CZ.UTF-8 UTF-8":
Filip Pytlounc49445a2016-04-04 14:23:20 +0200475 enabled: true
476
Andrey Shestakove7cca052017-05-24 23:06:24 +0300477Systemd settings:
478
479.. code-block:: yaml
480
481 linux:
482 system:
483 ...
484 systemd:
485 system:
486 Manager:
487 DefaultLimitNOFILE: 307200
488 DefaultLimitNPROC: 307200
489 user:
490 Manager:
491 DefaultLimitCPU: 2
492 DefaultLimitNPROC: 4
493
Filip Pytloun8b2131e2017-11-08 13:29:03 +0100494Ensure presence of directory:
495
496.. code-block:: yaml
497
498 linux:
499 system:
500 directory:
501 /tmp/test:
502 user: root
503 group: root
504 mode: 700
505 makedirs: true
506
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300507Ensure presence of file by specifying its source:
Richard Felkl2e07d652018-01-19 10:19:06 +0100508
509.. code-block:: yaml
510
511 linux:
512 system:
513 file:
514 /tmp/test.txt:
515 source: http://example.com/test.txt
Richard Felklf40599a2018-02-06 22:56:41 +0100516 user: root #optional
517 group: root #optional
518 mode: 700 #optional
519 dir_mode: 700 #optional
520 encoding: utf-8 #optional
521 hash: <<hash>> or <<URI to hash>> #optional
522 makedirs: true #optional
523
524 linux:
525 system:
526 file:
527 test.txt:
528 name: /tmp/test.txt
529 source: http://example.com/test.txt
Richard Felkl2e07d652018-01-19 10:19:06 +0100530
Gabor Orosz35815c02018-09-07 17:31:05 +0200531 linux:
532 system:
533 file:
534 test2:
535 name: /tmp/test2.txt
536 source: http://example.com/test2.jinja
537 template: jinja
538
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300539Ensure presence of file by specifying its contents:
Richard Felkl2e07d652018-01-19 10:19:06 +0100540
541.. code-block:: yaml
542
543 linux:
544 system:
545 file:
546 /tmp/test.txt:
547 contents: |
548 line1
549 line2
Richard Felklf40599a2018-02-06 22:56:41 +0100550
551 linux:
552 system:
553 file:
554 /tmp/test.txt:
555 contents_pillar: linux:network:hostname
556
557 linux:
558 system:
559 file:
560 /tmp/test.txt:
561 contents_grains: motd
562
Ivan Berezovskiy25e177d2019-07-22 13:14:14 +0400563Ensure presence of file by specifying its secured source:
564
565.. code-block:: yaml
566
567 linux:
568 system:
569 file:
570 /tmp/test.txt:
571 secured_source:
572 protocol: http #optional
573 user: foo
574 password: bar
575 url: example.com/test.txt
576 secured_hash: #optional
577 url: example.com/test.txt.md5
578 user: root #optional
579 group: root #optional
580 mode: 700 #optional
581 dir_mode: 700 #optional
582 encoding: utf-8 #optional
583 makedirs: true #optional
584
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300585Ensure presence of file to be serialized through one of the
586serializer modules (see:
587https://docs.saltstack.com/en/latest/ref/serializers/all/index.html):
Bruno Binet9c2fe222018-06-08 16:57:32 +0200588
589.. code-block:: yaml
590
591 linux:
592 system:
593 file:
594 /tmp/test.json:
595 serialize: json
596 contents:
597 foo: 1
598 bar: 'bar'
599
Filip Pytloun281034a2016-01-04 18:06:22 +0100600Kernel
601~~~~~~
602
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300603Install always up to date LTS kernel and headers from Ubuntu Trusty:
Filip Pytloun281034a2016-01-04 18:06:22 +0100604
605.. code-block:: yaml
606
607 linux:
608 system:
609 kernel:
610 type: generic
611 lts: trusty
612 headers: true
613
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300614Load kernel modules and add them to ``/etc/modules``:
Tomáš Kukrálba35b212017-02-15 17:59:46 +0100615
616.. code-block:: yaml
617
618 linux:
619 system:
620 kernel:
621 modules:
622 - nf_conntrack
623 - tp_smapi
624 - 8021q
625
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300626Configure or blacklist kernel modules with additional options to
627``/etc/modprobe.d`` following example will add
628``/etc/modprobe.d/nf_conntrack.conf`` file with line
629``options nf_conntrack hashsize=262144``:
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300630
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300631'option' can be a mapping (with 'enabled' and 'value' keys) or a scalar.
632
633Example for 'scalar' option value:
634
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300635.. code-block:: yaml
636
637 linux:
638 system:
639 kernel:
640 module:
641 nf_conntrack:
642 option:
643 hashsize: 262144
644
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300645Example for 'mapping' option value:
646
647.. code-block:: yaml
648
649 linux:
650 system:
651 kernel:
652 module:
653 nf_conntrack:
654 option:
655 hashsize:
656 enabled: true
657 value: 262144
658
659NOTE: 'enabled' key is optional and is True by default.
660
661Blacklist a module:
662
663.. code-block:: yaml
664
665 linux:
666 system:
667 kernel:
668 module:
669 nf_conntrack:
670 blacklist: true
671
672A module can have a number of aliases, wildcards are allowed.
673Define an alias for a module:
674
675.. code-block:: yaml
676
677 linux:
678 system:
679 kernel:
680 module:
681 nf_conntrack:
682 alias:
683 nfct:
684 enabled: true
685 "nf_conn*":
686 enabled: true
687
688NOTE: 'enabled' key is mandatory as there are no other keys exist.
689
690Execute custom command instead of 'insmod' when inserting a module:
691
692.. code-block:: yaml
693
694 linux:
695 system:
696 kernel:
697 module:
698 nf_conntrack:
699 install:
700 enabled: true
701 command: /bin/true
702
703NOTE: 'enabled' key is optional and is True by default.
704
705Execute custom command instead of 'rmmod' when removing a module:
706
707.. code-block:: yaml
708
709 linux:
710 system:
711 kernel:
712 module:
713 nf_conntrack:
714 remove:
715 enabled: true
716 command: /bin/true
717
718NOTE: 'enabled' key is optional and is True by default.
719
720Define module dependencies:
721
722.. code-block:: yaml
723
724 linux:
725 system:
726 kernel:
727 module:
728 nf_conntrack:
729 softdep:
730 pre:
731 1:
732 enabled: true
733 value: a
734 2:
735 enabled: true
736 value: b
737 3:
738 enabled: true
739 value: c
740 post:
741 1:
742 enabled: true
743 value: x
744 2:
745 enabled: true
746 value: y
747 3:
748 enabled: true
749 value: z
750
751NOTE: 'enabled' key is optional and is True by default.
752
753
Filip Pytloun281034a2016-01-04 18:06:22 +0100754Install specific kernel version and ensure all other kernel packages are
755not present. Also install extra modules and headers for this kernel:
756
757.. code-block:: yaml
758
759 linux:
760 system:
761 kernel:
762 type: generic
763 extra: true
764 headers: true
765 version: 4.2.0-22
766
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300767Systcl kernel parameters:
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100768
769.. code-block:: yaml
770
771 linux:
772 system:
773 kernel:
774 sysctl:
775 net.ipv4.tcp_keepalive_intvl: 3
776 net.ipv4.tcp_keepalive_time: 30
777 net.ipv4.tcp_keepalive_probes: 8
778
Michael Polenchukebf55522018-01-25 13:22:39 +0400779Configure kernel boot options:
780
781.. code-block:: yaml
782
783 linux:
784 system:
785 kernel:
786 boot_options:
787 - elevator=deadline
788 - spectre_v2=off
789 - nopti
790
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100791CPU
792~~~
793
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300794Enable cpufreq governor for every cpu:
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100795
796.. code-block:: yaml
797
798 linux:
799 system:
800 cpu:
801 governor: performance
802
Nick Metzf04f5f32018-01-08 15:25:04 +0100803
Jiri Broulik303905d2018-01-11 14:12:48 +0100804CGROUPS
805~~~~~~~
806
807Setup linux cgroups:
808
809.. code-block:: yaml
810
811 linux:
812 system:
813 cgroup:
814 enabled: true
815 group:
816 ceph_group_1:
817 controller:
818 cpu:
819 shares:
820 value: 250
821 cpuacct:
822 usage:
823 value: 0
824 cpuset:
825 cpus:
826 value: 1,2,3
827 memory:
828 limit_in_bytes:
829 value: 2G
830 memsw.limit_in_bytes:
831 value: 3G
832 mapping:
833 subjects:
834 - '@ceph'
835 generic_group_1:
836 controller:
837 cpu:
838 shares:
839 value: 250
840 cpuacct:
841 usage:
842 value: 0
843 mapping:
844 subjects:
845 - '*:firefox'
846 - 'student:cp'
847
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300848Shared libraries
Nick Metzf04f5f32018-01-08 15:25:04 +0100849~~~~~~~~~~~~~~~~
850
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300851Set additional shared library to Linux system library path:
Nick Metzf04f5f32018-01-08 15:25:04 +0100852
853.. code-block:: yaml
854
855 linux:
856 system:
857 ld:
858 library:
859 java:
860 - /usr/lib/jvm/jre-openjdk/lib/amd64/server
861 - /opt/java/jre/lib/amd64/server
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200862
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200863Certificates
864~~~~~~~~~~~~
865
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300866Add certificate authority into system trusted CA bundle:
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200867
868.. code-block:: yaml
869
870 linux:
871 system:
872 ca_certificates:
873 mycert: |
874 -----BEGIN CERTIFICATE-----
875 MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
876 A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
877 cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
878 MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
879 BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
880 YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
881 ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
882 BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
883 I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
884 CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
885 lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
886 AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
887 -----END CERTIFICATE-----
888
Filip Pytloun361096c2017-08-23 10:57:20 +0200889Sysfs
890~~~~~
891
892Install sysfsutils and set sysfs attributes:
893
894.. code-block:: yaml
895
896 linux:
897 system:
898 sysfs:
899 scheduler:
900 block/sda/queue/scheduler: deadline
901 power:
902 mode:
903 power/state: 0660
904 owner:
905 power/state: "root:power"
906 devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
907
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200908Optional: You can also use list that will ensure order of items.
909
910.. code-block:: yaml
911
912 linux:
913 system:
914 sysfs:
915 scheduler:
916 block/sda/queue/scheduler: deadline
917 power:
918 - mode:
919 power/state: 0660
920 - owner:
921 power/state: "root:power"
922 - devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
923
Martin Polreich148e1b82018-09-13 15:54:25 +0200924Sysfs definition with disabled automatic write. Attributes are saved
925to configuration, but are not applied during the run.
926Thay will be applied automatically after the reboot.
927
928
929.. code-block:: yaml
930
931 linux:
932 system:
933 sysfs:
934 enable_apply: false
935 scheduler:
936 block/sda/queue/scheduler: deadline
937
938.. note:: The `enable_apply` parameter defaults to `True` if not defined.
939
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100940Huge Pages
941~~~~~~~~~~~~
942
943Huge Pages give a performance boost to applications that intensively deal
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300944with memory allocation/deallocation by decreasing memory fragmentation:
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100945
946.. code-block:: yaml
947
948 linux:
949 system:
950 kernel:
951 hugepages:
952 small:
953 size: 2M
954 count: 107520
955 mount_point: /mnt/hugepages_2MB
Michael Polenchukd9369fe2018-05-08 17:53:08 +0400956 mount: false/true # default is true (mount immediately) / false (just save in the fstab)
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100957 large:
958 default: true # default automatically mounted
959 size: 1G
960 count: 210
961 mount_point: /mnt/hugepages_1GB
962
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300963.. note:: Not recommended to use both pagesizes concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100964
Jakub Pavlik5398d872017-02-13 22:30:47 +0100965Intel SR-IOV
966~~~~~~~~~~~~
967
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300968PCI-SIG Single Root I/O Virtualization and Sharing (SR-IOV)
969specification defines a standardized mechanism to virtualize
970PCIe devices. The mechanism can virtualize a single PCIe
971Ethernet controller to appear as multiple PCIe devices:
Jakub Pavlik5398d872017-02-13 22:30:47 +0100972
973.. code-block:: yaml
974
975 linux:
976 system:
977 kernel:
978 sriov: True
979 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
980 rc:
981 local: |
982 #!/bin/sh -e
983 # Enable 7 VF on eth1
984 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
985 exit 0
986
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100987Isolate CPU options
988~~~~~~~~~~~~~~~~~~~
989
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300990Remove the specified CPUs, as defined by the cpu_number values, from
991the general kernel SMP balancing and scheduler algroithms. The only
992way to move a process onto or off an *isolated* CPU is via the CPU
993affinity syscalls. ``cpu_number begins`` at ``0``, so the
994maximum value is ``1`` less than the number of CPUs on the system.:
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100995
996.. code-block:: yaml
997
998 linux:
999 system:
1000 kernel:
1001 isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
Jiri Broulikf8f55a22017-01-26 14:36:46 +01001002
Filip Pytlounf5383a42015-10-06 16:28:32 +02001003Repositories
1004~~~~~~~~~~~~
1005
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001006RedHat-based Linux with additional OpenStack repo:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001007
1008.. code-block:: yaml
1009
1010 linux:
1011 system:
1012 ...
1013 repo:
1014 rdo-icehouse:
1015 enabled: true
1016 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
1017 pgpcheck: 0
1018
1019Ensure system repository to use czech Debian mirror (``default: true``)
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001020Also pin it's packages with priority ``900``:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001021
1022.. code-block:: yaml
1023
1024 linux:
1025 system:
1026 repo:
1027 debian:
1028 default: true
1029 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
1030 # Import signing key from URL if needed
1031 key_url: "http://dummy.com/public.gpg"
1032 pin:
1033 - pin: 'origin "ftp.cz.debian.org"'
1034 priority: 900
1035 package: '*'
1036
azvyagintseva3a73d02018-12-06 14:49:58 +02001037Sometimes better to use one pining rule file, to decrease mistaken
1038ordering. You can use those option ``system:apt:preferences``, which would add opts into
1039``/etc/apt/preferences`` file:
1040
1041.. code-block:: yaml
1042
1043 parameters:
1044 linux:
1045 system:
1046 apt:
1047 preferences:
1048 enabled: true
1049 rules:
1050 100:
1051 enabled: true
1052 name: 'some origin pin'
1053 pin: 'release o=Debian'
1054 priority: 1100
1055 package: '*'
1056
1057
azvyagintsev4494a472018-09-14 19:19:23 +03001058If you need to add multiple pin rules for one repo, please use new,ordered definition format
1059('pinning' definition will be in priotity to use):
1060
1061.. code-block:: yaml
1062
1063 linux:
1064 system:
1065 repo:
1066 mcp_saltstack:
1067 source: "deb [arch=amd64] http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/ xenial main"
1068 architectures: amd64
1069 clean_file: true
1070 pinning:
1071 10:
1072 enabled: true
1073 pin: 'release o=SaltStack'
1074 priority: 50
1075 package: 'libsodium18'
1076 20:
1077 enabled: true
1078 pin: 'release o=SaltStack'
1079 priority: 1100
1080 package: '*'
1081
1082
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001083.. note:: For old Ubuntu releases (<xenial)
azvyagintsevff089d22018-07-27 16:52:34 +02001084 extra packages for apt transport, like ``apt-transport-https``
1085 may be required to be installed manually.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001086 (Chicken-eggs issue: we need to install packages to
azvyagintsevff089d22018-07-27 16:52:34 +02001087 reach repo from where they should be installed)
1088 Otherwise, you still can try 'fortune' and install prereq.packages before
1089 any repo configuration, using list of requires in map.jinja.
1090
1091
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001092Disabling any prerequisite packages installation:
1093
azvyagintsevff089d22018-07-27 16:52:34 +02001094You can simply drop any package pre-installation (before system.linux.repo
1095will be processed) via cluster lvl:
1096
1097.. code-block:: yaml
1098
1099 linux:
1100 system:
1101 pkgs: ~
1102
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001103Package manager proxy global setup:
Petr Michalec10462bb2017-03-23 19:18:08 +01001104
1105.. code-block:: yaml
1106
1107 linux:
1108 system:
1109 ...
1110 repo:
1111 apt-mk:
1112 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1113 ...
1114 proxy:
1115 pkg:
1116 enabled: true
1117 ftp: ftp://ftp-proxy-for-apt.host.local:2121
1118 ...
1119 # NOTE: Global defaults for any other componet that configure proxy on the system.
1120 # If your environment has just one simple proxy, set it on linux:system:proxy.
1121 #
1122 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
1123 # as for https and http
1124 ftp: ftp://proxy.host.local:2121
1125 http: http://proxy.host.local:3142
1126 https: https://proxy.host.local:3143
1127
1128Package manager proxy setup per repository:
1129
1130.. code-block:: yaml
1131
1132 linux:
1133 system:
1134 ...
1135 repo:
1136 debian:
1137 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1138 ...
1139 apt-mk:
1140 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1141 # per repository proxy
1142 proxy:
1143 enabled: true
1144 http: http://maas-01:8080
1145 https: http://maas-01:8080
1146 ...
1147 proxy:
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001148 # package manager fallback defaults
Petr Michalec10462bb2017-03-23 19:18:08 +01001149 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
1150 pkg:
1151 enabled: true
1152 ftp: ftp://proxy.host.local:2121
1153 #http: http://proxy.host.local:3142
1154 #https: https://proxy.host.local:3143
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001155 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001156 # global system fallback system defaults
1157 ftp: ftp://proxy.host.local:2121
1158 http: http://proxy.host.local:3142
1159 https: https://proxy.host.local:3143
1160
Ivan Berezovskiycfd58a22019-06-25 20:15:51 +04001161
1162Add secured apt repository:
1163
1164.. code-block:: yaml
1165
1166 linux:
1167 system:
1168 ...
1169 repo:
1170 test:
1171 secure: true
1172 url: example.org/ubuntu
1173 arch: deb
1174 protocol: http
1175 user: foo
1176 password: bar
1177 distribution: stable
1178 component: main
1179
1180Add multiply secured apt repositories with same credentials:
1181
1182.. code-block:: yaml
1183
1184 linux:
1185 system:
1186 ...
1187 common_repo_secured:
1188 arch: deb
1189 protocol: http
1190 user: foo
1191 password: bar
1192 distribution: stable
1193 component: main
1194 repo:
1195 test1:
1196 secure: true
1197 url: example1.org/ubuntu
1198 test2:
1199 secure: true
1200 url: example2.org/ubuntu
1201
Jiri Broulik34a29b42017-04-25 14:42:54 +02001202Remove all repositories:
1203
1204.. code-block:: yaml
1205
1206 linux:
1207 system:
1208 purge_repos: true
1209
azvyagintsevff089d22018-07-27 16:52:34 +02001210Refresh repositories metada, after configuration:
1211
1212.. code-block:: yaml
1213
1214 linux:
1215 system:
1216 refresh_repos_meta: true
1217
Filip Pytlounc512e6c2017-11-22 14:28:10 +01001218Setup custom apt config options:
1219
1220.. code-block:: yaml
1221
1222 linux:
1223 system:
1224 apt:
1225 config:
1226 compression-workaround:
1227 "Acquire::CompressionTypes::Order": "gz"
1228 docker-clean:
1229 "DPkg::Post-Invoke":
1230 - "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"
1231 "APT::Update::Post-Invoke":
1232 - "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"
Jiri Broulik34a29b42017-04-25 14:42:54 +02001233
Petr Michalec10462bb2017-03-23 19:18:08 +01001234RC
1235~~
1236
Jakub Pavlik78859382016-01-21 11:26:39 +01001237rc.local example
1238
1239.. code-block:: yaml
1240
1241 linux:
1242 system:
1243 rc:
1244 local: |
1245 #!/bin/sh -e
1246 #
1247 # rc.local
1248 #
1249 # This script is executed at the end of each multiuser runlevel.
1250 # Make sure that the script will "exit 0" on success or any other
1251 # value on error.
1252 #
1253 # In order to enable or disable this script just change the execution
1254 # bits.
1255 #
1256 # By default this script does nothing.
1257 exit 0
1258
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001259Prompt
1260~~~~~~
1261
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001262Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``.
1263Every user can have different prompt:
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001264
1265.. code-block:: yaml
1266
1267 linux:
1268 system:
1269 prompt:
1270 root: \\n\\[\\033[0;37m\\]\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\[\\e[0m\\]\\n\\[\\e[1;31m\\][\\u@\\h:\\w]\\[\\e[0m\\]
1271 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
1272
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001273On Debian systems, to set prompt system-wide, it's necessary to
1274remove setting PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc``,
1275which comes from ``/etc/skel/.bashrc``. This formula will do
1276this automatically, but will not touch existing user's
1277``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +01001278
Filip Pytlouneef11c12016-03-25 11:00:23 +01001279Bash
1280~~~~
1281
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001282Fix bash configuration to preserve history across sessions
1283like ZSH does by default:
Filip Pytlouneef11c12016-03-25 11:00:23 +01001284
1285.. code-block:: yaml
1286
1287 linux:
1288 system:
1289 bash:
1290 preserve_history: true
1291
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001292Login banner message
1293~~~~~~~~~~~~~~~~~~~~
1294
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001295``/etc/issue`` is a text file which contains a message or system
1296identification to be printed before the login prompt. It may contain
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001297various @char and \char sequences, if supported by the getty-type
1298program employed on the system.
1299
1300Setting logon banner message is easy:
1301
1302.. code-block:: yaml
1303
1304 liunx:
1305 system:
1306 banner:
1307 enabled: true
1308 contents: |
1309 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1310
1311 You must have explicit, authorized permission to access or configure this
1312 device. Unauthorized attempts and actions to access or use this system may
1313 result in civil and/or criminal penalties.
1314 All activities performed on this system are logged and monitored.
1315
Filip Pytloune874dfb2016-01-22 16:57:34 +01001316Message of the day
1317~~~~~~~~~~~~~~~~~~
1318
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001319``pam_motd`` from package ``libpam-modules`` is used for dynamic
1320messages of the day. Setting custom ``motd`` will clean up existing ones.
Filip Pytloune874dfb2016-01-22 16:57:34 +01001321
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001322Setting static ``motd`` will replace existing ``/etc/motd`` and remove
1323scripts from ``/etc/update-motd.d``.
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001324
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001325Setting static ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001326
1327.. code-block:: yaml
1328
1329 linux:
1330 system:
1331 motd: |
1332 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1333
1334 You must have explicit, authorized permission to access or configure this
1335 device. Unauthorized attempts and actions to access or use this system may
1336 result in civil and/or criminal penalties.
1337 All activities performed on this system are logged and monitored.
1338
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001339Setting dynamic ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001340
Filip Pytloune874dfb2016-01-22 16:57:34 +01001341.. code-block:: yaml
1342
1343 linux:
1344 system:
1345 motd:
1346 - release: |
1347 #!/bin/sh
1348 [ -r /etc/lsb-release ] && . /etc/lsb-release
1349
1350 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
1351 # Fall back to using the very slow lsb_release utility
1352 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
1353 fi
1354
1355 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
1356 - warning: |
1357 #!/bin/sh
1358 printf "This is [company name] network.\n"
1359 printf "Unauthorized access strictly prohibited.\n"
1360
Marek Celoud713e9072017-05-18 15:20:25 +02001361Services
1362~~~~~~~~
1363
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001364Stop and disable the ``linux`` service:
Marek Celoud713e9072017-05-18 15:20:25 +02001365
1366.. code-block:: yaml
1367
1368 linux:
1369 system:
1370 service:
1371 apt-daily.timer:
1372 status: dead
1373
Dzmitry Stremkouski70d09782018-11-30 16:04:59 +01001374Override systemd service unit:
1375
1376.. code-block:: yaml
1377
1378 parameters:
1379
1380 linux:
1381 system:
1382 service:
1383 tgt:
1384 name: tgt
1385 status: running
1386 enabled: True
1387 override:
1388 50:
1389 target: tgt.service.d
1390 name: bind
1391 content: |
1392 [Service]
1393 ExecStart=
1394 ExecStart=/usr/sbin/tgtd -f --iscsi portal=${_param:single_address}:3260
1395
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001396Possible statuses are ``dead`` (disable service by default), ``running``
1397(enable service by default), ``enabled``, ``disabled``:
Marek Celoud713e9072017-05-18 15:20:25 +02001398
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001399Linux with the ``atop`` service:
Serhiy Ovsianikov67bd56a2017-08-11 15:56:01 +03001400
1401.. code-block:: yaml
1402
1403 linux:
1404 system:
1405 atop:
1406 enabled: true
1407 interval: 20
1408 logpath: "/var/log/atop"
1409 outfile: "/var/log/atop/daily.log"
1410
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001411Linux with the ``mcelog`` service:
Oleksii Chupryn144432b2018-05-22 10:34:48 +03001412
1413.. code-block:: yaml
1414
1415 linux:
1416 system:
1417 mcelog:
1418 enabled: true
1419 logging:
1420 syslog: true
1421 syslog_error: true
1422
Filip Pytloun2f70b492016-02-19 15:55:25 +01001423RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +01001424^^^^^^^^^^^^^
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001425Currently, ``update-motd`` is not available
1426for RHEL. So there is no native support for dynamic ``motd``.
1427You can still set a static one, with a different pillar structure:
Filip Pytloun2f70b492016-02-19 15:55:25 +01001428
1429.. code-block:: yaml
1430
1431 linux:
1432 system:
1433 motd: |
1434 This is [company name] network.
1435 Unauthorized access strictly prohibited.
1436
Filip Pytloun8296bb92016-02-19 18:42:09 +01001437Haveged
1438~~~~~~~
1439
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001440If you are running headless server and are low on entropy,
1441you may set up Haveged:
Filip Pytloun8296bb92016-02-19 18:42:09 +01001442
1443.. code-block:: yaml
1444
1445 linux:
1446 system:
1447 haveged:
1448 enabled: true
1449
Filip Pytlounf5383a42015-10-06 16:28:32 +02001450Linux network
1451-------------
1452
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001453Linux with network manager:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001454
1455.. code-block:: yaml
1456
1457 linux:
1458 network:
1459 enabled: true
1460 network_manager: true
1461
Dzmitry Stremkouski00cdbe62018-10-31 16:41:54 +01001462Execute linux.network.interface state without ifupdown activity:
1463
1464.. code-block:: bash
1465
1466 salt-call linux.network.interface pillar='{"linux":{"network":{"noifupdown":True}}}'
1467
1468
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001469Linux with default static network interfaces, default gateway
1470interface and DNS servers:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001471
1472.. code-block:: yaml
1473
1474 linux:
1475 network:
1476 enabled: true
1477 interface:
1478 eth0:
1479 enabled: true
1480 type: eth
1481 address: 192.168.0.102
1482 netmask: 255.255.255.0
1483 gateway: 192.168.0.1
1484 name_servers:
1485 - 8.8.8.8
1486 - 8.8.4.4
1487 mtu: 1500
1488
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001489Linux with bonded interfaces and disabled ``NetworkManager``:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001490
1491.. code-block:: yaml
1492
1493 linux:
1494 network:
1495 enabled: true
1496 interface:
1497 eth0:
1498 type: eth
1499 ...
1500 eth1:
1501 type: eth
1502 ...
1503 bond0:
1504 enabled: true
1505 type: bond
1506 address: 192.168.0.102
1507 netmask: 255.255.255.0
1508 mtu: 1500
1509 use_in:
1510 - interface: ${linux:interface:eth0}
1511 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +01001512 network_manager:
1513 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001514
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001515Linux with VLAN ``interface_params``:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001516
1517.. code-block:: yaml
1518
1519 linux:
1520 network:
1521 enabled: true
1522 interface:
1523 vlan69:
1524 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +01001525 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001526 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001527
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001528Linux with wireless interface parameters:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001529
1530.. code-block:: yaml
1531
1532 linux:
1533 network:
1534 enabled: true
1535 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001536 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001537 interface:
1538 wlan0:
1539 type: eth
1540 wireless:
1541 essid: example
1542 key: example_key
1543 security: wpa
1544 priority: 1
1545
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001546Linux networks with routes defined:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001547
1548.. code-block:: yaml
1549
1550 linux:
1551 network:
1552 enabled: true
1553 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001554 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001555 interface:
1556 eth0:
1557 type: eth
1558 route:
1559 default:
1560 address: 192.168.0.123
1561 netmask: 255.255.255.0
1562 gateway: 192.168.0.1
1563
ivce5011da2019-01-23 07:56:53 +03001564Linux networks with implicit routes definition:
1565
1566- on node 1:
1567
1568.. code-block:: yaml
1569
1570 linux:
1571 network:
1572 enabled: true
1573 router:
1574 ctl:
1575 # router that connects 10.0.1.0/24 and 10.0.2.0/24
1576 addresses:
1577 - 10.0.1.1/24
1578 - 10.0.2.1/24
1579 test:
1580 addresses:
1581 - 10.0.1.2/24
1582 networks:
1583 - 10.100.0.0/16
1584 interface:
1585 ctl:
1586 name: eth0
1587 address: 10.0.1.101
1588 netmask: 255.255.255.0
1589
1590- on node2:
1591
1592.. code-block:: yaml
1593
1594 linux:
1595 network:
1596 enabled: true
1597 router:
1598 ctl:
1599 # equivalent of node1's ctl router with 'implicit_routes = false'
1600 options:
1601 implicit_routes: false
1602 addresses:
1603 - 10.0.1.1/24
1604 - 10.0.2.1/24
1605 networks:
1606 - 10.0.1.0/24
1607 - 10.0.2.0/24
1608 interface:
1609 ctl:
1610 name: eth0
1611 address: 10.0.2.101
1612 netmask: 255.255.255.0
1613
1614
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001615Native Linux Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001616
1617.. code-block:: yaml
1618
1619 linux:
1620 network:
1621 interface:
1622 eth1:
1623 enabled: true
1624 type: eth
1625 proto: manual
1626 up_cmds:
1627 - ip address add 0/0 dev $IFACE
1628 - ip link set $IFACE up
1629 down_cmds:
1630 - ip link set $IFACE down
1631 br-ex:
1632 enabled: true
1633 type: bridge
1634 address: ${linux:network:host:public_local:address}
1635 netmask: 255.255.255.0
1636 use_interfaces:
1637 - eth1
1638
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001639Open vSwitch Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001640
1641.. code-block:: yaml
1642
1643 linux:
1644 network:
1645 bridge: openvswitch
1646 interface:
1647 eth1:
1648 enabled: true
1649 type: eth
1650 proto: manual
1651 up_cmds:
1652 - ip address add 0/0 dev $IFACE
1653 - ip link set $IFACE up
1654 down_cmds:
1655 - ip link set $IFACE down
1656 br-ex:
1657 enabled: true
1658 type: bridge
1659 address: ${linux:network:host:public_local:address}
1660 netmask: 255.255.255.0
1661 use_interfaces:
1662 - eth1
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001663 br-prv:
1664 enabled: true
1665 type: ovs_bridge
1666 mtu: 65000
1667 br-ens7:
1668 enabled: true
1669 name: br-ens7
1670 type: ovs_bridge
1671 proto: manual
1672 mtu: 9000
1673 use_interfaces:
1674 - ens7
1675 patch-br-ens7-br-prv:
1676 enabled: true
1677 name: ens7-prv
1678 ovs_type: ovs_port
1679 type: ovs_port
1680 bridge: br-ens7
1681 port_type: patch
1682 peer: prv-ens7
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001683 tag: 109 # [] to unset a tag
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001684 mtu: 65000
1685 patch-br-prv-br-ens7:
1686 enabled: true
1687 name: prv-ens7
1688 bridge: br-prv
1689 ovs_type: ovs_port
1690 type: ovs_port
1691 port_type: patch
1692 peer: ens7-prv
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001693 tag: 109
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001694 mtu: 65000
1695 ens7:
1696 enabled: true
1697 name: ens7
1698 proto: manual
1699 ovs_port_type: OVSPort
1700 type: ovs_port
1701 ovs_bridge: br-ens7
1702 bridge: br-ens7
Oleg Gelbukh36f01072019-07-01 15:26:16 -07001703 ens6:
1704 enabled: true
1705 proto: manual
1706 type: eth
1707 ovs_bridge: br-ctl
1708 br-ctl:
1709 enabled: true
1710 type: ovs_bridge
1711 internal-br-ctl-port:
1712 enabled: true
1713 proto: static
1714 address: 172.172.0.10
1715 netmask: 255.255.0.0
1716 name_servers:
1717 - 8.8.8.8
1718 - 172.172.172.172
1719 name: port-br-ctl
1720 bridge: br-ctl
1721 ovs_type: ovs_port
1722 type: ovs_port
1723 port_type: internal
1724 mtu: 65000
Filip Pytlounf5383a42015-10-06 16:28:32 +02001725
Petr Jediný8f8ae542017-07-13 16:19:12 +02001726Debian manual proto interfaces
1727
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001728When you are changing interface proto from static in up state
1729to manual, you may need to flush ip addresses. For example,
1730if you want to use the interface and the ip on the bridge.
1731This can be done by setting the ``ipflush_onchange`` to true.
Petr Jediný8f8ae542017-07-13 16:19:12 +02001732
1733.. code-block:: yaml
1734
1735 linux:
1736 network:
1737 interface:
1738 eth1:
1739 enabled: true
1740 type: eth
1741 proto: manual
1742 mtu: 9100
1743 ipflush_onchange: true
1744
Jiri Broulik1a191e32018-01-15 15:54:21 +01001745Debian static proto interfaces
1746
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001747When you are changing interface proto from dhcp in up state to
1748static, you may need to flush ip addresses and restart interface
1749to assign ip address from a managed file. For example, if you wantto
1750use the interface and the ip on the bridge. This can be done by
1751setting the ``ipflush_onchange`` with combination ``restart_on_ipflush``
1752param set to true.
Jiri Broulik1a191e32018-01-15 15:54:21 +01001753
1754.. code-block:: yaml
1755
1756 linux:
1757 network:
1758 interface:
1759 eth1:
1760 enabled: true
1761 type: eth
1762 proto: static
1763 address: 10.1.0.22
1764 netmask: 255.255.255.0
1765 ipflush_onchange: true
1766 restart_on_ipflush: true
Petr Jediný8f8ae542017-07-13 16:19:12 +02001767
Petr Jedinýd577cb52017-06-28 20:17:49 +02001768Concatinating and removing interface files
1769
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001770Debian based distributions have ``/etc/network/interfaces.d/``
1771directory, where you can store configuration of network
1772interfaces in separate files. You can concatinate the files
1773to the defined destination when needed, this operation removes
1774the file from the ``/etc/network/interfaces.d/``. If you just need
1775to remove iface files, you can use the ``remove_iface_files`` key.
Petr Jedinýd577cb52017-06-28 20:17:49 +02001776
1777.. code-block:: yaml
1778
1779 linux:
1780 network:
1781 concat_iface_files:
1782 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
1783 dst: '/etc/network/interfaces'
1784 remove_iface_files:
1785 - '/etc/network/interfaces.d/90-custom.cfg'
1786
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001787Configure DHCP client
Petr Jedinýd577cb52017-06-28 20:17:49 +02001788
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001789None of the keys is mandatory, include only those you really need.
1790For full list of available options under send, supersede, prepend,
1791append refer to dhcp-options(5).
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001792
1793.. code-block:: yaml
1794
1795 linux:
1796 network:
1797 dhclient:
1798 enabled: true
1799 backoff_cutoff: 15
1800 initial_interval: 10
1801 reboot: 10
1802 retry: 60
1803 select_timeout: 0
1804 timeout: 120
1805 send:
1806 - option: host-name
1807 declaration: "= gethostname()"
1808 supersede:
1809 - option: host-name
1810 declaration: "spaceship"
1811 - option: domain-name
1812 declaration: "domain.home"
1813 #- option: arp-cache-timeout
1814 # declaration: 20
1815 prepend:
1816 - option: domain-name-servers
1817 declaration:
1818 - 8.8.8.8
1819 - 8.8.4.4
1820 - option: domain-search
1821 declaration:
1822 - example.com
1823 - eng.example.com
1824 #append:
1825 #- option: domain-name-servers
1826 # declaration: 127.0.0.1
1827 # ip or subnet to reject dhcp offer from
1828 reject:
1829 - 192.33.137.209
1830 - 10.0.2.0/24
1831 request:
1832 - subnet-mask
1833 - broadcast-address
1834 - time-offset
1835 - routers
1836 - domain-name
1837 - domain-name-servers
1838 - domain-search
1839 - host-name
1840 - dhcp6.name-servers
1841 - dhcp6.domain-search
1842 - dhcp6.fqdn
1843 - dhcp6.sntp-servers
1844 - netbios-name-servers
1845 - netbios-scope
1846 - interface-mtu
1847 - rfc3442-classless-static-routes
1848 - ntp-servers
1849 require:
1850 - subnet-mask
1851 - domain-name-servers
1852 # if per interface configuration required add below
1853 interface:
1854 ens2:
1855 initial_interval: 11
1856 reject:
1857 - 192.33.137.210
1858 ens3:
1859 initial_interval: 12
1860 reject:
1861 - 192.33.137.211
1862
Petr Michaleceb14b552017-06-01 10:27:05 +02001863Linux network systemd settings:
1864
1865.. code-block:: yaml
1866
1867 linux:
1868 network:
1869 ...
1870 systemd:
1871 link:
1872 10-iface-dmz:
1873 Match:
1874 MACAddress: c8:5b:67:fa:1a:af
1875 OriginalName: eth0
1876 Link:
1877 Name: dmz0
1878 netdev:
1879 20-bridge-dmz:
1880 match:
1881 name: dmz0
1882 network:
1883 mescription: bridge
1884 bridge: br-dmz0
1885 network:
1886 # works with lowercase, keys are by default capitalized
1887 40-dhcp:
1888 match:
1889 name: '*'
1890 network:
1891 DHCP: yes
1892
Petr Michalec10462bb2017-03-23 19:18:08 +01001893Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +01001894
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001895Use ``/etc/environment`` for static system wide variable assignment
1896after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001897
1898.. code-block:: yaml
1899
1900 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +01001901 system:
1902 env:
1903 BOB_VARIABLE: Alice
1904 ...
1905 BOB_PATH:
1906 - /srv/alice/bin
1907 - /srv/bob/bin
1908 ...
1909 ftp_proxy: none
1910 http_proxy: http://global-http-proxy.host.local:8080
1911 https_proxy: ${linux:system:proxy:https}
1912 no_proxy:
1913 - 192.168.0.80
1914 - 192.168.1.80
1915 - .domain.com
1916 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001917 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001918 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001919 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001920 ftp: ftp://proxy.host.local:2121
1921 http: http://proxy.host.local:3142
1922 https: https://proxy.host.local:3143
1923 noproxy:
1924 - .domain.com
1925 - .local
1926
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001927Configure the ``profile.d`` scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001928
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001929The ``profile.d`` scripts are being sourced during ``.sh`` execution
1930and support variable expansion in opposite to /etc/environment global
1931settings in ``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001932
1933.. code-block:: yaml
1934
1935 linux:
1936 system:
1937 profile:
1938 locales: |
1939 export LANG=C
1940 export LC_ALL=C
1941 ...
1942 vi_flavors.sh: |
1943 export PAGER=view
1944 export EDITOR=vim
1945 alias vi=vim
1946 shell_locales.sh: |
1947 export LANG=en_US
1948 export LC_ALL=en_US.UTF-8
1949 shell_proxies.sh: |
1950 export FTP_PROXY=ftp://127.0.3.3:2121
1951 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001952
Dmitry Teselkina0d31d12018-09-04 14:43:09 +03001953
1954Configure login.defs parameters
1955-------------------------------
1956
1957.. code-block:: yaml
1958
1959 linux:
1960 system:
1961 login_defs:
1962 <opt_name>:
1963 enabled: true
1964 value: <opt_value>
1965
1966<opt_name> is a configurational option defined in 'man login.defs'.
1967<opt_name> is case sensitive, should be UPPERCASE only!
1968
1969
Filip Pytlounf5383a42015-10-06 16:28:32 +02001970Linux with hosts
1971
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001972Parameter ``purge_hosts`` will enforce whole ``/etc/hosts file``,
1973removing entries that are not defined in model except defaults
1974for both IPv4 and IPv6 localhost and hostname as well as FQDN.
Ales Komarek417e8c52017-08-25 15:10:29 +02001975
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001976We recommend using this option to verify that ``/etc/hosts``
1977is always in a clean state. However it is not enabled by default
1978for security reasons.
Filip Pytloun86506fe2017-01-26 14:36:16 +01001979
Filip Pytlounf5383a42015-10-06 16:28:32 +02001980.. code-block:: yaml
1981
1982 linux:
1983 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001984 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001985 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001986 # No need to define this one if purge_hosts is true
1987 hostname:
1988 address: 127.0.1.1
1989 names:
1990 - ${linux:network:fqdn}
1991 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001992 node1:
1993 address: 192.168.10.200
1994 names:
1995 - node2.domain.com
1996 - service2.domain.com
1997 node2:
1998 address: 192.168.10.201
1999 names:
2000 - node2.domain.com
2001 - service2.domain.com
2002
Ales Komarek417e8c52017-08-25 15:10:29 +02002003Linux with hosts collected from mine
2004
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002005All DNS records defined within infrastrucuture
2006are passed to the local hosts records or any DNS server. Only
2007hosts with the ``grain`` parameter set to ``true`` will be propagated
2008to the mine.
Ales Komarek417e8c52017-08-25 15:10:29 +02002009
2010.. code-block:: yaml
2011
2012 linux:
2013 network:
2014 purge_hosts: true
2015 mine_dns_records: true
2016 host:
2017 node1:
2018 address: 192.168.10.200
2019 grain: true
2020 names:
2021 - node2.domain.com
2022 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01002023
Michael Polenchukc80ddd42019-01-15 18:47:48 +04002024Set up ``resolvconf's basic resolver info``, e.g. nameservers, search/domain and options:
Filip Pytlounde9bea52016-01-11 15:39:10 +01002025
2026.. code-block:: yaml
2027
2028 linux:
2029 network:
2030 resolv:
2031 dns:
Michael Polenchukc80ddd42019-01-15 18:47:48 +04002032 - 8.8.4.4
2033 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01002034 domain: my.example.com
2035 search:
Michael Polenchukc80ddd42019-01-15 18:47:48 +04002036 - my.example.com
2037 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01002038 options:
Michael Polenchukc80ddd42019-01-15 18:47:48 +04002039 - ndots:5
2040 - timeout:2
2041 - attempts:2
Filip Pytlounde9bea52016-01-11 15:39:10 +01002042
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002043Set up custom TX queue length for tap interfaces:
Andrii Petrenko735761d2017-03-21 17:17:35 -07002044
2045.. code-block:: yaml
2046
2047 linux:
2048 network:
2049 tap_custom_txqueuelen: 10000
2050
Michael Polenchukc37bd4a2019-04-22 15:20:03 +04002051Auto repair/re-attach libvirt's vnet interfaces:
2052
2053.. code-block:: yaml
2054
2055 linux:
2056 network:
2057 libvirt_vnet_repair: true
2058
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002059DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002060
2061**DPDK OVS NIC**
2062
2063.. code-block:: yaml
2064
2065 linux:
2066 network:
2067 bridge: openvswitch
2068 dpdk:
2069 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04002070 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002071 openvswitch:
2072 pmd_cpu_mask: "0x6"
2073 dpdk_socket_mem: "1024,1024"
2074 dpdk_lcore_mask: "0x400"
2075 memory_channels: 2
2076 interface:
2077 dpkd0:
2078 name: ${_param:dpdk_nic}
2079 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002080 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002081 enabled: true
2082 type: dpdk_ovs_port
2083 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002084 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002085 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01002086 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002087 br-prv:
2088 enabled: true
2089 type: dpdk_ovs_bridge
2090
2091**DPDK OVS Bond**
2092
2093.. code-block:: yaml
2094
2095 linux:
2096 network:
2097 bridge: openvswitch
2098 dpdk:
2099 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04002100 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002101 openvswitch:
2102 pmd_cpu_mask: "0x6"
2103 dpdk_socket_mem: "1024,1024"
2104 dpdk_lcore_mask: "0x400"
2105 memory_channels: 2
2106 interface:
2107 dpdk_second_nic:
2108 name: ${_param:primary_second_nic}
2109 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002110 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002111 bond: dpdkbond0
2112 enabled: true
2113 type: dpdk_ovs_port
2114 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002115 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002116 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002117 dpdk_first_nic:
2118 name: ${_param:primary_first_nic}
2119 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002120 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002121 bond: dpdkbond0
2122 enabled: true
2123 type: dpdk_ovs_port
2124 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002125 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002126 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002127 dpdkbond0:
2128 enabled: true
2129 bridge: br-prv
2130 type: dpdk_ovs_bond
2131 mode: active-backup
2132 br-prv:
2133 enabled: true
2134 type: dpdk_ovs_bridge
2135
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01002136**DPDK OVS LACP Bond with vlan tag**
2137
2138.. code-block:: yaml
2139
2140 linux:
2141 network:
2142 bridge: openvswitch
2143 dpdk:
2144 enabled: true
2145 driver: uio
2146 openvswitch:
2147 pmd_cpu_mask: "0x6"
2148 dpdk_socket_mem: "1024,1024"
2149 dpdk_lcore_mask: "0x400"
2150 memory_channels: "2"
2151 interface:
2152 eth3:
2153 enabled: true
2154 type: eth
2155 proto: manual
2156 name: ${_param:tenant_first_nic}
2157 eth4:
2158 enabled: true
2159 type: eth
2160 proto: manual
2161 name: ${_param:tenant_second_nic}
2162 dpdk0:
2163 name: ${_param:tenant_first_nic}
2164 pci: "0000:81:00.0"
2165 driver: igb_uio
2166 bond: bond1
2167 enabled: true
2168 type: dpdk_ovs_port
2169 n_rxq: 2
2170 dpdk1:
2171 name: ${_param:tenant_second_nic}
2172 pci: "0000:81:00.1"
2173 driver: igb_uio
2174 bond: bond1
2175 enabled: true
2176 type: dpdk_ovs_port
2177 n_rxq: 2
2178 bond1:
2179 enabled: true
2180 bridge: br-prv
2181 type: dpdk_ovs_bond
2182 mode: balance-slb
2183 br-prv:
2184 enabled: true
2185 type: dpdk_ovs_bridge
2186 tag: ${_param:tenant_vlan}
2187 address: ${_param:tenant_address}
2188 netmask: ${_param:tenant_network_netmask}
2189
Jakub Pavlikaa759062017-03-13 15:57:26 +01002190**DPDK OVS bridge for VXLAN**
2191
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002192If VXLAN is used as tenant segmentation, IP address must
2193be set on ``br-prv``.
Jakub Pavlikaa759062017-03-13 15:57:26 +01002194
2195.. code-block:: yaml
2196
2197 linux:
2198 network:
2199 ...
2200 interface:
2201 br-prv:
2202 enabled: true
2203 type: dpdk_ovs_bridge
2204 address: 192.168.50.0
2205 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04002206 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01002207 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002208
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02002209**DPDK OVS bridge with Linux network interface**
2210
2211.. code-block:: yaml
2212
2213 linux:
2214 network:
2215 ...
2216 interface:
2217 eth0:
2218 type: eth
2219 ovs_bridge: br-prv
2220 ...
2221 br-prv:
2222 enabled: true
2223 type: dpdk_ovs_bridge
2224 ...
2225
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002226Linux storage
2227-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02002228
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002229Linux with mounted Samba:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002230
2231.. code-block:: yaml
2232
2233 linux:
2234 storage:
2235 enabled: true
2236 mount:
2237 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01002238 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02002239 - path: /media/myuser/public/
2240 - device: //192.168.0.1/storage
2241 - file_system: cifs
2242 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
2243
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002244NFS mount:
Jiri Broulikb017f932017-03-31 13:55:36 +02002245
2246.. code-block:: yaml
2247
2248 linux:
2249 storage:
2250 enabled: true
2251 mount:
2252 nfs_glance:
2253 enabled: true
2254 path: /var/lib/glance/images
2255 device: 172.16.10.110:/var/nfs/glance
2256 file_system: nfs
2257 opts: rw,sync
2258
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002259File swap configuration:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002260
2261.. code-block:: yaml
2262
2263 linux:
2264 storage:
2265 enabled: true
2266 swap:
2267 file:
2268 enabled: true
2269 engine: file
2270 device: /swapfile
2271 size: 1024
2272
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002273Partition swap configuration:
Lachlan Evenson30676512016-01-22 15:43:28 -08002274
2275.. code-block:: yaml
2276
2277 linux:
2278 storage:
2279 enabled: true
2280 swap:
2281 partition:
2282 enabled: true
2283 engine: partition
2284 device: /dev/vg0/swap
2285
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002286LVM group ``vg1`` with one device and ``data`` volume mounted
2287into ``/mnt/data``.
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002288
2289.. code-block:: yaml
2290
2291 parameters:
2292 linux:
2293 storage:
2294 mount:
2295 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01002296 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002297 device: /dev/vg1/data
2298 file_system: ext4
2299 path: /mnt/data
2300 lvm:
2301 vg1:
2302 enabled: true
2303 devices:
2304 - /dev/sdb
2305 volume:
2306 data:
2307 size: 40G
2308 mount: ${linux:storage:mount:data}
root3387f332019-01-11 08:55:32 +00002309 # When set they will take precedence over filters aget from volume groups.
2310 lvm_filters:
2311 10:
2312 enabled: True
2313 value: "a|loop|"
2314 20:
2315 enabled: True
2316 value: "r|/dev/hdc|"
2317 30:
2318 enabled: True
2319 value: "a|/dev/ide|"
2320 40:
2321 enabled: True
2322 value: "r|.*|"
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002323
Jakub Pavlik4f742142017-08-08 15:05:50 +02002324Create partitions on disk. Specify size in MB. It expects empty
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002325disk without any existing partitions.
2326Set ``startsector=1`` if you want to start partitions from ``2048``.
Jakub Pavlik4f742142017-08-08 15:05:50 +02002327
2328.. code-block:: yaml
2329
2330 linux:
2331 storage:
2332 disk:
2333 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01002334 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02002335 name: /dev/loop1
2336 type: gpt
2337 partitions:
2338 - size: 200 #size in MB
2339 type: fat32
2340 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02002341 mkfs: True
2342 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02002343 /dev/vda1:
2344 partitions:
2345 - size: 5
2346 type: ext2
2347 - size: 10
2348 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02002349
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002350Multipath with Fujitsu Eternus DXL:
Ales Komareka634f4b2016-10-02 13:11:04 +02002351
2352.. code-block:: yaml
2353
2354 parameters:
2355 linux:
2356 storage:
2357 multipath:
2358 enabled: true
2359 blacklist_devices:
2360 - /dev/sda
2361 - /dev/sdb
2362 backends:
2363 - fujitsu_eternus_dxl
2364
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002365Multipath with Hitachi VSP 1000:
Ales Komareka634f4b2016-10-02 13:11:04 +02002366
2367.. code-block:: yaml
2368
2369 parameters:
2370 linux:
2371 storage:
2372 multipath:
2373 enabled: true
2374 blacklist_devices:
2375 - /dev/sda
2376 - /dev/sdb
2377 backends:
2378 - hitachi_vsp1000
2379
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002380Multipath with IBM Storwize:
Ales Komareka634f4b2016-10-02 13:11:04 +02002381
2382.. code-block:: yaml
2383
2384 parameters:
2385 linux:
2386 storage:
2387 multipath:
2388 enabled: true
2389 blacklist_devices:
2390 - /dev/sda
2391 - /dev/sdb
2392 backends:
2393 - ibm_storwize
2394
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002395Multipath with multiple backends:
Ales Komareka634f4b2016-10-02 13:11:04 +02002396
2397.. code-block:: yaml
2398
2399 parameters:
2400 linux:
2401 storage:
2402 multipath:
2403 enabled: true
2404 blacklist_devices:
2405 - /dev/sda
2406 - /dev/sdb
2407 - /dev/sdc
2408 - /dev/sdd
2409 backends:
2410 - ibm_storwize
2411 - fujitsu_eternus_dxl
2412 - hitachi_vsp1000
2413
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002414PAM LDAP integration:
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002415
2416.. code-block:: yaml
2417
2418 parameters:
2419 linux:
2420 system:
2421 auth:
2422 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02002423 mkhomedir:
2424 enabled: true
2425 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002426 ldap:
2427 enabled: true
2428 binddn: cn=bind,ou=service_users,dc=example,dc=com
2429 bindpw: secret
2430 uri: ldap://127.0.0.1
2431 base: ou=users,dc=example,dc=com
2432 ldap_version: 3
2433 pagesize: 65536
2434 referrals: off
2435 filter:
2436 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2437 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2438 group: (&(objectClass=group)(gidNumber=*))
2439
Gleb Galkin93b9ae92018-10-18 13:57:30 +03002440PAM duo 2FA integration
2441
2442.. code-block:: yaml
2443
2444 parameters:
2445 linux:
2446 system:
2447 auth:
2448 enabled: true
2449 duo:
2450 enabled: true
2451 duo_host: localhost
2452 duo_ikey: DUO-INTEGRATION-KEY
2453 duo_skey: DUO-SECRET-KEY
2454
2455duo package version may be specified (optional)
2456
2457.. code-block:: yaml
2458
2459 linux:
2460 system:
2461 package:
2462 duo-unix:
2463 version: 1.10.1-0
2464
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002465Disabled multipath (the default setup):
Ales Komareka634f4b2016-10-02 13:11:04 +02002466
2467.. code-block:: yaml
2468
2469 parameters:
2470 linux:
2471 storage:
2472 multipath:
2473 enabled: false
2474
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002475Linux with local loopback device:
Simon Pasquier375001e2017-01-26 13:22:33 +01002476
2477.. code-block:: yaml
2478
2479 linux:
2480 storage:
2481 loopback:
2482 disk1:
2483 file: /srv/disk1
2484 size: 50G
2485
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002486External config generation
2487--------------------------
2488
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002489You are able to use config support metadata between formulas
2490and only generate configuration files for external use, for example, Docker, and so on.
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002491
2492.. code-block:: yaml
2493
2494 parameters:
2495 linux:
2496 system:
2497 config:
2498 pillar:
2499 jenkins:
2500 master:
2501 home: /srv/volumes/jenkins
2502 approved_scripts:
2503 - method java.net.URL openConnection
2504 credentials:
2505 - type: username_password
2506 scope: global
2507 id: test
2508 desc: Testing credentials
2509 username: test
2510 password: test
2511
Vladimir Ereminccf28842017-04-10 23:52:10 +03002512Netconsole Remote Kernel Logging
2513--------------------------------
2514
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002515Netconsole logger can be configured for the configfs-enabled kernels
2516(``CONFIG_NETCONSOLE_DYNAMIC`` must be enabled). The configuration
2517applies both in runtime (if network is already configured),
2518and on-boot after an interface initialization.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002519
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002520.. note::
2521
2522 * Receiver can be located only on the same L3 domain
2523 (or you need to configure gateway MAC manually).
2524 * The Receiver MAC is detected only on configuration time.
2525 * Using broadcast MAC is not recommended.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002526
2527.. code-block:: yaml
2528
2529 parameters:
2530 linux:
2531 system:
2532 netconsole:
2533 enabled: true
2534 port: 514 (optional)
2535 loglevel: debug (optional)
2536 target:
2537 192.168.0.1:
2538 interface: bond0
2539 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02002540
Dzmitry Stremkouskid1a268b2018-10-03 16:36:04 +02002541Check network params on the environment
2542---------------------------------------
2543
2544Grab nics and nics states
2545
2546.. code-block:: bash
2547
2548 salt osd001\* net_checks.get_nics
2549
2550**Example of system output:**
2551
2552.. code-block:: bash
2553
2554 osd001.domain.com:
2555 |_
2556 - bond0
2557 - None
2558 - 1e:c8:64:42:23:b9
2559 - 0
2560 - 1500
2561 |_
2562 - bond1
2563 - None
2564 - 3c:fd:fe:27:3b:00
2565 - 1
2566 - 9100
2567 |_
2568 - fourty1
2569 - None
2570 - 3c:fd:fe:27:3b:00
2571 - 1
2572 - 9100
2573 |_
2574 - fourty2
2575 - None
2576 - 3c:fd:fe:27:3b:02
2577 - 1
2578 - 9100
2579
2580Grab 10G nics PCI addresses for hugepages setup
2581
2582.. code-block:: bash
2583
2584 salt cmp001\* net_checks.get_ten_pci
2585
2586**Example of system output:**
2587
2588.. code-block:: bash
2589
2590 cmp001.domain.com:
2591 |_
2592 - ten1
2593 - 0000:19:00.0
2594 |_
2595 - ten2
2596 - 0000:19:00.1
2597 |_
2598 - ten3
2599 - 0000:19:00.2
2600 |_
2601 - ten4
2602 - 0000:19:00.3
2603
2604Grab ip address for an interface
2605
2606.. code-block:: bash
2607
2608 salt cmp001\* net_checks.get_ip iface=one4
2609
2610**Example of system output:**
2611
2612.. code-block:: bash
2613
2614 cmp001.domain.com:
2615 10.200.177.101
2616
2617Grab ip addresses map
2618
2619.. code-block:: bash
2620
2621 salt-call net_checks.nodes_addresses
2622
2623**Example of system output:**
2624
2625.. code-block:: bash
2626
2627 local:
2628 |_
2629 - cid01.domain.com
2630 |_
2631 |_
2632 - pxe
2633 - 10.200.177.91
2634 |_
2635 - control
2636 - 10.200.178.91
2637 |_
2638 - cmn02.domain.com
2639 |_
2640 |_
2641 - storage_access
2642 - 10.200.181.67
2643 |_
2644 - pxe
2645 - 10.200.177.67
2646 |_
2647 - control
2648 - 10.200.178.67
2649 |_
2650 - cmp010.domain.com
2651 |_
2652 |_
2653 - pxe
2654 - 10.200.177.110
2655 |_
2656 - storage_access
2657 - 10.200.181.110
2658 |_
2659 - control
2660 - 10.200.178.110
2661 |_
2662 - vxlan
2663 - 10.200.179.110
2664
2665Verify full mesh connectivity
2666
2667.. code-block:: bash
2668
2669 salt-call net_checks.ping_check
2670
2671**Example of positive system output:**
2672
2673.. code-block:: bash
2674
2675 ['PASSED']
2676 [INFO ] ['PASSED']
2677 local:
2678 True
2679
2680**Example of system output in case of failure:**
2681
2682.. code-block:: bash
2683
2684 FAILED
2685 [ERROR ] FAILED
2686 ['control: 10.0.1.92 -> 10.0.1.224: Failed']
2687 ['control: 10.0.1.93 -> 10.0.1.224: Failed']
2688 ['control: 10.0.1.51 -> 10.0.1.224: Failed']
2689 ['control: 10.0.1.102 -> 10.0.1.224: Failed']
2690 ['control: 10.0.1.13 -> 10.0.1.224: Failed']
2691 ['control: 10.0.1.81 -> 10.0.1.224: Failed']
2692 local:
2693 False
2694
2695For this feature to work, please mark addresses with some role.
2696Otherwise 'default' role is assumed and mesh would consist of all
2697addresses on the environment.
2698
2699Mesh mark is needed only for interfaces which are enabled and have
2700ip address assigned.
2701
2702Checking dhcp pxe network meaningless, as it is used for salt
2703master vs minion communications, therefore treated as checked.
2704
2705.. code-block:: yaml
2706
2707 parameters:
2708 linux:
2709 network:
2710 interface:
2711 ens3:
2712 enabled: true
2713 type: eth
2714 proto: static
2715 address: ${_param:deploy_address}
2716 netmask: ${_param:deploy_network_netmask}
2717 gateway: ${_param:deploy_network_gateway}
2718 mesh: pxe
2719
2720Check pillars for ip address duplicates
2721
2722.. code-block:: bash
2723
2724 salt-call net_checks.verify_addresses
2725
2726**Example of positive system output:**
2727
2728.. code-block:: bash
2729
2730 ['PASSED']
2731 [INFO ] ['PASSED']
2732 local:
2733 True
2734
2735**Example of system output in case of failure:**
2736
2737.. code-block:: bash
2738
2739 FAILED. Duplicates found
2740 [ERROR ] FAILED. Duplicates found
2741 ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2742 [ERROR ] ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2743 local:
2744 False
2745
2746Generate csv report for the env
2747
2748.. code-block:: bash
2749
2750 salt -C 'kvm* or cmp* or osd*' net_checks.get_nics_csv \
2751 | grep '^\ ' | sed 's/\ *//g' | grep -Ev ^server \
2752 | sed '1 i\server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr'
2753
2754**Example of system output:**
2755
2756.. code-block:: bash
2757
2758 server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr
2759 cmp010.domain.com,bond0,None,b4:96:91:10:5b:3a,1,1500,,,,
2760 cmp010.domain.com,bond0.21,10.200.178.110,b4:96:91:10:5b:3a,1,1500,,,,
2761 cmp010.domain.com,bond0.22,10.200.179.110,b4:96:91:10:5b:3a,1,1500,,,,
2762 cmp010.domain.com,bond1,None,3c:fd:fe:34:ad:22,0,1500,,,,
2763 cmp010.domain.com,bond1.24,10.200.181.110,3c:fd:fe:34:ad:22,0,1500,,,,
2764 cmp010.domain.com,fourty5,None,3c:fd:fe:34:ad:20,0,9000,,,,
2765 cmp010.domain.com,fourty6,None,3c:fd:fe:34:ad:22,0,9000,,,,
2766 cmp010.domain.com,one1,None,b4:96:91:10:5b:38,0,1500,,,,
2767 cmp010.domain.com,one2,None,b4:96:91:10:5b:39,1,1500,f0:4b:3a:8f:75:40,exnfvaa18-20,548,ge-0/0/22
2768 cmp010.domain.com,one3,None,b4:96:91:10:5b:3a,1,1500,f0:4b:3a:8f:75:40,exnfvaa18-20,547,ge-0/0/21
2769 cmp010.domain.com,one4,10.200.177.110,b4:96:91:10:5b:3b,1,1500,f0:4b:3a:8f:75:40,exnfvaa18-20,546,ge-0/0/20
2770 cmp011.domain.com,bond0,None,b4:96:91:13:6c:aa,1,1500,,,,
2771 cmp011.domain.com,bond0.21,10.200.178.111,b4:96:91:13:6c:aa,1,1500,,,,
2772 cmp011.domain.com,bond0.22,10.200.179.111,b4:96:91:13:6c:aa,1,1500,,,,
2773 ...
2774
Filip Pytlounf5383a42015-10-06 16:28:32 +02002775Usage
2776=====
2777
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002778Set MTU of the eth0 network interface to 1400:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002779
2780.. code-block:: bash
2781
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002782 ip link set dev eth0 mtu 1400
Filip Pytlounf5383a42015-10-06 16:28:32 +02002783
2784Read more
2785=========
2786
2787* https://www.archlinux.org/
2788* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu