blob: 8452218a5d31f8dcd09d3c58a32f556d25ae6a2f [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
Dzmitry Stremkouskif6fb7212019-08-26 16:48:05 +02001507 proto: manual
1508 mtu: 9000
1509 name: ${_param:vlan_bond_name}
1510 slaves: ${_param:vlan_nic1} ${_param:vlan_nic2}
1511 mode: 802.3ad
1512 lacp_rate: slow
1513 downdelay: 200
1514 xmit_hash_policy: layer3+4
1515 miimon: 100
1516 use_interfaces:
1517 - ${_param:vlan_nic1}
1518 - ${_param:vlan_nic2}
1519 require_interfaces:
1520 - ${_param:vlan_nic1}
1521 - ${_param:vlan_nic2}
jan kaufman6d30adf2016-01-18 17:30:12 +01001522 network_manager:
1523 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001524
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001525Linux with VLAN ``interface_params``:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001526
1527.. code-block:: yaml
1528
1529 linux:
1530 network:
1531 enabled: true
1532 interface:
1533 vlan69:
1534 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +01001535 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001536 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001537
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001538Linux with wireless interface parameters:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001539
1540.. code-block:: yaml
1541
1542 linux:
1543 network:
1544 enabled: true
1545 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001546 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001547 interface:
1548 wlan0:
1549 type: eth
1550 wireless:
1551 essid: example
1552 key: example_key
1553 security: wpa
1554 priority: 1
1555
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001556Linux networks with routes defined:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001557
1558.. code-block:: yaml
1559
1560 linux:
1561 network:
1562 enabled: true
1563 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001564 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001565 interface:
1566 eth0:
1567 type: eth
1568 route:
1569 default:
1570 address: 192.168.0.123
1571 netmask: 255.255.255.0
1572 gateway: 192.168.0.1
1573
ivcc4730b12019-01-23 07:56:53 +03001574Linux networks with implicit routes definition:
1575
1576- on node 1:
1577
1578.. code-block:: yaml
1579
1580 linux:
1581 network:
1582 enabled: true
1583 router:
1584 ctl:
1585 # router that connects 10.0.1.0/24 and 10.0.2.0/24
1586 addresses:
1587 - 10.0.1.1/24
1588 - 10.0.2.1/24
1589 test:
1590 addresses:
1591 - 10.0.1.2/24
1592 networks:
1593 - 10.100.0.0/16
1594 interface:
1595 ctl:
1596 name: eth0
1597 address: 10.0.1.101
1598 netmask: 255.255.255.0
1599
1600- on node2:
1601
1602.. code-block:: yaml
1603
1604 linux:
1605 network:
1606 enabled: true
1607 router:
1608 ctl:
1609 # equivalent of node1's ctl router with 'implicit_routes = false'
1610 options:
1611 implicit_routes: false
1612 addresses:
1613 - 10.0.1.1/24
1614 - 10.0.2.1/24
1615 networks:
1616 - 10.0.1.0/24
1617 - 10.0.2.0/24
1618 interface:
1619 ctl:
1620 name: eth0
1621 address: 10.0.2.101
1622 netmask: 255.255.255.0
1623
1624
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001625Native Linux Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001626
1627.. code-block:: yaml
1628
1629 linux:
1630 network:
1631 interface:
1632 eth1:
1633 enabled: true
1634 type: eth
1635 proto: manual
1636 up_cmds:
1637 - ip address add 0/0 dev $IFACE
1638 - ip link set $IFACE up
1639 down_cmds:
1640 - ip link set $IFACE down
1641 br-ex:
1642 enabled: true
1643 type: bridge
1644 address: ${linux:network:host:public_local:address}
1645 netmask: 255.255.255.0
1646 use_interfaces:
1647 - eth1
1648
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001649Open vSwitch Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001650
1651.. code-block:: yaml
1652
1653 linux:
1654 network:
1655 bridge: openvswitch
1656 interface:
1657 eth1:
1658 enabled: true
1659 type: eth
1660 proto: manual
1661 up_cmds:
1662 - ip address add 0/0 dev $IFACE
1663 - ip link set $IFACE up
1664 down_cmds:
1665 - ip link set $IFACE down
1666 br-ex:
1667 enabled: true
1668 type: bridge
1669 address: ${linux:network:host:public_local:address}
1670 netmask: 255.255.255.0
1671 use_interfaces:
1672 - eth1
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001673 br-prv:
1674 enabled: true
1675 type: ovs_bridge
1676 mtu: 65000
1677 br-ens7:
1678 enabled: true
1679 name: br-ens7
1680 type: ovs_bridge
1681 proto: manual
1682 mtu: 9000
1683 use_interfaces:
1684 - ens7
1685 patch-br-ens7-br-prv:
1686 enabled: true
1687 name: ens7-prv
1688 ovs_type: ovs_port
1689 type: ovs_port
1690 bridge: br-ens7
1691 port_type: patch
1692 peer: prv-ens7
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001693 tag: 109 # [] to unset a tag
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001694 mtu: 65000
1695 patch-br-prv-br-ens7:
1696 enabled: true
1697 name: prv-ens7
1698 bridge: br-prv
1699 ovs_type: ovs_port
1700 type: ovs_port
1701 port_type: patch
1702 peer: ens7-prv
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001703 tag: 109
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001704 mtu: 65000
1705 ens7:
1706 enabled: true
1707 name: ens7
1708 proto: manual
1709 ovs_port_type: OVSPort
1710 type: ovs_port
1711 ovs_bridge: br-ens7
1712 bridge: br-ens7
Oleg Gelbukh52f9f762019-07-01 15:26:16 -07001713 ens6:
1714 enabled: true
1715 proto: manual
1716 type: eth
1717 ovs_bridge: br-ctl
1718 br-ctl:
1719 enabled: true
1720 type: ovs_bridge
1721 internal-br-ctl-port:
1722 enabled: true
1723 proto: static
1724 address: 172.172.0.10
1725 netmask: 255.255.0.0
1726 name_servers:
1727 - 8.8.8.8
1728 - 172.172.172.172
1729 name: port-br-ctl
1730 bridge: br-ctl
1731 ovs_type: ovs_port
1732 type: ovs_port
1733 port_type: internal
1734 mtu: 65000
Filip Pytlounf5383a42015-10-06 16:28:32 +02001735
Petr Jediný8f8ae542017-07-13 16:19:12 +02001736Debian manual proto interfaces
1737
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001738When you are changing interface proto from static in up state
1739to manual, you may need to flush ip addresses. For example,
1740if you want to use the interface and the ip on the bridge.
1741This can be done by setting the ``ipflush_onchange`` to true.
Petr Jediný8f8ae542017-07-13 16:19:12 +02001742
1743.. code-block:: yaml
1744
1745 linux:
1746 network:
1747 interface:
1748 eth1:
1749 enabled: true
1750 type: eth
1751 proto: manual
1752 mtu: 9100
1753 ipflush_onchange: true
1754
Jiri Broulik1a191e32018-01-15 15:54:21 +01001755Debian static proto interfaces
1756
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001757When you are changing interface proto from dhcp in up state to
1758static, you may need to flush ip addresses and restart interface
1759to assign ip address from a managed file. For example, if you wantto
1760use the interface and the ip on the bridge. This can be done by
1761setting the ``ipflush_onchange`` with combination ``restart_on_ipflush``
1762param set to true.
Jiri Broulik1a191e32018-01-15 15:54:21 +01001763
1764.. code-block:: yaml
1765
1766 linux:
1767 network:
1768 interface:
1769 eth1:
1770 enabled: true
1771 type: eth
1772 proto: static
1773 address: 10.1.0.22
1774 netmask: 255.255.255.0
1775 ipflush_onchange: true
1776 restart_on_ipflush: true
Petr Jediný8f8ae542017-07-13 16:19:12 +02001777
Petr Jedinýd577cb52017-06-28 20:17:49 +02001778Concatinating and removing interface files
1779
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001780Debian based distributions have ``/etc/network/interfaces.d/``
1781directory, where you can store configuration of network
1782interfaces in separate files. You can concatinate the files
1783to the defined destination when needed, this operation removes
1784the file from the ``/etc/network/interfaces.d/``. If you just need
1785to remove iface files, you can use the ``remove_iface_files`` key.
Petr Jedinýd577cb52017-06-28 20:17:49 +02001786
1787.. code-block:: yaml
1788
1789 linux:
1790 network:
1791 concat_iface_files:
1792 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
1793 dst: '/etc/network/interfaces'
1794 remove_iface_files:
1795 - '/etc/network/interfaces.d/90-custom.cfg'
1796
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001797Configure DHCP client
Petr Jedinýd577cb52017-06-28 20:17:49 +02001798
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001799None of the keys is mandatory, include only those you really need.
1800For full list of available options under send, supersede, prepend,
1801append refer to dhcp-options(5).
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001802
1803.. code-block:: yaml
1804
1805 linux:
1806 network:
1807 dhclient:
1808 enabled: true
1809 backoff_cutoff: 15
1810 initial_interval: 10
1811 reboot: 10
1812 retry: 60
1813 select_timeout: 0
1814 timeout: 120
1815 send:
1816 - option: host-name
1817 declaration: "= gethostname()"
1818 supersede:
1819 - option: host-name
1820 declaration: "spaceship"
1821 - option: domain-name
1822 declaration: "domain.home"
1823 #- option: arp-cache-timeout
1824 # declaration: 20
1825 prepend:
1826 - option: domain-name-servers
1827 declaration:
1828 - 8.8.8.8
1829 - 8.8.4.4
1830 - option: domain-search
1831 declaration:
1832 - example.com
1833 - eng.example.com
1834 #append:
1835 #- option: domain-name-servers
1836 # declaration: 127.0.0.1
1837 # ip or subnet to reject dhcp offer from
1838 reject:
1839 - 192.33.137.209
1840 - 10.0.2.0/24
1841 request:
1842 - subnet-mask
1843 - broadcast-address
1844 - time-offset
1845 - routers
1846 - domain-name
1847 - domain-name-servers
1848 - domain-search
1849 - host-name
1850 - dhcp6.name-servers
1851 - dhcp6.domain-search
1852 - dhcp6.fqdn
1853 - dhcp6.sntp-servers
1854 - netbios-name-servers
1855 - netbios-scope
1856 - interface-mtu
1857 - rfc3442-classless-static-routes
1858 - ntp-servers
1859 require:
1860 - subnet-mask
1861 - domain-name-servers
1862 # if per interface configuration required add below
1863 interface:
1864 ens2:
1865 initial_interval: 11
1866 reject:
1867 - 192.33.137.210
1868 ens3:
1869 initial_interval: 12
1870 reject:
1871 - 192.33.137.211
1872
Petr Michaleceb14b552017-06-01 10:27:05 +02001873Linux network systemd settings:
1874
1875.. code-block:: yaml
1876
1877 linux:
1878 network:
1879 ...
1880 systemd:
1881 link:
1882 10-iface-dmz:
1883 Match:
1884 MACAddress: c8:5b:67:fa:1a:af
1885 OriginalName: eth0
1886 Link:
1887 Name: dmz0
1888 netdev:
1889 20-bridge-dmz:
1890 match:
1891 name: dmz0
1892 network:
1893 mescription: bridge
1894 bridge: br-dmz0
1895 network:
1896 # works with lowercase, keys are by default capitalized
1897 40-dhcp:
1898 match:
1899 name: '*'
1900 network:
1901 DHCP: yes
1902
Petr Michalec10462bb2017-03-23 19:18:08 +01001903Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +01001904
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001905Use ``/etc/environment`` for static system wide variable assignment
1906after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001907
1908.. code-block:: yaml
1909
1910 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +01001911 system:
1912 env:
1913 BOB_VARIABLE: Alice
1914 ...
1915 BOB_PATH:
1916 - /srv/alice/bin
1917 - /srv/bob/bin
1918 ...
1919 ftp_proxy: none
1920 http_proxy: http://global-http-proxy.host.local:8080
1921 https_proxy: ${linux:system:proxy:https}
1922 no_proxy:
1923 - 192.168.0.80
1924 - 192.168.1.80
1925 - .domain.com
1926 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001927 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001928 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001929 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001930 ftp: ftp://proxy.host.local:2121
1931 http: http://proxy.host.local:3142
1932 https: https://proxy.host.local:3143
1933 noproxy:
1934 - .domain.com
1935 - .local
1936
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001937Configure the ``profile.d`` scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001938
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001939The ``profile.d`` scripts are being sourced during ``.sh`` execution
1940and support variable expansion in opposite to /etc/environment global
1941settings in ``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001942
1943.. code-block:: yaml
1944
1945 linux:
1946 system:
1947 profile:
1948 locales: |
1949 export LANG=C
1950 export LC_ALL=C
1951 ...
1952 vi_flavors.sh: |
1953 export PAGER=view
1954 export EDITOR=vim
1955 alias vi=vim
1956 shell_locales.sh: |
1957 export LANG=en_US
1958 export LC_ALL=en_US.UTF-8
1959 shell_proxies.sh: |
1960 export FTP_PROXY=ftp://127.0.3.3:2121
1961 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001962
Dmitry Teselkina0d31d12018-09-04 14:43:09 +03001963
1964Configure login.defs parameters
1965-------------------------------
1966
1967.. code-block:: yaml
1968
1969 linux:
1970 system:
1971 login_defs:
1972 <opt_name>:
1973 enabled: true
1974 value: <opt_value>
1975
1976<opt_name> is a configurational option defined in 'man login.defs'.
1977<opt_name> is case sensitive, should be UPPERCASE only!
1978
1979
Filip Pytlounf5383a42015-10-06 16:28:32 +02001980Linux with hosts
1981
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001982Parameter ``purge_hosts`` will enforce whole ``/etc/hosts file``,
1983removing entries that are not defined in model except defaults
1984for both IPv4 and IPv6 localhost and hostname as well as FQDN.
Ales Komarek417e8c52017-08-25 15:10:29 +02001985
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001986We recommend using this option to verify that ``/etc/hosts``
1987is always in a clean state. However it is not enabled by default
1988for security reasons.
Filip Pytloun86506fe2017-01-26 14:36:16 +01001989
Filip Pytlounf5383a42015-10-06 16:28:32 +02001990.. code-block:: yaml
1991
1992 linux:
1993 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001994 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001995 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001996 # No need to define this one if purge_hosts is true
1997 hostname:
1998 address: 127.0.1.1
1999 names:
2000 - ${linux:network:fqdn}
2001 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02002002 node1:
2003 address: 192.168.10.200
2004 names:
2005 - node2.domain.com
2006 - service2.domain.com
2007 node2:
2008 address: 192.168.10.201
2009 names:
2010 - node2.domain.com
2011 - service2.domain.com
2012
Ales Komarek417e8c52017-08-25 15:10:29 +02002013Linux with hosts collected from mine
2014
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002015All DNS records defined within infrastrucuture
2016are passed to the local hosts records or any DNS server. Only
2017hosts with the ``grain`` parameter set to ``true`` will be propagated
2018to the mine.
Ales Komarek417e8c52017-08-25 15:10:29 +02002019
2020.. code-block:: yaml
2021
2022 linux:
2023 network:
2024 purge_hosts: true
2025 mine_dns_records: true
2026 host:
2027 node1:
2028 address: 192.168.10.200
2029 grain: true
2030 names:
2031 - node2.domain.com
2032 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01002033
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04002034Set up ``resolvconf's basic resolver info``, e.g. nameservers, search/domain and options:
Filip Pytlounde9bea52016-01-11 15:39:10 +01002035
2036.. code-block:: yaml
2037
2038 linux:
2039 network:
2040 resolv:
2041 dns:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04002042 - 8.8.4.4
2043 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01002044 domain: my.example.com
2045 search:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04002046 - my.example.com
2047 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01002048 options:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04002049 - ndots:5
2050 - timeout:2
2051 - attempts:2
Filip Pytlounde9bea52016-01-11 15:39:10 +01002052
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002053Set up custom TX queue length for tap interfaces:
Andrii Petrenko735761d2017-03-21 17:17:35 -07002054
2055.. code-block:: yaml
2056
2057 linux:
2058 network:
2059 tap_custom_txqueuelen: 10000
2060
Michael Polenchuk6e3042b2019-04-22 15:20:03 +04002061Auto repair/re-attach libvirt's vnet interfaces:
2062
2063.. code-block:: yaml
2064
2065 linux:
2066 network:
2067 libvirt_vnet_repair: true
2068
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002069DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002070
2071**DPDK OVS NIC**
2072
2073.. code-block:: yaml
2074
2075 linux:
2076 network:
2077 bridge: openvswitch
2078 dpdk:
2079 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04002080 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002081 openvswitch:
2082 pmd_cpu_mask: "0x6"
2083 dpdk_socket_mem: "1024,1024"
2084 dpdk_lcore_mask: "0x400"
2085 memory_channels: 2
2086 interface:
2087 dpkd0:
2088 name: ${_param:dpdk_nic}
2089 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002090 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002091 enabled: true
2092 type: dpdk_ovs_port
2093 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002094 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002095 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01002096 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002097 br-prv:
2098 enabled: true
2099 type: dpdk_ovs_bridge
Michael Polenchukd3378db2018-12-29 16:46:50 +04002100 br-floating:
2101 enabled: true
2102 type: ovs_bridge
2103 name_servers:
2104 - 1.1.1.1
2105 - 9.9.9.9
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002106
2107**DPDK OVS Bond**
2108
2109.. code-block:: yaml
2110
2111 linux:
2112 network:
2113 bridge: openvswitch
2114 dpdk:
2115 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04002116 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002117 openvswitch:
2118 pmd_cpu_mask: "0x6"
2119 dpdk_socket_mem: "1024,1024"
2120 dpdk_lcore_mask: "0x400"
2121 memory_channels: 2
2122 interface:
2123 dpdk_second_nic:
2124 name: ${_param:primary_second_nic}
2125 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002126 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002127 bond: dpdkbond0
2128 enabled: true
2129 type: dpdk_ovs_port
2130 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002131 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002132 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002133 dpdk_first_nic:
2134 name: ${_param:primary_first_nic}
2135 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002136 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002137 bond: dpdkbond0
2138 enabled: true
2139 type: dpdk_ovs_port
2140 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002141 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002142 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002143 dpdkbond0:
2144 enabled: true
2145 bridge: br-prv
2146 type: dpdk_ovs_bond
2147 mode: active-backup
2148 br-prv:
2149 enabled: true
2150 type: dpdk_ovs_bridge
2151
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01002152**DPDK OVS LACP Bond with vlan tag**
2153
2154.. code-block:: yaml
2155
2156 linux:
2157 network:
2158 bridge: openvswitch
2159 dpdk:
2160 enabled: true
2161 driver: uio
2162 openvswitch:
2163 pmd_cpu_mask: "0x6"
2164 dpdk_socket_mem: "1024,1024"
2165 dpdk_lcore_mask: "0x400"
2166 memory_channels: "2"
2167 interface:
2168 eth3:
2169 enabled: true
2170 type: eth
2171 proto: manual
2172 name: ${_param:tenant_first_nic}
2173 eth4:
2174 enabled: true
2175 type: eth
2176 proto: manual
2177 name: ${_param:tenant_second_nic}
2178 dpdk0:
2179 name: ${_param:tenant_first_nic}
2180 pci: "0000:81:00.0"
2181 driver: igb_uio
2182 bond: bond1
2183 enabled: true
2184 type: dpdk_ovs_port
2185 n_rxq: 2
2186 dpdk1:
2187 name: ${_param:tenant_second_nic}
2188 pci: "0000:81:00.1"
2189 driver: igb_uio
2190 bond: bond1
2191 enabled: true
2192 type: dpdk_ovs_port
2193 n_rxq: 2
2194 bond1:
2195 enabled: true
2196 bridge: br-prv
2197 type: dpdk_ovs_bond
2198 mode: balance-slb
2199 br-prv:
2200 enabled: true
2201 type: dpdk_ovs_bridge
2202 tag: ${_param:tenant_vlan}
2203 address: ${_param:tenant_address}
2204 netmask: ${_param:tenant_network_netmask}
2205
Jakub Pavlikaa759062017-03-13 15:57:26 +01002206**DPDK OVS bridge for VXLAN**
2207
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002208If VXLAN is used as tenant segmentation, IP address must
2209be set on ``br-prv``.
Jakub Pavlikaa759062017-03-13 15:57:26 +01002210
2211.. code-block:: yaml
2212
2213 linux:
2214 network:
2215 ...
2216 interface:
2217 br-prv:
2218 enabled: true
2219 type: dpdk_ovs_bridge
2220 address: 192.168.50.0
2221 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04002222 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01002223 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002224
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02002225**DPDK OVS bridge with Linux network interface**
2226
2227.. code-block:: yaml
2228
2229 linux:
2230 network:
2231 ...
2232 interface:
2233 eth0:
2234 type: eth
2235 ovs_bridge: br-prv
2236 ...
2237 br-prv:
2238 enabled: true
2239 type: dpdk_ovs_bridge
2240 ...
2241
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002242Linux storage
2243-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02002244
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002245Linux with mounted Samba:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002246
2247.. code-block:: yaml
2248
2249 linux:
2250 storage:
2251 enabled: true
2252 mount:
2253 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01002254 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02002255 - path: /media/myuser/public/
2256 - device: //192.168.0.1/storage
2257 - file_system: cifs
2258 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
2259
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002260NFS mount:
Jiri Broulikb017f932017-03-31 13:55:36 +02002261
2262.. code-block:: yaml
2263
2264 linux:
2265 storage:
2266 enabled: true
2267 mount:
2268 nfs_glance:
2269 enabled: true
2270 path: /var/lib/glance/images
2271 device: 172.16.10.110:/var/nfs/glance
2272 file_system: nfs
2273 opts: rw,sync
2274
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002275File swap configuration:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002276
2277.. code-block:: yaml
2278
2279 linux:
2280 storage:
2281 enabled: true
2282 swap:
2283 file:
2284 enabled: true
2285 engine: file
2286 device: /swapfile
2287 size: 1024
2288
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002289Partition swap configuration:
Lachlan Evenson30676512016-01-22 15:43:28 -08002290
2291.. code-block:: yaml
2292
2293 linux:
2294 storage:
2295 enabled: true
2296 swap:
2297 partition:
2298 enabled: true
2299 engine: partition
2300 device: /dev/vg0/swap
2301
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002302LVM group ``vg1`` with one device and ``data`` volume mounted
2303into ``/mnt/data``.
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002304
2305.. code-block:: yaml
2306
2307 parameters:
2308 linux:
2309 storage:
2310 mount:
2311 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01002312 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002313 device: /dev/vg1/data
2314 file_system: ext4
2315 path: /mnt/data
2316 lvm:
2317 vg1:
2318 enabled: true
2319 devices:
2320 - /dev/sdb
2321 volume:
2322 data:
2323 size: 40G
2324 mount: ${linux:storage:mount:data}
root40bb5e72019-01-11 08:55:32 +00002325 # When set they will take precedence over filters aget from volume groups.
2326 lvm_filters:
2327 10:
2328 enabled: True
2329 value: "a|loop|"
2330 20:
2331 enabled: True
2332 value: "r|/dev/hdc|"
2333 30:
2334 enabled: True
2335 value: "a|/dev/ide|"
2336 40:
2337 enabled: True
2338 value: "r|.*|"
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002339
Jakub Pavlik4f742142017-08-08 15:05:50 +02002340Create partitions on disk. Specify size in MB. It expects empty
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002341disk without any existing partitions.
2342Set ``startsector=1`` if you want to start partitions from ``2048``.
Jakub Pavlik4f742142017-08-08 15:05:50 +02002343
2344.. code-block:: yaml
2345
2346 linux:
2347 storage:
2348 disk:
2349 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01002350 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02002351 name: /dev/loop1
2352 type: gpt
2353 partitions:
2354 - size: 200 #size in MB
2355 type: fat32
2356 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02002357 mkfs: True
2358 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02002359 /dev/vda1:
2360 partitions:
2361 - size: 5
2362 type: ext2
2363 - size: 10
2364 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02002365
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002366Multipath with Fujitsu Eternus DXL:
Ales Komareka634f4b2016-10-02 13:11:04 +02002367
2368.. code-block:: yaml
2369
2370 parameters:
2371 linux:
2372 storage:
2373 multipath:
2374 enabled: true
2375 blacklist_devices:
2376 - /dev/sda
2377 - /dev/sdb
2378 backends:
2379 - fujitsu_eternus_dxl
2380
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002381Multipath with Hitachi VSP 1000:
Ales Komareka634f4b2016-10-02 13:11:04 +02002382
2383.. code-block:: yaml
2384
2385 parameters:
2386 linux:
2387 storage:
2388 multipath:
2389 enabled: true
2390 blacklist_devices:
2391 - /dev/sda
2392 - /dev/sdb
2393 backends:
2394 - hitachi_vsp1000
2395
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002396Multipath with IBM Storwize:
Ales Komareka634f4b2016-10-02 13:11:04 +02002397
2398.. code-block:: yaml
2399
2400 parameters:
2401 linux:
2402 storage:
2403 multipath:
2404 enabled: true
2405 blacklist_devices:
2406 - /dev/sda
2407 - /dev/sdb
2408 backends:
2409 - ibm_storwize
2410
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002411Multipath with multiple backends:
Ales Komareka634f4b2016-10-02 13:11:04 +02002412
2413.. code-block:: yaml
2414
2415 parameters:
2416 linux:
2417 storage:
2418 multipath:
2419 enabled: true
2420 blacklist_devices:
2421 - /dev/sda
2422 - /dev/sdb
2423 - /dev/sdc
2424 - /dev/sdd
2425 backends:
2426 - ibm_storwize
2427 - fujitsu_eternus_dxl
2428 - hitachi_vsp1000
2429
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002430PAM LDAP integration:
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002431
2432.. code-block:: yaml
2433
2434 parameters:
2435 linux:
2436 system:
2437 auth:
2438 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02002439 mkhomedir:
2440 enabled: true
2441 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002442 ldap:
2443 enabled: true
2444 binddn: cn=bind,ou=service_users,dc=example,dc=com
2445 bindpw: secret
2446 uri: ldap://127.0.0.1
2447 base: ou=users,dc=example,dc=com
2448 ldap_version: 3
2449 pagesize: 65536
2450 referrals: off
2451 filter:
2452 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2453 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2454 group: (&(objectClass=group)(gidNumber=*))
2455
Gleb Galkin93b9ae92018-10-18 13:57:30 +03002456PAM duo 2FA integration
2457
2458.. code-block:: yaml
2459
2460 parameters:
2461 linux:
2462 system:
2463 auth:
2464 enabled: true
2465 duo:
2466 enabled: true
2467 duo_host: localhost
2468 duo_ikey: DUO-INTEGRATION-KEY
2469 duo_skey: DUO-SECRET-KEY
2470
2471duo package version may be specified (optional)
2472
2473.. code-block:: yaml
2474
2475 linux:
2476 system:
2477 package:
2478 duo-unix:
2479 version: 1.10.1-0
2480
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002481Disabled multipath (the default setup):
Ales Komareka634f4b2016-10-02 13:11:04 +02002482
2483.. code-block:: yaml
2484
2485 parameters:
2486 linux:
2487 storage:
2488 multipath:
2489 enabled: false
2490
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002491Linux with local loopback device:
Simon Pasquier375001e2017-01-26 13:22:33 +01002492
2493.. code-block:: yaml
2494
2495 linux:
2496 storage:
2497 loopback:
2498 disk1:
2499 file: /srv/disk1
2500 size: 50G
2501
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002502External config generation
2503--------------------------
2504
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002505You are able to use config support metadata between formulas
2506and only generate configuration files for external use, for example, Docker, and so on.
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002507
2508.. code-block:: yaml
2509
2510 parameters:
2511 linux:
2512 system:
2513 config:
2514 pillar:
2515 jenkins:
2516 master:
2517 home: /srv/volumes/jenkins
2518 approved_scripts:
2519 - method java.net.URL openConnection
2520 credentials:
2521 - type: username_password
2522 scope: global
2523 id: test
2524 desc: Testing credentials
2525 username: test
2526 password: test
2527
Vladimir Ereminccf28842017-04-10 23:52:10 +03002528Netconsole Remote Kernel Logging
2529--------------------------------
2530
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002531Netconsole logger can be configured for the configfs-enabled kernels
2532(``CONFIG_NETCONSOLE_DYNAMIC`` must be enabled). The configuration
2533applies both in runtime (if network is already configured),
2534and on-boot after an interface initialization.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002535
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002536.. note::
2537
2538 * Receiver can be located only on the same L3 domain
2539 (or you need to configure gateway MAC manually).
2540 * The Receiver MAC is detected only on configuration time.
2541 * Using broadcast MAC is not recommended.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002542
2543.. code-block:: yaml
2544
2545 parameters:
2546 linux:
2547 system:
2548 netconsole:
2549 enabled: true
2550 port: 514 (optional)
2551 loglevel: debug (optional)
2552 target:
2553 192.168.0.1:
2554 interface: bond0
2555 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02002556
Dzmitry Stremkouskid1a268b2018-10-03 16:36:04 +02002557Check network params on the environment
2558---------------------------------------
2559
2560Grab nics and nics states
2561
2562.. code-block:: bash
2563
2564 salt osd001\* net_checks.get_nics
2565
2566**Example of system output:**
2567
2568.. code-block:: bash
2569
2570 osd001.domain.com:
2571 |_
2572 - bond0
2573 - None
2574 - 1e:c8:64:42:23:b9
2575 - 0
2576 - 1500
2577 |_
2578 - bond1
2579 - None
2580 - 3c:fd:fe:27:3b:00
2581 - 1
2582 - 9100
2583 |_
2584 - fourty1
2585 - None
2586 - 3c:fd:fe:27:3b:00
2587 - 1
2588 - 9100
2589 |_
2590 - fourty2
2591 - None
2592 - 3c:fd:fe:27:3b:02
2593 - 1
2594 - 9100
2595
2596Grab 10G nics PCI addresses for hugepages setup
2597
2598.. code-block:: bash
2599
2600 salt cmp001\* net_checks.get_ten_pci
2601
2602**Example of system output:**
2603
2604.. code-block:: bash
2605
2606 cmp001.domain.com:
2607 |_
2608 - ten1
2609 - 0000:19:00.0
2610 |_
2611 - ten2
2612 - 0000:19:00.1
2613 |_
2614 - ten3
2615 - 0000:19:00.2
2616 |_
2617 - ten4
2618 - 0000:19:00.3
2619
2620Grab ip address for an interface
2621
2622.. code-block:: bash
2623
2624 salt cmp001\* net_checks.get_ip iface=one4
2625
2626**Example of system output:**
2627
2628.. code-block:: bash
2629
2630 cmp001.domain.com:
2631 10.200.177.101
2632
2633Grab ip addresses map
2634
2635.. code-block:: bash
2636
2637 salt-call net_checks.nodes_addresses
2638
2639**Example of system output:**
2640
2641.. code-block:: bash
2642
2643 local:
2644 |_
2645 - cid01.domain.com
2646 |_
2647 |_
2648 - pxe
2649 - 10.200.177.91
2650 |_
2651 - control
2652 - 10.200.178.91
2653 |_
2654 - cmn02.domain.com
2655 |_
2656 |_
2657 - storage_access
2658 - 10.200.181.67
2659 |_
2660 - pxe
2661 - 10.200.177.67
2662 |_
2663 - control
2664 - 10.200.178.67
2665 |_
2666 - cmp010.domain.com
2667 |_
2668 |_
2669 - pxe
2670 - 10.200.177.110
2671 |_
2672 - storage_access
2673 - 10.200.181.110
2674 |_
2675 - control
2676 - 10.200.178.110
2677 |_
2678 - vxlan
2679 - 10.200.179.110
2680
2681Verify full mesh connectivity
2682
2683.. code-block:: bash
2684
2685 salt-call net_checks.ping_check
2686
2687**Example of positive system output:**
2688
2689.. code-block:: bash
2690
2691 ['PASSED']
2692 [INFO ] ['PASSED']
2693 local:
2694 True
2695
2696**Example of system output in case of failure:**
2697
2698.. code-block:: bash
2699
2700 FAILED
2701 [ERROR ] FAILED
2702 ['control: 10.0.1.92 -> 10.0.1.224: Failed']
2703 ['control: 10.0.1.93 -> 10.0.1.224: Failed']
2704 ['control: 10.0.1.51 -> 10.0.1.224: Failed']
2705 ['control: 10.0.1.102 -> 10.0.1.224: Failed']
2706 ['control: 10.0.1.13 -> 10.0.1.224: Failed']
2707 ['control: 10.0.1.81 -> 10.0.1.224: Failed']
2708 local:
2709 False
2710
2711For this feature to work, please mark addresses with some role.
2712Otherwise 'default' role is assumed and mesh would consist of all
2713addresses on the environment.
2714
2715Mesh mark is needed only for interfaces which are enabled and have
2716ip address assigned.
2717
2718Checking dhcp pxe network meaningless, as it is used for salt
2719master vs minion communications, therefore treated as checked.
2720
2721.. code-block:: yaml
2722
2723 parameters:
2724 linux:
2725 network:
2726 interface:
2727 ens3:
2728 enabled: true
2729 type: eth
2730 proto: static
2731 address: ${_param:deploy_address}
2732 netmask: ${_param:deploy_network_netmask}
2733 gateway: ${_param:deploy_network_gateway}
2734 mesh: pxe
2735
2736Check pillars for ip address duplicates
2737
2738.. code-block:: bash
2739
2740 salt-call net_checks.verify_addresses
2741
2742**Example of positive system output:**
2743
2744.. code-block:: bash
2745
2746 ['PASSED']
2747 [INFO ] ['PASSED']
2748 local:
2749 True
2750
2751**Example of system output in case of failure:**
2752
2753.. code-block:: bash
2754
2755 FAILED. Duplicates found
2756 [ERROR ] FAILED. Duplicates found
2757 ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2758 [ERROR ] ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2759 local:
2760 False
2761
2762Generate csv report for the env
2763
2764.. code-block:: bash
2765
2766 salt -C 'kvm* or cmp* or osd*' net_checks.get_nics_csv \
2767 | grep '^\ ' | sed 's/\ *//g' | grep -Ev ^server \
2768 | sed '1 i\server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr'
2769
2770**Example of system output:**
2771
2772.. code-block:: bash
2773
2774 server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr
2775 cmp010.domain.com,bond0,None,b4:96:91:10:5b:3a,1,1500,,,,
2776 cmp010.domain.com,bond0.21,10.200.178.110,b4:96:91:10:5b:3a,1,1500,,,,
2777 cmp010.domain.com,bond0.22,10.200.179.110,b4:96:91:10:5b:3a,1,1500,,,,
2778 cmp010.domain.com,bond1,None,3c:fd:fe:34:ad:22,0,1500,,,,
2779 cmp010.domain.com,bond1.24,10.200.181.110,3c:fd:fe:34:ad:22,0,1500,,,,
2780 cmp010.domain.com,fourty5,None,3c:fd:fe:34:ad:20,0,9000,,,,
2781 cmp010.domain.com,fourty6,None,3c:fd:fe:34:ad:22,0,9000,,,,
2782 cmp010.domain.com,one1,None,b4:96:91:10:5b:38,0,1500,,,,
2783 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
2784 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
2785 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
2786 cmp011.domain.com,bond0,None,b4:96:91:13:6c:aa,1,1500,,,,
2787 cmp011.domain.com,bond0.21,10.200.178.111,b4:96:91:13:6c:aa,1,1500,,,,
2788 cmp011.domain.com,bond0.22,10.200.179.111,b4:96:91:13:6c:aa,1,1500,,,,
2789 ...
2790
Filip Pytlounf5383a42015-10-06 16:28:32 +02002791Usage
2792=====
2793
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002794Set MTU of the eth0 network interface to 1400:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002795
2796.. code-block:: bash
2797
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002798 ip link set dev eth0 mtu 1400
Filip Pytlounf5383a42015-10-06 16:28:32 +02002799
2800Read more
2801=========
2802
2803* https://www.archlinux.org/
2804* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu