blob: c315aeef8c702013169d1153da6032000e511204 [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
Dmitry Teselkin8e903562019-02-21 16:40:23 +030079Setting user defaults
80---------------------
81Default parameters that will be used by `useradd` command could be configured
82the following way:
83
84.. code-block:: yaml
85
86 linux:
87 system:
88 ...
89 defaults:
90 user:
91 shell: <SHELL>
92 gid: <GROUP>
93 home: <HOME>
94 inactdays: <INACTIVE>
95 expire: <EXPIRE>
96 skeleton: <SKEL>
97 create_mail_spool: <CREATE_MAIL_SPOOL>
98
99Other parameters that are used when creating user profile could be configured
100as well, acting as global defaults:
101
102.. code-block:: yaml
103
104 linux:
105 system:
106 ...
107 defaults:
108 user:
109 ...
110 maxdays: <PASS_MAX_DAYS>
111 mindays: <PASS_MIN_DAYS>
112 warndays: <PASS_WARN_AGE>
113
114.. note::
115
116 The three options above ('maxdays', 'mindays', 'warndays') could be
117 overriden in linux:system:login_defs using their 'real' names.
118 The reason they could be defined here is that it's quite logical to
119 have these parameters related to configuration of user account
120 behaviour in one place.
121
122
Dmitry Teselkin47e41f42018-09-27 14:10:09 +0300123Configure password expiration parameters
124----------------------------------------
125The following login.defs parameters can be overridden per-user:
126
127* PASS_MAX_DAYS
128* PASS_MIN_DAYS
129* PASS_WARN_DAYS
Dmitry Teselkin47e41f42018-09-27 14:10:09 +0300130
131.. code-block:: yaml
132
133 linux:
134 system:
135 ...
136 user:
137 jdoe:
138 name: 'jdoe'
139 enabled: true
140 ...
141 maxdays: <PASS_MAX_DAYS>
142 mindays: <PASS_MIN_DAYS>
Dmitry Teselkin8e903562019-02-21 16:40:23 +0300143 warndays: <PASS_WARN_AGE>
Dmitry Teselkin47e41f42018-09-27 14:10:09 +0300144
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100145Configure sudo for users and groups under ``/etc/sudoers.d/``.
146This ways ``linux.system.sudo`` pillar map to actual sudo attributes:
147
148.. code-block:: jinja
Aleš Komárek63572992017-04-11 13:16:44 +0200149
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100150 # simplified template:
151 Cmds_Alias {{ alias }}={{ commands }}
152 {{ user }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
153 %{{ group }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
154
155 # when rendered:
156 saltuser1 ALL=(ALL) NOPASSWD: ALL
157
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100158.. code-block:: yaml
Aleš Komárek63572992017-04-11 13:16:44 +0200159
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100160 linux:
161 system:
162 sudo:
163 enabled: true
Tomas Kammd8eb3002017-05-08 19:30:29 +0200164 aliases:
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100165 host:
166 LOCAL:
167 - localhost
168 PRODUCTION:
169 - db1
170 - db2
171 runas:
172 DBA:
173 - postgres
174 - mysql
175 SALT:
176 - root
177 command:
178 # Note: This is not 100% safe when ALL keyword is used, user still may modify configs and hide his actions.
179 # Best practice is to specify full list of commands user is allowed to run.
180 SUPPORT_RESTRICTED:
181 - /bin/vi /etc/sudoers*
182 - /bin/vim /etc/sudoers*
183 - /bin/nano /etc/sudoers*
184 - /bin/emacs /etc/sudoers*
185 - /bin/su - root
186 - /bin/su -
187 - /bin/su
188 - /usr/sbin/visudo
189 SUPPORT_SHELLS:
190 - /bin/sh
191 - /bin/ksh
192 - /bin/bash
193 - /bin/rbash
194 - /bin/dash
195 - /bin/zsh
196 - /bin/csh
197 - /bin/fish
198 - /bin/tcsh
199 - /usr/bin/login
200 - /usr/bin/su
201 - /usr/su
202 ALL_SALT_SAFE:
203 - /usr/bin/salt state*
204 - /usr/bin/salt service*
205 - /usr/bin/salt pillar*
206 - /usr/bin/salt grains*
207 - /usr/bin/salt saltutil*
208 - /usr/bin/salt-call state*
209 - /usr/bin/salt-call service*
210 - /usr/bin/salt-call pillar*
211 - /usr/bin/salt-call grains*
212 - /usr/bin/salt-call saltutil*
213 SALT_TRUSTED:
214 - /usr/bin/salt*
215 users:
216 # saltuser1 with default values: saltuser1 ALL=(ALL) NOPASSWD: ALL
217 saltuser1: {}
218 saltuser2:
219 hosts:
220 - LOCAL
221 # User Alias DBA
222 DBA:
223 hosts:
224 - ALL
225 commands:
226 - ALL_SALT_SAFE
227 groups:
228 db-ops:
229 hosts:
230 - ALL
231 - '!PRODUCTION'
232 runas:
233 - DBA
234 commands:
235 - /bin/cat *
236 - /bin/less *
237 - /bin/ls *
238 salt-ops:
239 hosts:
240 - 'ALL'
241 runas:
242 - SALT
243 commands:
244 - SUPPORT_SHELLS
245 salt-ops-2nd:
246 name: salt-ops
247 nopasswd: false
Jakub Josef7a9d9b92017-05-16 11:39:01 +0200248 setenv: true # Enable sudo -E option
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100249 runas:
250 - DBA
251 commands:
252 - ALL
253 - '!SUPPORT_SHELLS'
254 - '!SUPPORT_RESTRICTED'
255
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300256Linux with package, latest version:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200257
258.. code-block:: yaml
259
260 linux:
261 system:
262 ...
263 package:
264 package-name:
265 version: latest
266
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300267Linux with package from certail repo, version with no upgrades:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200268
269.. code-block:: yaml
270
271 linux:
272 system:
273 ...
274 package:
275 package-name:
276 version: 2132.323
277 repo: 'custom-repo'
278 hold: true
279
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300280Linux with package from certail repo, version with no GPG
281verification:
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 verify: false
293
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300294Linux with autoupdates (automatically install security package
295updates):
Bruno Binet69a9d8d2017-02-16 22:34:32 +0100296
297.. code-block:: yaml
298
299 linux:
300 system:
301 ...
302 autoupdates:
303 enabled: true
304 mail: root@localhost
305 mail_only_on_error: true
306 remove_unused_dependencies: false
307 automatic_reboot: true
308 automatic_reboot_time: "02:00"
309
Dmitry Teselkin0f084a02018-08-29 14:46:38 +0300310Managing cron tasks
311-------------------
312
313There are two data structures that are related to managing cron itself and
314cron tasks:
315
316.. code-block:: yaml
317
318 linux:
319 system:
320 cron:
321
322and
323
324.. code-block:: yaml
325
326 linux:
327 system:
328 job:
329
330`linux:system:cron` manages cron packages, services, and '/etc/cron.allow' file.
331
332'deny' files are managed the only way - we're ensuring they are absent, that's
333a requirement from CIS 5.1.8
334
335'cron' pillar structure is the following:
336
337.. code-block:: yaml
338
339 linux:
340 system:
341 cron:
342 enabled: true
343 pkgs: [ <cron packages> ]
344 services: [ <cron services> ]
345 user:
346 <username>:
347 enabled: true
348
349To add user to '/etc/cron.allow' use 'enabled' key as shown above.
350
351'/etc/cron.deny' is not managed as CIS 5.1.8 requires it was removed.
352
353A user would be ignored if any of the following is true:
354* user is disabled in `linux:system:user:<username>`
355* user is disabled in `linux:system:cron:user:<username>`
356
357`linux:system:job` manages individual cron tasks.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300358
359By default, it will use name as an identifier, unless identifier key is
Filip Pytloun91222222017-08-04 10:55:27 +0200360explicitly set or False (then it will use Salt's default behavior which is
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300361identifier same as command resulting in not being able to change it):
Filip Pytlounf5383a42015-10-06 16:28:32 +0200362
363.. code-block:: yaml
364
365 linux:
366 system:
367 ...
368 job:
369 cmd1:
370 command: '/cmd/to/run'
Filip Pytloun91222222017-08-04 10:55:27 +0200371 identifier: cmd1
Filip Pytlounf5383a42015-10-06 16:28:32 +0200372 enabled: true
373 user: 'root'
374 hour: 2
375 minute: 0
376
Dmitry Teselkin0f084a02018-08-29 14:46:38 +0300377Managing 'at' tasks
378-------------------
379
380Pillar for managing `at` tasks is similar to one for `cron` tasks:
381
382.. code-block:: yaml
383
384 linux:
385 system:
386 at:
387 enabled: true
388 pkgs: [ <at packages> ]
389 services: [ <at services> ]
390 user:
391 <username>:
392 enabled: true
393
394To add a user to '/etc/at.allow' use 'enabled' key as shown above.
395
396'/etc/at.deny' is not managed as CIS 5.1.8 requires it was removed.
397
398A user will be ignored if any of the following is true:
399* user is disabled in `linux:system:user:<username>`
400* user is disabled in `linux:system:at:user:<username>`
401
402
Filip Pytlound0a29e72015-11-30 15:23:34 +0100403Linux security limits (limit sensu user memory usage to max 1GB):
404
405.. code-block:: yaml
406
407 linux:
408 system:
409 ...
410 limit:
411 sensu:
412 enabled: true
413 domain: sensu
414 limits:
415 - type: hard
416 item: as
417 value: 1000000
418
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300419Enable autologin on ``tty1`` (may work only for Ubuntu 14.04):
Filip Pytloun7fee0542015-10-15 11:19:24 +0200420
421.. code-block:: yaml
422
423 linux:
424 system:
425 console:
426 tty1:
427 autologin: root
Filip Pytloun281d0202016-01-29 14:03:51 +0100428 # Enable serial console
429 ttyS0:
430 autologin: root
431 rate: 115200
432 term: xterm
Filip Pytloun7fee0542015-10-15 11:19:24 +0200433
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300434To disable set autologin to ``false``.
Filip Pytloun7fee0542015-10-15 11:19:24 +0200435
Filip Pytloun7731b852016-02-01 11:13:47 +0100436Set ``policy-rc.d`` on Debian-based systems. Action can be any available
437command in ``while true`` loop and ``case`` context.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300438Following will disallow dpkg to stop/start services for the Cassandra
439package automatically:
Filip Pytloun7731b852016-02-01 11:13:47 +0100440
441.. code-block:: yaml
442
443 linux:
444 system:
445 policyrcd:
446 - package: cassandra
447 action: exit 101
448 - package: '*'
449 action: switch
450
Filip Pytlounc49445a2016-04-04 14:23:20 +0200451Set system locales:
452
453.. code-block:: yaml
454
455 linux:
456 system:
457 locale:
458 en_US.UTF-8:
459 default: true
Filip Pytlounee1745f2016-04-04 17:39:41 +0200460 "cs_CZ.UTF-8 UTF-8":
Filip Pytlounc49445a2016-04-04 14:23:20 +0200461 enabled: true
462
Andrey Shestakove7cca052017-05-24 23:06:24 +0300463Systemd settings:
464
465.. code-block:: yaml
466
467 linux:
468 system:
469 ...
470 systemd:
471 system:
472 Manager:
473 DefaultLimitNOFILE: 307200
474 DefaultLimitNPROC: 307200
475 user:
476 Manager:
477 DefaultLimitCPU: 2
478 DefaultLimitNPROC: 4
479
Filip Pytloun8b2131e2017-11-08 13:29:03 +0100480Ensure presence of directory:
481
482.. code-block:: yaml
483
484 linux:
485 system:
486 directory:
487 /tmp/test:
488 user: root
489 group: root
490 mode: 700
491 makedirs: true
492
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300493Ensure presence of file by specifying its source:
Richard Felkl2e07d652018-01-19 10:19:06 +0100494
495.. code-block:: yaml
496
497 linux:
498 system:
499 file:
500 /tmp/test.txt:
501 source: http://example.com/test.txt
Richard Felklf40599a2018-02-06 22:56:41 +0100502 user: root #optional
503 group: root #optional
504 mode: 700 #optional
505 dir_mode: 700 #optional
506 encoding: utf-8 #optional
507 hash: <<hash>> or <<URI to hash>> #optional
508 makedirs: true #optional
509
510 linux:
511 system:
512 file:
513 test.txt:
514 name: /tmp/test.txt
515 source: http://example.com/test.txt
Richard Felkl2e07d652018-01-19 10:19:06 +0100516
Gabor Orosz35815c02018-09-07 17:31:05 +0200517 linux:
518 system:
519 file:
520 test2:
521 name: /tmp/test2.txt
522 source: http://example.com/test2.jinja
523 template: jinja
524
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300525Ensure presence of file by specifying its contents:
Richard Felkl2e07d652018-01-19 10:19:06 +0100526
527.. code-block:: yaml
528
529 linux:
530 system:
531 file:
532 /tmp/test.txt:
533 contents: |
534 line1
535 line2
Richard Felklf40599a2018-02-06 22:56:41 +0100536
537 linux:
538 system:
539 file:
540 /tmp/test.txt:
541 contents_pillar: linux:network:hostname
542
543 linux:
544 system:
545 file:
546 /tmp/test.txt:
547 contents_grains: motd
548
Ivan Berezovskiyf9301e12019-07-22 13:14:14 +0400549Ensure presence of file by specifying its secured source:
550
551.. code-block:: yaml
552
553 linux:
554 system:
555 file:
556 /tmp/test.txt:
557 secured_source:
558 protocol: http #optional
559 user: foo
560 password: bar
561 url: example.com/test.txt
562 secured_hash: #optional
563 url: example.com/test.txt.md5
564 user: root #optional
565 group: root #optional
566 mode: 700 #optional
567 dir_mode: 700 #optional
568 encoding: utf-8 #optional
569 makedirs: true #optional
570
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300571Ensure presence of file to be serialized through one of the
572serializer modules (see:
573https://docs.saltstack.com/en/latest/ref/serializers/all/index.html):
Bruno Binet9c2fe222018-06-08 16:57:32 +0200574
575.. code-block:: yaml
576
577 linux:
578 system:
579 file:
580 /tmp/test.json:
581 serialize: json
582 contents:
583 foo: 1
584 bar: 'bar'
585
agoriunovd7b19ce2019-02-18 11:37:32 +0200586Ensure presence of file to be decoded through file.decode module (see:
587https://docs.saltstack.com/en/latest/ref/states/all/salt.states.file.html#salt.states.file.decode):
588
589.. code-block:: yaml
590
591 linux:
592 system:
593 file:
594 /tmp/test4.txt:
595 decode: True
596 encoded_data: |
597 dGVzdDQK
598
Filip Pytloun281034a2016-01-04 18:06:22 +0100599Kernel
600~~~~~~
601
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300602Install always up to date LTS kernel and headers from Ubuntu Trusty:
Filip Pytloun281034a2016-01-04 18:06:22 +0100603
604.. code-block:: yaml
605
606 linux:
607 system:
608 kernel:
609 type: generic
610 lts: trusty
611 headers: true
612
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300613Load kernel modules and add them to ``/etc/modules``:
Tomáš Kukrálba35b212017-02-15 17:59:46 +0100614
615.. code-block:: yaml
616
617 linux:
618 system:
619 kernel:
620 modules:
621 - nf_conntrack
622 - tp_smapi
623 - 8021q
624
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300625Configure or blacklist kernel modules with additional options to
626``/etc/modprobe.d`` following example will add
627``/etc/modprobe.d/nf_conntrack.conf`` file with line
628``options nf_conntrack hashsize=262144``:
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300629
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300630'option' can be a mapping (with 'enabled' and 'value' keys) or a scalar.
631
632Example for 'scalar' option value:
633
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300634.. code-block:: yaml
635
636 linux:
637 system:
638 kernel:
639 module:
640 nf_conntrack:
641 option:
642 hashsize: 262144
643
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300644Example for 'mapping' option value:
645
646.. code-block:: yaml
647
648 linux:
649 system:
650 kernel:
651 module:
652 nf_conntrack:
653 option:
654 hashsize:
655 enabled: true
656 value: 262144
657
658NOTE: 'enabled' key is optional and is True by default.
659
660Blacklist a module:
661
662.. code-block:: yaml
663
664 linux:
665 system:
666 kernel:
667 module:
668 nf_conntrack:
669 blacklist: true
670
671A module can have a number of aliases, wildcards are allowed.
672Define an alias for a module:
673
674.. code-block:: yaml
675
676 linux:
677 system:
678 kernel:
679 module:
680 nf_conntrack:
681 alias:
682 nfct:
683 enabled: true
684 "nf_conn*":
685 enabled: true
686
687NOTE: 'enabled' key is mandatory as there are no other keys exist.
688
689Execute custom command instead of 'insmod' when inserting a module:
690
691.. code-block:: yaml
692
693 linux:
694 system:
695 kernel:
696 module:
697 nf_conntrack:
698 install:
699 enabled: true
700 command: /bin/true
701
702NOTE: 'enabled' key is optional and is True by default.
703
704Execute custom command instead of 'rmmod' when removing a module:
705
706.. code-block:: yaml
707
708 linux:
709 system:
710 kernel:
711 module:
712 nf_conntrack:
713 remove:
714 enabled: true
715 command: /bin/true
716
717NOTE: 'enabled' key is optional and is True by default.
718
719Define module dependencies:
720
721.. code-block:: yaml
722
723 linux:
724 system:
725 kernel:
726 module:
727 nf_conntrack:
728 softdep:
729 pre:
730 1:
731 enabled: true
732 value: a
733 2:
734 enabled: true
735 value: b
736 3:
737 enabled: true
738 value: c
739 post:
740 1:
741 enabled: true
742 value: x
743 2:
744 enabled: true
745 value: y
746 3:
747 enabled: true
748 value: z
749
750NOTE: 'enabled' key is optional and is True by default.
751
752
Filip Pytloun281034a2016-01-04 18:06:22 +0100753Install specific kernel version and ensure all other kernel packages are
754not present. Also install extra modules and headers for this kernel:
755
756.. code-block:: yaml
757
758 linux:
759 system:
760 kernel:
761 type: generic
762 extra: true
763 headers: true
764 version: 4.2.0-22
765
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300766Systcl kernel parameters:
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100767
768.. code-block:: yaml
769
770 linux:
771 system:
772 kernel:
773 sysctl:
774 net.ipv4.tcp_keepalive_intvl: 3
775 net.ipv4.tcp_keepalive_time: 30
776 net.ipv4.tcp_keepalive_probes: 8
777
Michael Polenchukebf55522018-01-25 13:22:39 +0400778Configure kernel boot options:
779
780.. code-block:: yaml
781
782 linux:
783 system:
784 kernel:
785 boot_options:
786 - elevator=deadline
787 - spectre_v2=off
788 - nopti
789
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100790CPU
791~~~
792
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300793Enable cpufreq governor for every cpu:
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100794
795.. code-block:: yaml
796
797 linux:
798 system:
799 cpu:
800 governor: performance
801
Nick Metzf04f5f32018-01-08 15:25:04 +0100802
Jiri Broulik303905d2018-01-11 14:12:48 +0100803CGROUPS
804~~~~~~~
805
806Setup linux cgroups:
807
808.. code-block:: yaml
809
810 linux:
811 system:
812 cgroup:
813 enabled: true
814 group:
815 ceph_group_1:
816 controller:
817 cpu:
818 shares:
819 value: 250
820 cpuacct:
821 usage:
822 value: 0
823 cpuset:
824 cpus:
825 value: 1,2,3
826 memory:
827 limit_in_bytes:
828 value: 2G
829 memsw.limit_in_bytes:
830 value: 3G
831 mapping:
832 subjects:
833 - '@ceph'
834 generic_group_1:
835 controller:
836 cpu:
837 shares:
838 value: 250
839 cpuacct:
840 usage:
841 value: 0
842 mapping:
843 subjects:
844 - '*:firefox'
845 - 'student:cp'
846
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300847Shared libraries
Nick Metzf04f5f32018-01-08 15:25:04 +0100848~~~~~~~~~~~~~~~~
849
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300850Set additional shared library to Linux system library path:
Nick Metzf04f5f32018-01-08 15:25:04 +0100851
852.. code-block:: yaml
853
854 linux:
855 system:
856 ld:
857 library:
858 java:
859 - /usr/lib/jvm/jre-openjdk/lib/amd64/server
860 - /opt/java/jre/lib/amd64/server
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200861
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200862Certificates
863~~~~~~~~~~~~
864
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300865Add certificate authority into system trusted CA bundle:
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200866
867.. code-block:: yaml
868
869 linux:
870 system:
871 ca_certificates:
872 mycert: |
873 -----BEGIN CERTIFICATE-----
874 MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
875 A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
876 cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
877 MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
878 BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
879 YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
880 ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
881 BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
882 I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
883 CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
884 lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
885 AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
886 -----END CERTIFICATE-----
887
Filip Pytloun361096c2017-08-23 10:57:20 +0200888Sysfs
889~~~~~
890
891Install sysfsutils and set sysfs attributes:
892
893.. code-block:: yaml
894
895 linux:
896 system:
897 sysfs:
898 scheduler:
899 block/sda/queue/scheduler: deadline
900 power:
901 mode:
902 power/state: 0660
903 owner:
904 power/state: "root:power"
905 devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
906
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200907Optional: You can also use list that will ensure order of items.
908
909.. code-block:: yaml
910
911 linux:
912 system:
913 sysfs:
914 scheduler:
915 block/sda/queue/scheduler: deadline
916 power:
917 - mode:
918 power/state: 0660
919 - owner:
920 power/state: "root:power"
921 - devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
922
Martin Polreich148e1b82018-09-13 15:54:25 +0200923Sysfs definition with disabled automatic write. Attributes are saved
924to configuration, but are not applied during the run.
925Thay will be applied automatically after the reboot.
926
927
928.. code-block:: yaml
929
930 linux:
931 system:
932 sysfs:
933 enable_apply: false
934 scheduler:
935 block/sda/queue/scheduler: deadline
936
937.. note:: The `enable_apply` parameter defaults to `True` if not defined.
938
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100939Huge Pages
940~~~~~~~~~~~~
941
942Huge Pages give a performance boost to applications that intensively deal
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300943with memory allocation/deallocation by decreasing memory fragmentation:
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100944
945.. code-block:: yaml
946
947 linux:
948 system:
949 kernel:
950 hugepages:
951 small:
952 size: 2M
953 count: 107520
954 mount_point: /mnt/hugepages_2MB
Michael Polenchukd9369fe2018-05-08 17:53:08 +0400955 mount: false/true # default is true (mount immediately) / false (just save in the fstab)
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100956 large:
957 default: true # default automatically mounted
958 size: 1G
959 count: 210
960 mount_point: /mnt/hugepages_1GB
961
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300962.. note:: Not recommended to use both pagesizes concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100963
Jakub Pavlik5398d872017-02-13 22:30:47 +0100964Intel SR-IOV
965~~~~~~~~~~~~
966
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300967PCI-SIG Single Root I/O Virtualization and Sharing (SR-IOV)
968specification defines a standardized mechanism to virtualize
969PCIe devices. The mechanism can virtualize a single PCIe
970Ethernet controller to appear as multiple PCIe devices:
Jakub Pavlik5398d872017-02-13 22:30:47 +0100971
972.. code-block:: yaml
973
974 linux:
975 system:
976 kernel:
977 sriov: True
978 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
979 rc:
980 local: |
981 #!/bin/sh -e
982 # Enable 7 VF on eth1
983 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
984 exit 0
985
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100986Isolate CPU options
987~~~~~~~~~~~~~~~~~~~
988
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300989Remove the specified CPUs, as defined by the cpu_number values, from
990the general kernel SMP balancing and scheduler algroithms. The only
991way to move a process onto or off an *isolated* CPU is via the CPU
992affinity syscalls. ``cpu_number begins`` at ``0``, so the
993maximum value is ``1`` less than the number of CPUs on the system.:
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100994
995.. code-block:: yaml
996
997 linux:
998 system:
999 kernel:
1000 isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
Jiri Broulikf8f55a22017-01-26 14:36:46 +01001001
Filip Pytlounf5383a42015-10-06 16:28:32 +02001002Repositories
1003~~~~~~~~~~~~
1004
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001005RedHat-based Linux with additional OpenStack repo:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001006
1007.. code-block:: yaml
1008
1009 linux:
1010 system:
1011 ...
1012 repo:
1013 rdo-icehouse:
1014 enabled: true
1015 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
1016 pgpcheck: 0
1017
1018Ensure system repository to use czech Debian mirror (``default: true``)
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001019Also pin it's packages with priority ``900``:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001020
1021.. code-block:: yaml
1022
1023 linux:
1024 system:
1025 repo:
1026 debian:
1027 default: true
1028 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
1029 # Import signing key from URL if needed
1030 key_url: "http://dummy.com/public.gpg"
1031 pin:
1032 - pin: 'origin "ftp.cz.debian.org"'
1033 priority: 900
1034 package: '*'
1035
azvyagintseva3a73d02018-12-06 14:49:58 +02001036Sometimes better to use one pining rule file, to decrease mistaken
1037ordering. You can use those option ``system:apt:preferences``, which would add opts into
1038``/etc/apt/preferences`` file:
1039
1040.. code-block:: yaml
1041
1042 parameters:
1043 linux:
1044 system:
1045 apt:
1046 preferences:
1047 enabled: true
1048 rules:
1049 100:
1050 enabled: true
1051 name: 'some origin pin'
1052 pin: 'release o=Debian'
1053 priority: 1100
1054 package: '*'
1055
1056
azvyagintsev4494a472018-09-14 19:19:23 +03001057If you need to add multiple pin rules for one repo, please use new,ordered definition format
1058('pinning' definition will be in priotity to use):
1059
1060.. code-block:: yaml
1061
1062 linux:
1063 system:
1064 repo:
1065 mcp_saltstack:
1066 source: "deb [arch=amd64] http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/ xenial main"
1067 architectures: amd64
1068 clean_file: true
1069 pinning:
1070 10:
1071 enabled: true
1072 pin: 'release o=SaltStack'
1073 priority: 50
1074 package: 'libsodium18'
1075 20:
1076 enabled: true
1077 pin: 'release o=SaltStack'
1078 priority: 1100
1079 package: '*'
1080
1081
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001082.. note:: For old Ubuntu releases (<xenial)
azvyagintsevff089d22018-07-27 16:52:34 +02001083 extra packages for apt transport, like ``apt-transport-https``
1084 may be required to be installed manually.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001085 (Chicken-eggs issue: we need to install packages to
azvyagintsevff089d22018-07-27 16:52:34 +02001086 reach repo from where they should be installed)
1087 Otherwise, you still can try 'fortune' and install prereq.packages before
1088 any repo configuration, using list of requires in map.jinja.
1089
1090
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001091Disabling any prerequisite packages installation:
1092
azvyagintsevff089d22018-07-27 16:52:34 +02001093You can simply drop any package pre-installation (before system.linux.repo
1094will be processed) via cluster lvl:
1095
1096.. code-block:: yaml
1097
1098 linux:
1099 system:
1100 pkgs: ~
1101
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001102Package manager proxy global setup:
Petr Michalec10462bb2017-03-23 19:18:08 +01001103
1104.. code-block:: yaml
1105
1106 linux:
1107 system:
1108 ...
1109 repo:
1110 apt-mk:
1111 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1112 ...
1113 proxy:
1114 pkg:
1115 enabled: true
1116 ftp: ftp://ftp-proxy-for-apt.host.local:2121
1117 ...
1118 # NOTE: Global defaults for any other componet that configure proxy on the system.
1119 # If your environment has just one simple proxy, set it on linux:system:proxy.
1120 #
1121 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
1122 # as for https and http
1123 ftp: ftp://proxy.host.local:2121
1124 http: http://proxy.host.local:3142
1125 https: https://proxy.host.local:3143
1126
1127Package manager proxy setup per repository:
1128
1129.. code-block:: yaml
1130
1131 linux:
1132 system:
1133 ...
1134 repo:
1135 debian:
1136 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1137 ...
1138 apt-mk:
1139 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1140 # per repository proxy
1141 proxy:
1142 enabled: true
1143 http: http://maas-01:8080
1144 https: http://maas-01:8080
1145 ...
1146 proxy:
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001147 # package manager fallback defaults
Petr Michalec10462bb2017-03-23 19:18:08 +01001148 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
1149 pkg:
1150 enabled: true
1151 ftp: ftp://proxy.host.local:2121
1152 #http: http://proxy.host.local:3142
1153 #https: https://proxy.host.local:3143
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001154 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001155 # global system fallback system defaults
1156 ftp: ftp://proxy.host.local:2121
1157 http: http://proxy.host.local:3142
1158 https: https://proxy.host.local:3143
1159
Ivan Berezovskiy6335da52019-06-25 20:15:51 +04001160
1161Add secured apt repository:
1162
1163.. code-block:: yaml
1164
1165 linux:
1166 system:
1167 ...
1168 repo:
1169 test:
1170 secure: true
1171 url: example.org/ubuntu
1172 arch: deb
1173 protocol: http
1174 user: foo
1175 password: bar
1176 distribution: stable
1177 component: main
1178
1179Add multiply secured apt repositories with same credentials:
1180
1181.. code-block:: yaml
1182
1183 linux:
1184 system:
1185 ...
1186 common_repo_secured:
1187 arch: deb
1188 protocol: http
1189 user: foo
1190 password: bar
1191 distribution: stable
1192 component: main
1193 repo:
1194 test1:
1195 secure: true
1196 url: example1.org/ubuntu
1197 test2:
1198 secure: true
1199 url: example2.org/ubuntu
1200
Jiri Broulik34a29b42017-04-25 14:42:54 +02001201Remove all repositories:
1202
1203.. code-block:: yaml
1204
1205 linux:
1206 system:
1207 purge_repos: true
1208
azvyagintsevff089d22018-07-27 16:52:34 +02001209Refresh repositories metada, after configuration:
1210
1211.. code-block:: yaml
1212
1213 linux:
1214 system:
1215 refresh_repos_meta: true
1216
Filip Pytlounc512e6c2017-11-22 14:28:10 +01001217Setup custom apt config options:
1218
1219.. code-block:: yaml
1220
1221 linux:
1222 system:
1223 apt:
1224 config:
1225 compression-workaround:
1226 "Acquire::CompressionTypes::Order": "gz"
1227 docker-clean:
1228 "DPkg::Post-Invoke":
1229 - "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"
1230 "APT::Update::Post-Invoke":
1231 - "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 +02001232
Petr Michalec10462bb2017-03-23 19:18:08 +01001233RC
1234~~
1235
Jakub Pavlik78859382016-01-21 11:26:39 +01001236rc.local example
1237
1238.. code-block:: yaml
1239
1240 linux:
1241 system:
1242 rc:
1243 local: |
1244 #!/bin/sh -e
1245 #
1246 # rc.local
1247 #
1248 # This script is executed at the end of each multiuser runlevel.
1249 # Make sure that the script will "exit 0" on success or any other
1250 # value on error.
1251 #
1252 # In order to enable or disable this script just change the execution
1253 # bits.
1254 #
1255 # By default this script does nothing.
1256 exit 0
1257
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001258Prompt
1259~~~~~~
1260
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001261Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``.
1262Every user can have different prompt:
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001263
1264.. code-block:: yaml
1265
1266 linux:
1267 system:
1268 prompt:
1269 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\\]
1270 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
1271
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001272On Debian systems, to set prompt system-wide, it's necessary to
1273remove setting PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc``,
1274which comes from ``/etc/skel/.bashrc``. This formula will do
1275this automatically, but will not touch existing user's
1276``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +01001277
Filip Pytlouneef11c12016-03-25 11:00:23 +01001278Bash
1279~~~~
1280
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001281Fix bash configuration to preserve history across sessions
1282like ZSH does by default:
Filip Pytlouneef11c12016-03-25 11:00:23 +01001283
1284.. code-block:: yaml
1285
1286 linux:
1287 system:
1288 bash:
1289 preserve_history: true
1290
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001291Login banner message
1292~~~~~~~~~~~~~~~~~~~~
1293
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001294``/etc/issue`` is a text file which contains a message or system
1295identification to be printed before the login prompt. It may contain
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001296various @char and \char sequences, if supported by the getty-type
1297program employed on the system.
1298
1299Setting logon banner message is easy:
1300
1301.. code-block:: yaml
1302
1303 liunx:
1304 system:
1305 banner:
1306 enabled: true
1307 contents: |
1308 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1309
1310 You must have explicit, authorized permission to access or configure this
1311 device. Unauthorized attempts and actions to access or use this system may
1312 result in civil and/or criminal penalties.
1313 All activities performed on this system are logged and monitored.
1314
Filip Pytloune874dfb2016-01-22 16:57:34 +01001315Message of the day
1316~~~~~~~~~~~~~~~~~~
1317
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001318``pam_motd`` from package ``libpam-modules`` is used for dynamic
1319messages of the day. Setting custom ``motd`` will clean up existing ones.
Filip Pytloune874dfb2016-01-22 16:57:34 +01001320
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001321Setting static ``motd`` will replace existing ``/etc/motd`` and remove
1322scripts from ``/etc/update-motd.d``.
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001323
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001324Setting static ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001325
1326.. code-block:: yaml
1327
1328 linux:
1329 system:
1330 motd: |
1331 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1332
1333 You must have explicit, authorized permission to access or configure this
1334 device. Unauthorized attempts and actions to access or use this system may
1335 result in civil and/or criminal penalties.
1336 All activities performed on this system are logged and monitored.
1337
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001338Setting dynamic ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001339
Filip Pytloune874dfb2016-01-22 16:57:34 +01001340.. code-block:: yaml
1341
1342 linux:
1343 system:
1344 motd:
1345 - release: |
1346 #!/bin/sh
1347 [ -r /etc/lsb-release ] && . /etc/lsb-release
1348
1349 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
1350 # Fall back to using the very slow lsb_release utility
1351 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
1352 fi
1353
1354 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
1355 - warning: |
1356 #!/bin/sh
1357 printf "This is [company name] network.\n"
1358 printf "Unauthorized access strictly prohibited.\n"
1359
Marek Celoud713e9072017-05-18 15:20:25 +02001360Services
1361~~~~~~~~
1362
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001363Stop and disable the ``linux`` service:
Marek Celoud713e9072017-05-18 15:20:25 +02001364
1365.. code-block:: yaml
1366
1367 linux:
1368 system:
1369 service:
1370 apt-daily.timer:
1371 status: dead
1372
Dzmitry Stremkouski70d09782018-11-30 16:04:59 +01001373Override systemd service unit:
1374
1375.. code-block:: yaml
1376
1377 parameters:
1378
1379 linux:
1380 system:
1381 service:
1382 tgt:
1383 name: tgt
1384 status: running
1385 enabled: True
1386 override:
1387 50:
1388 target: tgt.service.d
1389 name: bind
1390 content: |
1391 [Service]
1392 ExecStart=
1393 ExecStart=/usr/sbin/tgtd -f --iscsi portal=${_param:single_address}:3260
1394
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001395Possible statuses are ``dead`` (disable service by default), ``running``
1396(enable service by default), ``enabled``, ``disabled``:
Marek Celoud713e9072017-05-18 15:20:25 +02001397
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001398Linux with the ``atop`` service:
Serhiy Ovsianikov67bd56a2017-08-11 15:56:01 +03001399
1400.. code-block:: yaml
1401
1402 linux:
1403 system:
1404 atop:
1405 enabled: true
1406 interval: 20
1407 logpath: "/var/log/atop"
1408 outfile: "/var/log/atop/daily.log"
1409
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001410Linux with the ``mcelog`` service:
Oleksii Chupryn144432b2018-05-22 10:34:48 +03001411
1412.. code-block:: yaml
1413
1414 linux:
1415 system:
1416 mcelog:
1417 enabled: true
1418 logging:
1419 syslog: true
1420 syslog_error: true
1421
Filip Pytloun2f70b492016-02-19 15:55:25 +01001422RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +01001423^^^^^^^^^^^^^
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001424Currently, ``update-motd`` is not available
1425for RHEL. So there is no native support for dynamic ``motd``.
1426You can still set a static one, with a different pillar structure:
Filip Pytloun2f70b492016-02-19 15:55:25 +01001427
1428.. code-block:: yaml
1429
1430 linux:
1431 system:
1432 motd: |
1433 This is [company name] network.
1434 Unauthorized access strictly prohibited.
1435
Filip Pytloun8296bb92016-02-19 18:42:09 +01001436Haveged
1437~~~~~~~
1438
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001439If you are running headless server and are low on entropy,
1440you may set up Haveged:
Filip Pytloun8296bb92016-02-19 18:42:09 +01001441
1442.. code-block:: yaml
1443
1444 linux:
1445 system:
1446 haveged:
1447 enabled: true
1448
Filip Pytlounf5383a42015-10-06 16:28:32 +02001449Linux network
1450-------------
1451
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001452Linux with network manager:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001453
1454.. code-block:: yaml
1455
1456 linux:
1457 network:
1458 enabled: true
1459 network_manager: true
1460
Dzmitry Stremkouski00cdbe62018-10-31 16:41:54 +01001461Execute linux.network.interface state without ifupdown activity:
1462
1463.. code-block:: bash
1464
1465 salt-call linux.network.interface pillar='{"linux":{"network":{"noifupdown":True}}}'
1466
1467
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001468Linux with default static network interfaces, default gateway
1469interface and DNS servers:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001470
1471.. code-block:: yaml
1472
1473 linux:
1474 network:
1475 enabled: true
1476 interface:
1477 eth0:
1478 enabled: true
1479 type: eth
1480 address: 192.168.0.102
1481 netmask: 255.255.255.0
1482 gateway: 192.168.0.1
1483 name_servers:
1484 - 8.8.8.8
1485 - 8.8.4.4
1486 mtu: 1500
1487
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001488Linux with bonded interfaces and disabled ``NetworkManager``:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001489
1490.. code-block:: yaml
1491
1492 linux:
1493 network:
1494 enabled: true
1495 interface:
1496 eth0:
1497 type: eth
1498 ...
1499 eth1:
1500 type: eth
1501 ...
1502 bond0:
1503 enabled: true
1504 type: bond
1505 address: 192.168.0.102
1506 netmask: 255.255.255.0
1507 mtu: 1500
1508 use_in:
1509 - interface: ${linux:interface:eth0}
1510 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +01001511 network_manager:
1512 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001513
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001514Linux with VLAN ``interface_params``:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001515
1516.. code-block:: yaml
1517
1518 linux:
1519 network:
1520 enabled: true
1521 interface:
1522 vlan69:
1523 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +01001524 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001525 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001526
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001527Linux with wireless interface parameters:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001528
1529.. code-block:: yaml
1530
1531 linux:
1532 network:
1533 enabled: true
1534 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001535 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001536 interface:
1537 wlan0:
1538 type: eth
1539 wireless:
1540 essid: example
1541 key: example_key
1542 security: wpa
1543 priority: 1
1544
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001545Linux networks with routes defined:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001546
1547.. code-block:: yaml
1548
1549 linux:
1550 network:
1551 enabled: true
1552 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001553 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001554 interface:
1555 eth0:
1556 type: eth
1557 route:
1558 default:
1559 address: 192.168.0.123
1560 netmask: 255.255.255.0
1561 gateway: 192.168.0.1
1562
ivcc4730b12019-01-23 07:56:53 +03001563Linux networks with implicit routes definition:
1564
1565- on node 1:
1566
1567.. code-block:: yaml
1568
1569 linux:
1570 network:
1571 enabled: true
1572 router:
1573 ctl:
1574 # router that connects 10.0.1.0/24 and 10.0.2.0/24
1575 addresses:
1576 - 10.0.1.1/24
1577 - 10.0.2.1/24
1578 test:
1579 addresses:
1580 - 10.0.1.2/24
1581 networks:
1582 - 10.100.0.0/16
1583 interface:
1584 ctl:
1585 name: eth0
1586 address: 10.0.1.101
1587 netmask: 255.255.255.0
1588
1589- on node2:
1590
1591.. code-block:: yaml
1592
1593 linux:
1594 network:
1595 enabled: true
1596 router:
1597 ctl:
1598 # equivalent of node1's ctl router with 'implicit_routes = false'
1599 options:
1600 implicit_routes: false
1601 addresses:
1602 - 10.0.1.1/24
1603 - 10.0.2.1/24
1604 networks:
1605 - 10.0.1.0/24
1606 - 10.0.2.0/24
1607 interface:
1608 ctl:
1609 name: eth0
1610 address: 10.0.2.101
1611 netmask: 255.255.255.0
1612
1613
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001614Native Linux Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001615
1616.. code-block:: yaml
1617
1618 linux:
1619 network:
1620 interface:
1621 eth1:
1622 enabled: true
1623 type: eth
1624 proto: manual
1625 up_cmds:
1626 - ip address add 0/0 dev $IFACE
1627 - ip link set $IFACE up
1628 down_cmds:
1629 - ip link set $IFACE down
1630 br-ex:
1631 enabled: true
1632 type: bridge
1633 address: ${linux:network:host:public_local:address}
1634 netmask: 255.255.255.0
1635 use_interfaces:
1636 - eth1
1637
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001638Open vSwitch Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001639
1640.. code-block:: yaml
1641
1642 linux:
1643 network:
1644 bridge: openvswitch
1645 interface:
1646 eth1:
1647 enabled: true
1648 type: eth
1649 proto: manual
1650 up_cmds:
1651 - ip address add 0/0 dev $IFACE
1652 - ip link set $IFACE up
1653 down_cmds:
1654 - ip link set $IFACE down
1655 br-ex:
1656 enabled: true
1657 type: bridge
1658 address: ${linux:network:host:public_local:address}
1659 netmask: 255.255.255.0
1660 use_interfaces:
1661 - eth1
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001662 br-prv:
1663 enabled: true
1664 type: ovs_bridge
1665 mtu: 65000
1666 br-ens7:
1667 enabled: true
1668 name: br-ens7
1669 type: ovs_bridge
1670 proto: manual
1671 mtu: 9000
1672 use_interfaces:
1673 - ens7
1674 patch-br-ens7-br-prv:
1675 enabled: true
1676 name: ens7-prv
1677 ovs_type: ovs_port
1678 type: ovs_port
1679 bridge: br-ens7
1680 port_type: patch
1681 peer: prv-ens7
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001682 tag: 109 # [] to unset a tag
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001683 mtu: 65000
1684 patch-br-prv-br-ens7:
1685 enabled: true
1686 name: prv-ens7
1687 bridge: br-prv
1688 ovs_type: ovs_port
1689 type: ovs_port
1690 port_type: patch
1691 peer: ens7-prv
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001692 tag: 109
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001693 mtu: 65000
1694 ens7:
1695 enabled: true
1696 name: ens7
1697 proto: manual
1698 ovs_port_type: OVSPort
1699 type: ovs_port
1700 ovs_bridge: br-ens7
1701 bridge: br-ens7
Filip Pytlounf5383a42015-10-06 16:28:32 +02001702
Petr Jediný8f8ae542017-07-13 16:19:12 +02001703Debian manual proto interfaces
1704
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001705When you are changing interface proto from static in up state
1706to manual, you may need to flush ip addresses. For example,
1707if you want to use the interface and the ip on the bridge.
1708This can be done by setting the ``ipflush_onchange`` to true.
Petr Jediný8f8ae542017-07-13 16:19:12 +02001709
1710.. code-block:: yaml
1711
1712 linux:
1713 network:
1714 interface:
1715 eth1:
1716 enabled: true
1717 type: eth
1718 proto: manual
1719 mtu: 9100
1720 ipflush_onchange: true
1721
Jiri Broulik1a191e32018-01-15 15:54:21 +01001722Debian static proto interfaces
1723
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001724When you are changing interface proto from dhcp in up state to
1725static, you may need to flush ip addresses and restart interface
1726to assign ip address from a managed file. For example, if you wantto
1727use the interface and the ip on the bridge. This can be done by
1728setting the ``ipflush_onchange`` with combination ``restart_on_ipflush``
1729param set to true.
Jiri Broulik1a191e32018-01-15 15:54:21 +01001730
1731.. code-block:: yaml
1732
1733 linux:
1734 network:
1735 interface:
1736 eth1:
1737 enabled: true
1738 type: eth
1739 proto: static
1740 address: 10.1.0.22
1741 netmask: 255.255.255.0
1742 ipflush_onchange: true
1743 restart_on_ipflush: true
Petr Jediný8f8ae542017-07-13 16:19:12 +02001744
Petr Jedinýd577cb52017-06-28 20:17:49 +02001745Concatinating and removing interface files
1746
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001747Debian based distributions have ``/etc/network/interfaces.d/``
1748directory, where you can store configuration of network
1749interfaces in separate files. You can concatinate the files
1750to the defined destination when needed, this operation removes
1751the file from the ``/etc/network/interfaces.d/``. If you just need
1752to remove iface files, you can use the ``remove_iface_files`` key.
Petr Jedinýd577cb52017-06-28 20:17:49 +02001753
1754.. code-block:: yaml
1755
1756 linux:
1757 network:
1758 concat_iface_files:
1759 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
1760 dst: '/etc/network/interfaces'
1761 remove_iface_files:
1762 - '/etc/network/interfaces.d/90-custom.cfg'
1763
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001764Configure DHCP client
Petr Jedinýd577cb52017-06-28 20:17:49 +02001765
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001766None of the keys is mandatory, include only those you really need.
1767For full list of available options under send, supersede, prepend,
1768append refer to dhcp-options(5).
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001769
1770.. code-block:: yaml
1771
1772 linux:
1773 network:
1774 dhclient:
1775 enabled: true
1776 backoff_cutoff: 15
1777 initial_interval: 10
1778 reboot: 10
1779 retry: 60
1780 select_timeout: 0
1781 timeout: 120
1782 send:
1783 - option: host-name
1784 declaration: "= gethostname()"
1785 supersede:
1786 - option: host-name
1787 declaration: "spaceship"
1788 - option: domain-name
1789 declaration: "domain.home"
1790 #- option: arp-cache-timeout
1791 # declaration: 20
1792 prepend:
1793 - option: domain-name-servers
1794 declaration:
1795 - 8.8.8.8
1796 - 8.8.4.4
1797 - option: domain-search
1798 declaration:
1799 - example.com
1800 - eng.example.com
1801 #append:
1802 #- option: domain-name-servers
1803 # declaration: 127.0.0.1
1804 # ip or subnet to reject dhcp offer from
1805 reject:
1806 - 192.33.137.209
1807 - 10.0.2.0/24
1808 request:
1809 - subnet-mask
1810 - broadcast-address
1811 - time-offset
1812 - routers
1813 - domain-name
1814 - domain-name-servers
1815 - domain-search
1816 - host-name
1817 - dhcp6.name-servers
1818 - dhcp6.domain-search
1819 - dhcp6.fqdn
1820 - dhcp6.sntp-servers
1821 - netbios-name-servers
1822 - netbios-scope
1823 - interface-mtu
1824 - rfc3442-classless-static-routes
1825 - ntp-servers
1826 require:
1827 - subnet-mask
1828 - domain-name-servers
1829 # if per interface configuration required add below
1830 interface:
1831 ens2:
1832 initial_interval: 11
1833 reject:
1834 - 192.33.137.210
1835 ens3:
1836 initial_interval: 12
1837 reject:
1838 - 192.33.137.211
1839
Petr Michaleceb14b552017-06-01 10:27:05 +02001840Linux network systemd settings:
1841
1842.. code-block:: yaml
1843
1844 linux:
1845 network:
1846 ...
1847 systemd:
1848 link:
1849 10-iface-dmz:
1850 Match:
1851 MACAddress: c8:5b:67:fa:1a:af
1852 OriginalName: eth0
1853 Link:
1854 Name: dmz0
1855 netdev:
1856 20-bridge-dmz:
1857 match:
1858 name: dmz0
1859 network:
1860 mescription: bridge
1861 bridge: br-dmz0
1862 network:
1863 # works with lowercase, keys are by default capitalized
1864 40-dhcp:
1865 match:
1866 name: '*'
1867 network:
1868 DHCP: yes
1869
Petr Michalec10462bb2017-03-23 19:18:08 +01001870Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +01001871
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001872Use ``/etc/environment`` for static system wide variable assignment
1873after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001874
1875.. code-block:: yaml
1876
1877 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +01001878 system:
1879 env:
1880 BOB_VARIABLE: Alice
1881 ...
1882 BOB_PATH:
1883 - /srv/alice/bin
1884 - /srv/bob/bin
1885 ...
1886 ftp_proxy: none
1887 http_proxy: http://global-http-proxy.host.local:8080
1888 https_proxy: ${linux:system:proxy:https}
1889 no_proxy:
1890 - 192.168.0.80
1891 - 192.168.1.80
1892 - .domain.com
1893 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001894 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001895 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001896 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001897 ftp: ftp://proxy.host.local:2121
1898 http: http://proxy.host.local:3142
1899 https: https://proxy.host.local:3143
1900 noproxy:
1901 - .domain.com
1902 - .local
1903
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001904Configure the ``profile.d`` scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001905
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001906The ``profile.d`` scripts are being sourced during ``.sh`` execution
1907and support variable expansion in opposite to /etc/environment global
1908settings in ``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001909
1910.. code-block:: yaml
1911
1912 linux:
1913 system:
1914 profile:
1915 locales: |
1916 export LANG=C
1917 export LC_ALL=C
1918 ...
1919 vi_flavors.sh: |
1920 export PAGER=view
1921 export EDITOR=vim
1922 alias vi=vim
1923 shell_locales.sh: |
1924 export LANG=en_US
1925 export LC_ALL=en_US.UTF-8
1926 shell_proxies.sh: |
1927 export FTP_PROXY=ftp://127.0.3.3:2121
1928 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001929
Dmitry Teselkina0d31d12018-09-04 14:43:09 +03001930
1931Configure login.defs parameters
1932-------------------------------
1933
1934.. code-block:: yaml
1935
1936 linux:
1937 system:
1938 login_defs:
1939 <opt_name>:
1940 enabled: true
1941 value: <opt_value>
1942
1943<opt_name> is a configurational option defined in 'man login.defs'.
1944<opt_name> is case sensitive, should be UPPERCASE only!
1945
1946
Filip Pytlounf5383a42015-10-06 16:28:32 +02001947Linux with hosts
1948
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001949Parameter ``purge_hosts`` will enforce whole ``/etc/hosts file``,
1950removing entries that are not defined in model except defaults
1951for both IPv4 and IPv6 localhost and hostname as well as FQDN.
Ales Komarek417e8c52017-08-25 15:10:29 +02001952
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001953We recommend using this option to verify that ``/etc/hosts``
1954is always in a clean state. However it is not enabled by default
1955for security reasons.
Filip Pytloun86506fe2017-01-26 14:36:16 +01001956
Filip Pytlounf5383a42015-10-06 16:28:32 +02001957.. code-block:: yaml
1958
1959 linux:
1960 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001961 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001962 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001963 # No need to define this one if purge_hosts is true
1964 hostname:
1965 address: 127.0.1.1
1966 names:
1967 - ${linux:network:fqdn}
1968 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001969 node1:
1970 address: 192.168.10.200
1971 names:
1972 - node2.domain.com
1973 - service2.domain.com
1974 node2:
1975 address: 192.168.10.201
1976 names:
1977 - node2.domain.com
1978 - service2.domain.com
1979
Ales Komarek417e8c52017-08-25 15:10:29 +02001980Linux with hosts collected from mine
1981
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001982All DNS records defined within infrastrucuture
1983are passed to the local hosts records or any DNS server. Only
1984hosts with the ``grain`` parameter set to ``true`` will be propagated
1985to the mine.
Ales Komarek417e8c52017-08-25 15:10:29 +02001986
1987.. code-block:: yaml
1988
1989 linux:
1990 network:
1991 purge_hosts: true
1992 mine_dns_records: true
1993 host:
1994 node1:
1995 address: 192.168.10.200
1996 grain: true
1997 names:
1998 - node2.domain.com
1999 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01002000
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04002001Set up ``resolvconf's basic resolver info``, e.g. nameservers, search/domain and options:
Filip Pytlounde9bea52016-01-11 15:39:10 +01002002
2003.. code-block:: yaml
2004
2005 linux:
2006 network:
2007 resolv:
2008 dns:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04002009 - 8.8.4.4
2010 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01002011 domain: my.example.com
2012 search:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04002013 - my.example.com
2014 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01002015 options:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04002016 - ndots:5
2017 - timeout:2
2018 - attempts:2
Filip Pytlounde9bea52016-01-11 15:39:10 +01002019
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002020Set up custom TX queue length for tap interfaces:
Andrii Petrenko735761d2017-03-21 17:17:35 -07002021
2022.. code-block:: yaml
2023
2024 linux:
2025 network:
2026 tap_custom_txqueuelen: 10000
2027
Michael Polenchuk6e3042b2019-04-22 15:20:03 +04002028Auto repair/re-attach libvirt's vnet interfaces:
2029
2030.. code-block:: yaml
2031
2032 linux:
2033 network:
2034 libvirt_vnet_repair: true
2035
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002036DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002037
2038**DPDK OVS NIC**
2039
2040.. code-block:: yaml
2041
2042 linux:
2043 network:
2044 bridge: openvswitch
2045 dpdk:
2046 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04002047 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002048 openvswitch:
2049 pmd_cpu_mask: "0x6"
2050 dpdk_socket_mem: "1024,1024"
2051 dpdk_lcore_mask: "0x400"
2052 memory_channels: 2
2053 interface:
2054 dpkd0:
2055 name: ${_param:dpdk_nic}
2056 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002057 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002058 enabled: true
2059 type: dpdk_ovs_port
2060 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002061 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002062 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01002063 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002064 br-prv:
2065 enabled: true
2066 type: dpdk_ovs_bridge
Michael Polenchukd3378db2018-12-29 16:46:50 +04002067 br-floating:
2068 enabled: true
2069 type: ovs_bridge
2070 name_servers:
2071 - 1.1.1.1
2072 - 9.9.9.9
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002073
2074**DPDK OVS Bond**
2075
2076.. code-block:: yaml
2077
2078 linux:
2079 network:
2080 bridge: openvswitch
2081 dpdk:
2082 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04002083 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002084 openvswitch:
2085 pmd_cpu_mask: "0x6"
2086 dpdk_socket_mem: "1024,1024"
2087 dpdk_lcore_mask: "0x400"
2088 memory_channels: 2
2089 interface:
2090 dpdk_second_nic:
2091 name: ${_param:primary_second_nic}
2092 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002093 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002094 bond: dpdkbond0
2095 enabled: true
2096 type: dpdk_ovs_port
2097 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002098 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002099 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002100 dpdk_first_nic:
2101 name: ${_param:primary_first_nic}
2102 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002103 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002104 bond: dpdkbond0
2105 enabled: true
2106 type: dpdk_ovs_port
2107 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002108 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002109 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002110 dpdkbond0:
2111 enabled: true
2112 bridge: br-prv
2113 type: dpdk_ovs_bond
2114 mode: active-backup
2115 br-prv:
2116 enabled: true
2117 type: dpdk_ovs_bridge
2118
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01002119**DPDK OVS LACP Bond with vlan tag**
2120
2121.. code-block:: yaml
2122
2123 linux:
2124 network:
2125 bridge: openvswitch
2126 dpdk:
2127 enabled: true
2128 driver: uio
2129 openvswitch:
2130 pmd_cpu_mask: "0x6"
2131 dpdk_socket_mem: "1024,1024"
2132 dpdk_lcore_mask: "0x400"
2133 memory_channels: "2"
2134 interface:
2135 eth3:
2136 enabled: true
2137 type: eth
2138 proto: manual
2139 name: ${_param:tenant_first_nic}
2140 eth4:
2141 enabled: true
2142 type: eth
2143 proto: manual
2144 name: ${_param:tenant_second_nic}
2145 dpdk0:
2146 name: ${_param:tenant_first_nic}
2147 pci: "0000:81:00.0"
2148 driver: igb_uio
2149 bond: bond1
2150 enabled: true
2151 type: dpdk_ovs_port
2152 n_rxq: 2
2153 dpdk1:
2154 name: ${_param:tenant_second_nic}
2155 pci: "0000:81:00.1"
2156 driver: igb_uio
2157 bond: bond1
2158 enabled: true
2159 type: dpdk_ovs_port
2160 n_rxq: 2
2161 bond1:
2162 enabled: true
2163 bridge: br-prv
2164 type: dpdk_ovs_bond
2165 mode: balance-slb
2166 br-prv:
2167 enabled: true
2168 type: dpdk_ovs_bridge
2169 tag: ${_param:tenant_vlan}
2170 address: ${_param:tenant_address}
2171 netmask: ${_param:tenant_network_netmask}
2172
Jakub Pavlikaa759062017-03-13 15:57:26 +01002173**DPDK OVS bridge for VXLAN**
2174
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002175If VXLAN is used as tenant segmentation, IP address must
2176be set on ``br-prv``.
Jakub Pavlikaa759062017-03-13 15:57:26 +01002177
2178.. code-block:: yaml
2179
2180 linux:
2181 network:
2182 ...
2183 interface:
2184 br-prv:
2185 enabled: true
2186 type: dpdk_ovs_bridge
2187 address: 192.168.50.0
2188 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04002189 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01002190 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002191
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02002192**DPDK OVS bridge with Linux network interface**
2193
2194.. code-block:: yaml
2195
2196 linux:
2197 network:
2198 ...
2199 interface:
2200 eth0:
2201 type: eth
2202 ovs_bridge: br-prv
2203 ...
2204 br-prv:
2205 enabled: true
2206 type: dpdk_ovs_bridge
2207 ...
2208
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002209Linux storage
2210-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02002211
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002212Linux with mounted Samba:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002213
2214.. code-block:: yaml
2215
2216 linux:
2217 storage:
2218 enabled: true
2219 mount:
2220 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01002221 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02002222 - path: /media/myuser/public/
2223 - device: //192.168.0.1/storage
2224 - file_system: cifs
2225 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
2226
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002227NFS mount:
Jiri Broulikb017f932017-03-31 13:55:36 +02002228
2229.. code-block:: yaml
2230
2231 linux:
2232 storage:
2233 enabled: true
2234 mount:
2235 nfs_glance:
2236 enabled: true
2237 path: /var/lib/glance/images
2238 device: 172.16.10.110:/var/nfs/glance
2239 file_system: nfs
2240 opts: rw,sync
2241
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002242File swap configuration:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002243
2244.. code-block:: yaml
2245
2246 linux:
2247 storage:
2248 enabled: true
2249 swap:
2250 file:
2251 enabled: true
2252 engine: file
2253 device: /swapfile
2254 size: 1024
2255
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002256Partition swap configuration:
Lachlan Evenson30676512016-01-22 15:43:28 -08002257
2258.. code-block:: yaml
2259
2260 linux:
2261 storage:
2262 enabled: true
2263 swap:
2264 partition:
2265 enabled: true
2266 engine: partition
2267 device: /dev/vg0/swap
2268
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002269LVM group ``vg1`` with one device and ``data`` volume mounted
2270into ``/mnt/data``.
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002271
2272.. code-block:: yaml
2273
2274 parameters:
2275 linux:
2276 storage:
2277 mount:
2278 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01002279 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002280 device: /dev/vg1/data
2281 file_system: ext4
2282 path: /mnt/data
2283 lvm:
2284 vg1:
2285 enabled: true
2286 devices:
2287 - /dev/sdb
2288 volume:
2289 data:
2290 size: 40G
2291 mount: ${linux:storage:mount:data}
root40bb5e72019-01-11 08:55:32 +00002292 # When set they will take precedence over filters aget from volume groups.
2293 lvm_filters:
2294 10:
2295 enabled: True
2296 value: "a|loop|"
2297 20:
2298 enabled: True
2299 value: "r|/dev/hdc|"
2300 30:
2301 enabled: True
2302 value: "a|/dev/ide|"
2303 40:
2304 enabled: True
2305 value: "r|.*|"
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002306
Jakub Pavlik4f742142017-08-08 15:05:50 +02002307Create partitions on disk. Specify size in MB. It expects empty
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002308disk without any existing partitions.
2309Set ``startsector=1`` if you want to start partitions from ``2048``.
Jakub Pavlik4f742142017-08-08 15:05:50 +02002310
2311.. code-block:: yaml
2312
2313 linux:
2314 storage:
2315 disk:
2316 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01002317 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02002318 name: /dev/loop1
2319 type: gpt
2320 partitions:
2321 - size: 200 #size in MB
2322 type: fat32
2323 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02002324 mkfs: True
2325 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02002326 /dev/vda1:
2327 partitions:
2328 - size: 5
2329 type: ext2
2330 - size: 10
2331 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02002332
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002333Multipath with Fujitsu Eternus DXL:
Ales Komareka634f4b2016-10-02 13:11:04 +02002334
2335.. code-block:: yaml
2336
2337 parameters:
2338 linux:
2339 storage:
2340 multipath:
2341 enabled: true
2342 blacklist_devices:
2343 - /dev/sda
2344 - /dev/sdb
2345 backends:
2346 - fujitsu_eternus_dxl
2347
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002348Multipath with Hitachi VSP 1000:
Ales Komareka634f4b2016-10-02 13:11:04 +02002349
2350.. code-block:: yaml
2351
2352 parameters:
2353 linux:
2354 storage:
2355 multipath:
2356 enabled: true
2357 blacklist_devices:
2358 - /dev/sda
2359 - /dev/sdb
2360 backends:
2361 - hitachi_vsp1000
2362
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002363Multipath with IBM Storwize:
Ales Komareka634f4b2016-10-02 13:11:04 +02002364
2365.. code-block:: yaml
2366
2367 parameters:
2368 linux:
2369 storage:
2370 multipath:
2371 enabled: true
2372 blacklist_devices:
2373 - /dev/sda
2374 - /dev/sdb
2375 backends:
2376 - ibm_storwize
2377
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002378Multipath with multiple backends:
Ales Komareka634f4b2016-10-02 13:11:04 +02002379
2380.. code-block:: yaml
2381
2382 parameters:
2383 linux:
2384 storage:
2385 multipath:
2386 enabled: true
2387 blacklist_devices:
2388 - /dev/sda
2389 - /dev/sdb
2390 - /dev/sdc
2391 - /dev/sdd
2392 backends:
2393 - ibm_storwize
2394 - fujitsu_eternus_dxl
2395 - hitachi_vsp1000
2396
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002397PAM LDAP integration:
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002398
2399.. code-block:: yaml
2400
2401 parameters:
2402 linux:
2403 system:
2404 auth:
2405 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02002406 mkhomedir:
2407 enabled: true
2408 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002409 ldap:
2410 enabled: true
2411 binddn: cn=bind,ou=service_users,dc=example,dc=com
2412 bindpw: secret
2413 uri: ldap://127.0.0.1
2414 base: ou=users,dc=example,dc=com
2415 ldap_version: 3
2416 pagesize: 65536
2417 referrals: off
2418 filter:
2419 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2420 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2421 group: (&(objectClass=group)(gidNumber=*))
2422
Gleb Galkin93b9ae92018-10-18 13:57:30 +03002423PAM duo 2FA integration
2424
2425.. code-block:: yaml
2426
2427 parameters:
2428 linux:
2429 system:
2430 auth:
2431 enabled: true
2432 duo:
2433 enabled: true
2434 duo_host: localhost
2435 duo_ikey: DUO-INTEGRATION-KEY
2436 duo_skey: DUO-SECRET-KEY
2437
2438duo package version may be specified (optional)
2439
2440.. code-block:: yaml
2441
2442 linux:
2443 system:
2444 package:
2445 duo-unix:
2446 version: 1.10.1-0
2447
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002448Disabled multipath (the default setup):
Ales Komareka634f4b2016-10-02 13:11:04 +02002449
2450.. code-block:: yaml
2451
2452 parameters:
2453 linux:
2454 storage:
2455 multipath:
2456 enabled: false
2457
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002458Linux with local loopback device:
Simon Pasquier375001e2017-01-26 13:22:33 +01002459
2460.. code-block:: yaml
2461
2462 linux:
2463 storage:
2464 loopback:
2465 disk1:
2466 file: /srv/disk1
2467 size: 50G
2468
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002469External config generation
2470--------------------------
2471
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002472You are able to use config support metadata between formulas
2473and only generate configuration files for external use, for example, Docker, and so on.
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002474
2475.. code-block:: yaml
2476
2477 parameters:
2478 linux:
2479 system:
2480 config:
2481 pillar:
2482 jenkins:
2483 master:
2484 home: /srv/volumes/jenkins
2485 approved_scripts:
2486 - method java.net.URL openConnection
2487 credentials:
2488 - type: username_password
2489 scope: global
2490 id: test
2491 desc: Testing credentials
2492 username: test
2493 password: test
2494
Vladimir Ereminccf28842017-04-10 23:52:10 +03002495Netconsole Remote Kernel Logging
2496--------------------------------
2497
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002498Netconsole logger can be configured for the configfs-enabled kernels
2499(``CONFIG_NETCONSOLE_DYNAMIC`` must be enabled). The configuration
2500applies both in runtime (if network is already configured),
2501and on-boot after an interface initialization.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002502
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002503.. note::
2504
2505 * Receiver can be located only on the same L3 domain
2506 (or you need to configure gateway MAC manually).
2507 * The Receiver MAC is detected only on configuration time.
2508 * Using broadcast MAC is not recommended.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002509
2510.. code-block:: yaml
2511
2512 parameters:
2513 linux:
2514 system:
2515 netconsole:
2516 enabled: true
2517 port: 514 (optional)
2518 loglevel: debug (optional)
2519 target:
2520 192.168.0.1:
2521 interface: bond0
2522 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02002523
Dzmitry Stremkouskid1a268b2018-10-03 16:36:04 +02002524Check network params on the environment
2525---------------------------------------
2526
2527Grab nics and nics states
2528
2529.. code-block:: bash
2530
2531 salt osd001\* net_checks.get_nics
2532
2533**Example of system output:**
2534
2535.. code-block:: bash
2536
2537 osd001.domain.com:
2538 |_
2539 - bond0
2540 - None
2541 - 1e:c8:64:42:23:b9
2542 - 0
2543 - 1500
2544 |_
2545 - bond1
2546 - None
2547 - 3c:fd:fe:27:3b:00
2548 - 1
2549 - 9100
2550 |_
2551 - fourty1
2552 - None
2553 - 3c:fd:fe:27:3b:00
2554 - 1
2555 - 9100
2556 |_
2557 - fourty2
2558 - None
2559 - 3c:fd:fe:27:3b:02
2560 - 1
2561 - 9100
2562
2563Grab 10G nics PCI addresses for hugepages setup
2564
2565.. code-block:: bash
2566
2567 salt cmp001\* net_checks.get_ten_pci
2568
2569**Example of system output:**
2570
2571.. code-block:: bash
2572
2573 cmp001.domain.com:
2574 |_
2575 - ten1
2576 - 0000:19:00.0
2577 |_
2578 - ten2
2579 - 0000:19:00.1
2580 |_
2581 - ten3
2582 - 0000:19:00.2
2583 |_
2584 - ten4
2585 - 0000:19:00.3
2586
2587Grab ip address for an interface
2588
2589.. code-block:: bash
2590
2591 salt cmp001\* net_checks.get_ip iface=one4
2592
2593**Example of system output:**
2594
2595.. code-block:: bash
2596
2597 cmp001.domain.com:
2598 10.200.177.101
2599
2600Grab ip addresses map
2601
2602.. code-block:: bash
2603
2604 salt-call net_checks.nodes_addresses
2605
2606**Example of system output:**
2607
2608.. code-block:: bash
2609
2610 local:
2611 |_
2612 - cid01.domain.com
2613 |_
2614 |_
2615 - pxe
2616 - 10.200.177.91
2617 |_
2618 - control
2619 - 10.200.178.91
2620 |_
2621 - cmn02.domain.com
2622 |_
2623 |_
2624 - storage_access
2625 - 10.200.181.67
2626 |_
2627 - pxe
2628 - 10.200.177.67
2629 |_
2630 - control
2631 - 10.200.178.67
2632 |_
2633 - cmp010.domain.com
2634 |_
2635 |_
2636 - pxe
2637 - 10.200.177.110
2638 |_
2639 - storage_access
2640 - 10.200.181.110
2641 |_
2642 - control
2643 - 10.200.178.110
2644 |_
2645 - vxlan
2646 - 10.200.179.110
2647
2648Verify full mesh connectivity
2649
2650.. code-block:: bash
2651
2652 salt-call net_checks.ping_check
2653
2654**Example of positive system output:**
2655
2656.. code-block:: bash
2657
2658 ['PASSED']
2659 [INFO ] ['PASSED']
2660 local:
2661 True
2662
2663**Example of system output in case of failure:**
2664
2665.. code-block:: bash
2666
2667 FAILED
2668 [ERROR ] FAILED
2669 ['control: 10.0.1.92 -> 10.0.1.224: Failed']
2670 ['control: 10.0.1.93 -> 10.0.1.224: Failed']
2671 ['control: 10.0.1.51 -> 10.0.1.224: Failed']
2672 ['control: 10.0.1.102 -> 10.0.1.224: Failed']
2673 ['control: 10.0.1.13 -> 10.0.1.224: Failed']
2674 ['control: 10.0.1.81 -> 10.0.1.224: Failed']
2675 local:
2676 False
2677
2678For this feature to work, please mark addresses with some role.
2679Otherwise 'default' role is assumed and mesh would consist of all
2680addresses on the environment.
2681
2682Mesh mark is needed only for interfaces which are enabled and have
2683ip address assigned.
2684
2685Checking dhcp pxe network meaningless, as it is used for salt
2686master vs minion communications, therefore treated as checked.
2687
2688.. code-block:: yaml
2689
2690 parameters:
2691 linux:
2692 network:
2693 interface:
2694 ens3:
2695 enabled: true
2696 type: eth
2697 proto: static
2698 address: ${_param:deploy_address}
2699 netmask: ${_param:deploy_network_netmask}
2700 gateway: ${_param:deploy_network_gateway}
2701 mesh: pxe
2702
2703Check pillars for ip address duplicates
2704
2705.. code-block:: bash
2706
2707 salt-call net_checks.verify_addresses
2708
2709**Example of positive system output:**
2710
2711.. code-block:: bash
2712
2713 ['PASSED']
2714 [INFO ] ['PASSED']
2715 local:
2716 True
2717
2718**Example of system output in case of failure:**
2719
2720.. code-block:: bash
2721
2722 FAILED. Duplicates found
2723 [ERROR ] FAILED. Duplicates found
2724 ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2725 [ERROR ] ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2726 local:
2727 False
2728
2729Generate csv report for the env
2730
2731.. code-block:: bash
2732
2733 salt -C 'kvm* or cmp* or osd*' net_checks.get_nics_csv \
2734 | grep '^\ ' | sed 's/\ *//g' | grep -Ev ^server \
2735 | sed '1 i\server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr'
2736
2737**Example of system output:**
2738
2739.. code-block:: bash
2740
2741 server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr
2742 cmp010.domain.com,bond0,None,b4:96:91:10:5b:3a,1,1500,,,,
2743 cmp010.domain.com,bond0.21,10.200.178.110,b4:96:91:10:5b:3a,1,1500,,,,
2744 cmp010.domain.com,bond0.22,10.200.179.110,b4:96:91:10:5b:3a,1,1500,,,,
2745 cmp010.domain.com,bond1,None,3c:fd:fe:34:ad:22,0,1500,,,,
2746 cmp010.domain.com,bond1.24,10.200.181.110,3c:fd:fe:34:ad:22,0,1500,,,,
2747 cmp010.domain.com,fourty5,None,3c:fd:fe:34:ad:20,0,9000,,,,
2748 cmp010.domain.com,fourty6,None,3c:fd:fe:34:ad:22,0,9000,,,,
2749 cmp010.domain.com,one1,None,b4:96:91:10:5b:38,0,1500,,,,
2750 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
2751 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
2752 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
2753 cmp011.domain.com,bond0,None,b4:96:91:13:6c:aa,1,1500,,,,
2754 cmp011.domain.com,bond0.21,10.200.178.111,b4:96:91:13:6c:aa,1,1500,,,,
2755 cmp011.domain.com,bond0.22,10.200.179.111,b4:96:91:13:6c:aa,1,1500,,,,
2756 ...
2757
Filip Pytlounf5383a42015-10-06 16:28:32 +02002758Usage
2759=====
2760
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002761Set MTU of the eth0 network interface to 1400:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002762
2763.. code-block:: bash
2764
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002765 ip link set dev eth0 mtu 1400
Filip Pytlounf5383a42015-10-06 16:28:32 +02002766
2767Read more
2768=========
2769
2770* https://www.archlinux.org/
2771* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu