blob: 1230b5b73ffa742a16c1daa9d742543499ce0110 [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 Teselkinc7814732019-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 Teselkinc7814732019-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 Berezovskiy25e177d2019-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
Filip Pytloun281034a2016-01-04 18:06:22 +0100586Kernel
587~~~~~~
588
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300589Install always up to date LTS kernel and headers from Ubuntu Trusty:
Filip Pytloun281034a2016-01-04 18:06:22 +0100590
591.. code-block:: yaml
592
593 linux:
594 system:
595 kernel:
596 type: generic
597 lts: trusty
598 headers: true
599
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300600Load kernel modules and add them to ``/etc/modules``:
Tomáš Kukrálba35b212017-02-15 17:59:46 +0100601
602.. code-block:: yaml
603
604 linux:
605 system:
606 kernel:
607 modules:
608 - nf_conntrack
609 - tp_smapi
610 - 8021q
611
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300612Configure or blacklist kernel modules with additional options to
613``/etc/modprobe.d`` following example will add
614``/etc/modprobe.d/nf_conntrack.conf`` file with line
615``options nf_conntrack hashsize=262144``:
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300616
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300617'option' can be a mapping (with 'enabled' and 'value' keys) or a scalar.
618
619Example for 'scalar' option value:
620
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300621.. code-block:: yaml
622
623 linux:
624 system:
625 kernel:
626 module:
627 nf_conntrack:
628 option:
629 hashsize: 262144
630
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300631Example for 'mapping' option value:
632
633.. code-block:: yaml
634
635 linux:
636 system:
637 kernel:
638 module:
639 nf_conntrack:
640 option:
641 hashsize:
642 enabled: true
643 value: 262144
644
645NOTE: 'enabled' key is optional and is True by default.
646
647Blacklist a module:
648
649.. code-block:: yaml
650
651 linux:
652 system:
653 kernel:
654 module:
655 nf_conntrack:
656 blacklist: true
657
658A module can have a number of aliases, wildcards are allowed.
659Define an alias for a module:
660
661.. code-block:: yaml
662
663 linux:
664 system:
665 kernel:
666 module:
667 nf_conntrack:
668 alias:
669 nfct:
670 enabled: true
671 "nf_conn*":
672 enabled: true
673
674NOTE: 'enabled' key is mandatory as there are no other keys exist.
675
676Execute custom command instead of 'insmod' when inserting a module:
677
678.. code-block:: yaml
679
680 linux:
681 system:
682 kernel:
683 module:
684 nf_conntrack:
685 install:
686 enabled: true
687 command: /bin/true
688
689NOTE: 'enabled' key is optional and is True by default.
690
691Execute custom command instead of 'rmmod' when removing a module:
692
693.. code-block:: yaml
694
695 linux:
696 system:
697 kernel:
698 module:
699 nf_conntrack:
700 remove:
701 enabled: true
702 command: /bin/true
703
704NOTE: 'enabled' key is optional and is True by default.
705
706Define module dependencies:
707
708.. code-block:: yaml
709
710 linux:
711 system:
712 kernel:
713 module:
714 nf_conntrack:
715 softdep:
716 pre:
717 1:
718 enabled: true
719 value: a
720 2:
721 enabled: true
722 value: b
723 3:
724 enabled: true
725 value: c
726 post:
727 1:
728 enabled: true
729 value: x
730 2:
731 enabled: true
732 value: y
733 3:
734 enabled: true
735 value: z
736
737NOTE: 'enabled' key is optional and is True by default.
738
739
Filip Pytloun281034a2016-01-04 18:06:22 +0100740Install specific kernel version and ensure all other kernel packages are
741not present. Also install extra modules and headers for this kernel:
742
743.. code-block:: yaml
744
745 linux:
746 system:
747 kernel:
748 type: generic
749 extra: true
750 headers: true
751 version: 4.2.0-22
752
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300753Systcl kernel parameters:
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100754
755.. code-block:: yaml
756
757 linux:
758 system:
759 kernel:
760 sysctl:
761 net.ipv4.tcp_keepalive_intvl: 3
762 net.ipv4.tcp_keepalive_time: 30
763 net.ipv4.tcp_keepalive_probes: 8
764
Michael Polenchukebf55522018-01-25 13:22:39 +0400765Configure kernel boot options:
766
767.. code-block:: yaml
768
769 linux:
770 system:
771 kernel:
772 boot_options:
773 - elevator=deadline
774 - spectre_v2=off
775 - nopti
776
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100777CPU
778~~~
779
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300780Enable cpufreq governor for every cpu:
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100781
782.. code-block:: yaml
783
784 linux:
785 system:
786 cpu:
787 governor: performance
788
Nick Metzf04f5f32018-01-08 15:25:04 +0100789
Jiri Broulik303905d2018-01-11 14:12:48 +0100790CGROUPS
791~~~~~~~
792
793Setup linux cgroups:
794
795.. code-block:: yaml
796
797 linux:
798 system:
799 cgroup:
800 enabled: true
801 group:
802 ceph_group_1:
803 controller:
804 cpu:
805 shares:
806 value: 250
807 cpuacct:
808 usage:
809 value: 0
810 cpuset:
811 cpus:
812 value: 1,2,3
813 memory:
814 limit_in_bytes:
815 value: 2G
816 memsw.limit_in_bytes:
817 value: 3G
818 mapping:
819 subjects:
820 - '@ceph'
821 generic_group_1:
822 controller:
823 cpu:
824 shares:
825 value: 250
826 cpuacct:
827 usage:
828 value: 0
829 mapping:
830 subjects:
831 - '*:firefox'
832 - 'student:cp'
833
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300834Shared libraries
Nick Metzf04f5f32018-01-08 15:25:04 +0100835~~~~~~~~~~~~~~~~
836
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300837Set additional shared library to Linux system library path:
Nick Metzf04f5f32018-01-08 15:25:04 +0100838
839.. code-block:: yaml
840
841 linux:
842 system:
843 ld:
844 library:
845 java:
846 - /usr/lib/jvm/jre-openjdk/lib/amd64/server
847 - /opt/java/jre/lib/amd64/server
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200848
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200849Certificates
850~~~~~~~~~~~~
851
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300852Add certificate authority into system trusted CA bundle:
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200853
854.. code-block:: yaml
855
856 linux:
857 system:
858 ca_certificates:
859 mycert: |
860 -----BEGIN CERTIFICATE-----
861 MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
862 A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
863 cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
864 MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
865 BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
866 YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
867 ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
868 BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
869 I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
870 CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
871 lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
872 AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
873 -----END CERTIFICATE-----
874
Filip Pytloun361096c2017-08-23 10:57:20 +0200875Sysfs
876~~~~~
877
878Install sysfsutils and set sysfs attributes:
879
880.. code-block:: yaml
881
882 linux:
883 system:
884 sysfs:
885 scheduler:
886 block/sda/queue/scheduler: deadline
887 power:
888 mode:
889 power/state: 0660
890 owner:
891 power/state: "root:power"
892 devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
893
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200894Optional: You can also use list that will ensure order of items.
895
896.. code-block:: yaml
897
898 linux:
899 system:
900 sysfs:
901 scheduler:
902 block/sda/queue/scheduler: deadline
903 power:
904 - mode:
905 power/state: 0660
906 - owner:
907 power/state: "root:power"
908 - devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
909
Martin Polreich148e1b82018-09-13 15:54:25 +0200910Sysfs definition with disabled automatic write. Attributes are saved
911to configuration, but are not applied during the run.
912Thay will be applied automatically after the reboot.
913
914
915.. code-block:: yaml
916
917 linux:
918 system:
919 sysfs:
920 enable_apply: false
921 scheduler:
922 block/sda/queue/scheduler: deadline
923
924.. note:: The `enable_apply` parameter defaults to `True` if not defined.
925
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100926Huge Pages
927~~~~~~~~~~~~
928
929Huge Pages give a performance boost to applications that intensively deal
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300930with memory allocation/deallocation by decreasing memory fragmentation:
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100931
932.. code-block:: yaml
933
934 linux:
935 system:
936 kernel:
937 hugepages:
938 small:
939 size: 2M
940 count: 107520
941 mount_point: /mnt/hugepages_2MB
Michael Polenchukd9369fe2018-05-08 17:53:08 +0400942 mount: false/true # default is true (mount immediately) / false (just save in the fstab)
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100943 large:
944 default: true # default automatically mounted
945 size: 1G
946 count: 210
947 mount_point: /mnt/hugepages_1GB
948
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300949.. note:: Not recommended to use both pagesizes concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100950
Jakub Pavlik5398d872017-02-13 22:30:47 +0100951Intel SR-IOV
952~~~~~~~~~~~~
953
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300954PCI-SIG Single Root I/O Virtualization and Sharing (SR-IOV)
955specification defines a standardized mechanism to virtualize
956PCIe devices. The mechanism can virtualize a single PCIe
957Ethernet controller to appear as multiple PCIe devices:
Jakub Pavlik5398d872017-02-13 22:30:47 +0100958
959.. code-block:: yaml
960
961 linux:
962 system:
963 kernel:
964 sriov: True
965 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
966 rc:
967 local: |
968 #!/bin/sh -e
969 # Enable 7 VF on eth1
970 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
971 exit 0
972
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100973Isolate CPU options
974~~~~~~~~~~~~~~~~~~~
975
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300976Remove the specified CPUs, as defined by the cpu_number values, from
977the general kernel SMP balancing and scheduler algroithms. The only
978way to move a process onto or off an *isolated* CPU is via the CPU
979affinity syscalls. ``cpu_number begins`` at ``0``, so the
980maximum value is ``1`` less than the number of CPUs on the system.:
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100981
982.. code-block:: yaml
983
984 linux:
985 system:
986 kernel:
987 isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100988
Filip Pytlounf5383a42015-10-06 16:28:32 +0200989Repositories
990~~~~~~~~~~~~
991
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300992RedHat-based Linux with additional OpenStack repo:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200993
994.. code-block:: yaml
995
996 linux:
997 system:
998 ...
999 repo:
1000 rdo-icehouse:
1001 enabled: true
1002 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
1003 pgpcheck: 0
1004
1005Ensure system repository to use czech Debian mirror (``default: true``)
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001006Also pin it's packages with priority ``900``:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001007
1008.. code-block:: yaml
1009
1010 linux:
1011 system:
1012 repo:
1013 debian:
1014 default: true
1015 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
1016 # Import signing key from URL if needed
1017 key_url: "http://dummy.com/public.gpg"
1018 pin:
1019 - pin: 'origin "ftp.cz.debian.org"'
1020 priority: 900
1021 package: '*'
1022
azvyagintseva3a73d02018-12-06 14:49:58 +02001023Sometimes better to use one pining rule file, to decrease mistaken
1024ordering. You can use those option ``system:apt:preferences``, which would add opts into
1025``/etc/apt/preferences`` file:
1026
1027.. code-block:: yaml
1028
1029 parameters:
1030 linux:
1031 system:
1032 apt:
1033 preferences:
1034 enabled: true
1035 rules:
1036 100:
1037 enabled: true
1038 name: 'some origin pin'
1039 pin: 'release o=Debian'
1040 priority: 1100
1041 package: '*'
1042
1043
azvyagintsev4494a472018-09-14 19:19:23 +03001044If you need to add multiple pin rules for one repo, please use new,ordered definition format
1045('pinning' definition will be in priotity to use):
1046
1047.. code-block:: yaml
1048
1049 linux:
1050 system:
1051 repo:
1052 mcp_saltstack:
1053 source: "deb [arch=amd64] http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/ xenial main"
1054 architectures: amd64
1055 clean_file: true
1056 pinning:
1057 10:
1058 enabled: true
1059 pin: 'release o=SaltStack'
1060 priority: 50
1061 package: 'libsodium18'
1062 20:
1063 enabled: true
1064 pin: 'release o=SaltStack'
1065 priority: 1100
1066 package: '*'
1067
1068
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001069.. note:: For old Ubuntu releases (<xenial)
azvyagintsevff089d22018-07-27 16:52:34 +02001070 extra packages for apt transport, like ``apt-transport-https``
1071 may be required to be installed manually.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001072 (Chicken-eggs issue: we need to install packages to
azvyagintsevff089d22018-07-27 16:52:34 +02001073 reach repo from where they should be installed)
1074 Otherwise, you still can try 'fortune' and install prereq.packages before
1075 any repo configuration, using list of requires in map.jinja.
1076
1077
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001078Disabling any prerequisite packages installation:
1079
azvyagintsevff089d22018-07-27 16:52:34 +02001080You can simply drop any package pre-installation (before system.linux.repo
1081will be processed) via cluster lvl:
1082
1083.. code-block:: yaml
1084
1085 linux:
1086 system:
1087 pkgs: ~
1088
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001089Package manager proxy global setup:
Petr Michalec10462bb2017-03-23 19:18:08 +01001090
1091.. code-block:: yaml
1092
1093 linux:
1094 system:
1095 ...
1096 repo:
1097 apt-mk:
1098 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1099 ...
1100 proxy:
1101 pkg:
1102 enabled: true
1103 ftp: ftp://ftp-proxy-for-apt.host.local:2121
1104 ...
1105 # NOTE: Global defaults for any other componet that configure proxy on the system.
1106 # If your environment has just one simple proxy, set it on linux:system:proxy.
1107 #
1108 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
1109 # as for https and http
1110 ftp: ftp://proxy.host.local:2121
1111 http: http://proxy.host.local:3142
1112 https: https://proxy.host.local:3143
1113
1114Package manager proxy setup per repository:
1115
1116.. code-block:: yaml
1117
1118 linux:
1119 system:
1120 ...
1121 repo:
1122 debian:
1123 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1124 ...
1125 apt-mk:
1126 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1127 # per repository proxy
1128 proxy:
1129 enabled: true
1130 http: http://maas-01:8080
1131 https: http://maas-01:8080
1132 ...
1133 proxy:
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001134 # package manager fallback defaults
Petr Michalec10462bb2017-03-23 19:18:08 +01001135 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
1136 pkg:
1137 enabled: true
1138 ftp: ftp://proxy.host.local:2121
1139 #http: http://proxy.host.local:3142
1140 #https: https://proxy.host.local:3143
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001141 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001142 # global system fallback system defaults
1143 ftp: ftp://proxy.host.local:2121
1144 http: http://proxy.host.local:3142
1145 https: https://proxy.host.local:3143
1146
Ivan Berezovskiycfd58a22019-06-25 20:15:51 +04001147
1148Add secured apt repository:
1149
1150.. code-block:: yaml
1151
1152 linux:
1153 system:
1154 ...
1155 repo:
1156 test:
1157 secure: true
1158 url: example.org/ubuntu
1159 arch: deb
1160 protocol: http
1161 user: foo
1162 password: bar
1163 distribution: stable
1164 component: main
1165
1166Add multiply secured apt repositories with same credentials:
1167
1168.. code-block:: yaml
1169
1170 linux:
1171 system:
1172 ...
1173 common_repo_secured:
1174 arch: deb
1175 protocol: http
1176 user: foo
1177 password: bar
1178 distribution: stable
1179 component: main
1180 repo:
1181 test1:
1182 secure: true
1183 url: example1.org/ubuntu
1184 test2:
1185 secure: true
1186 url: example2.org/ubuntu
1187
Jiri Broulik34a29b42017-04-25 14:42:54 +02001188Remove all repositories:
1189
1190.. code-block:: yaml
1191
1192 linux:
1193 system:
1194 purge_repos: true
1195
azvyagintsevff089d22018-07-27 16:52:34 +02001196Refresh repositories metada, after configuration:
1197
1198.. code-block:: yaml
1199
1200 linux:
1201 system:
1202 refresh_repos_meta: true
1203
Filip Pytlounc512e6c2017-11-22 14:28:10 +01001204Setup custom apt config options:
1205
1206.. code-block:: yaml
1207
1208 linux:
1209 system:
1210 apt:
1211 config:
1212 compression-workaround:
1213 "Acquire::CompressionTypes::Order": "gz"
1214 docker-clean:
1215 "DPkg::Post-Invoke":
1216 - "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"
1217 "APT::Update::Post-Invoke":
1218 - "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 +02001219
Petr Michalec10462bb2017-03-23 19:18:08 +01001220RC
1221~~
1222
Jakub Pavlik78859382016-01-21 11:26:39 +01001223rc.local example
1224
1225.. code-block:: yaml
1226
1227 linux:
1228 system:
1229 rc:
1230 local: |
1231 #!/bin/sh -e
1232 #
1233 # rc.local
1234 #
1235 # This script is executed at the end of each multiuser runlevel.
1236 # Make sure that the script will "exit 0" on success or any other
1237 # value on error.
1238 #
1239 # In order to enable or disable this script just change the execution
1240 # bits.
1241 #
1242 # By default this script does nothing.
1243 exit 0
1244
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001245Prompt
1246~~~~~~
1247
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001248Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``.
1249Every user can have different prompt:
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001250
1251.. code-block:: yaml
1252
1253 linux:
1254 system:
1255 prompt:
1256 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\\]
1257 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
1258
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001259On Debian systems, to set prompt system-wide, it's necessary to
1260remove setting PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc``,
1261which comes from ``/etc/skel/.bashrc``. This formula will do
1262this automatically, but will not touch existing user's
1263``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +01001264
Filip Pytlouneef11c12016-03-25 11:00:23 +01001265Bash
1266~~~~
1267
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001268Fix bash configuration to preserve history across sessions
1269like ZSH does by default:
Filip Pytlouneef11c12016-03-25 11:00:23 +01001270
1271.. code-block:: yaml
1272
1273 linux:
1274 system:
1275 bash:
1276 preserve_history: true
1277
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001278Login banner message
1279~~~~~~~~~~~~~~~~~~~~
1280
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001281``/etc/issue`` is a text file which contains a message or system
1282identification to be printed before the login prompt. It may contain
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001283various @char and \char sequences, if supported by the getty-type
1284program employed on the system.
1285
1286Setting logon banner message is easy:
1287
1288.. code-block:: yaml
1289
1290 liunx:
1291 system:
1292 banner:
1293 enabled: true
1294 contents: |
1295 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1296
1297 You must have explicit, authorized permission to access or configure this
1298 device. Unauthorized attempts and actions to access or use this system may
1299 result in civil and/or criminal penalties.
1300 All activities performed on this system are logged and monitored.
1301
Filip Pytloune874dfb2016-01-22 16:57:34 +01001302Message of the day
1303~~~~~~~~~~~~~~~~~~
1304
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001305``pam_motd`` from package ``libpam-modules`` is used for dynamic
1306messages of the day. Setting custom ``motd`` will clean up existing ones.
Filip Pytloune874dfb2016-01-22 16:57:34 +01001307
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001308Setting static ``motd`` will replace existing ``/etc/motd`` and remove
1309scripts from ``/etc/update-motd.d``.
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001310
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001311Setting static ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001312
1313.. code-block:: yaml
1314
1315 linux:
1316 system:
1317 motd: |
1318 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1319
1320 You must have explicit, authorized permission to access or configure this
1321 device. Unauthorized attempts and actions to access or use this system may
1322 result in civil and/or criminal penalties.
1323 All activities performed on this system are logged and monitored.
1324
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001325Setting dynamic ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001326
Filip Pytloune874dfb2016-01-22 16:57:34 +01001327.. code-block:: yaml
1328
1329 linux:
1330 system:
1331 motd:
1332 - release: |
1333 #!/bin/sh
1334 [ -r /etc/lsb-release ] && . /etc/lsb-release
1335
1336 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
1337 # Fall back to using the very slow lsb_release utility
1338 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
1339 fi
1340
1341 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
1342 - warning: |
1343 #!/bin/sh
1344 printf "This is [company name] network.\n"
1345 printf "Unauthorized access strictly prohibited.\n"
1346
Marek Celoud713e9072017-05-18 15:20:25 +02001347Services
1348~~~~~~~~
1349
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001350Stop and disable the ``linux`` service:
Marek Celoud713e9072017-05-18 15:20:25 +02001351
1352.. code-block:: yaml
1353
1354 linux:
1355 system:
1356 service:
1357 apt-daily.timer:
1358 status: dead
1359
Dzmitry Stremkouski70d09782018-11-30 16:04:59 +01001360Override systemd service unit:
1361
1362.. code-block:: yaml
1363
1364 parameters:
1365
1366 linux:
1367 system:
1368 service:
1369 tgt:
1370 name: tgt
1371 status: running
1372 enabled: True
1373 override:
1374 50:
1375 target: tgt.service.d
1376 name: bind
1377 content: |
1378 [Service]
1379 ExecStart=
1380 ExecStart=/usr/sbin/tgtd -f --iscsi portal=${_param:single_address}:3260
1381
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001382Possible statuses are ``dead`` (disable service by default), ``running``
1383(enable service by default), ``enabled``, ``disabled``:
Marek Celoud713e9072017-05-18 15:20:25 +02001384
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001385Linux with the ``atop`` service:
Serhiy Ovsianikov67bd56a2017-08-11 15:56:01 +03001386
1387.. code-block:: yaml
1388
1389 linux:
1390 system:
1391 atop:
1392 enabled: true
1393 interval: 20
1394 logpath: "/var/log/atop"
1395 outfile: "/var/log/atop/daily.log"
1396
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001397Linux with the ``mcelog`` service:
Oleksii Chupryn144432b2018-05-22 10:34:48 +03001398
1399.. code-block:: yaml
1400
1401 linux:
1402 system:
1403 mcelog:
1404 enabled: true
1405 logging:
1406 syslog: true
1407 syslog_error: true
1408
Filip Pytloun2f70b492016-02-19 15:55:25 +01001409RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +01001410^^^^^^^^^^^^^
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001411Currently, ``update-motd`` is not available
1412for RHEL. So there is no native support for dynamic ``motd``.
1413You can still set a static one, with a different pillar structure:
Filip Pytloun2f70b492016-02-19 15:55:25 +01001414
1415.. code-block:: yaml
1416
1417 linux:
1418 system:
1419 motd: |
1420 This is [company name] network.
1421 Unauthorized access strictly prohibited.
1422
Filip Pytloun8296bb92016-02-19 18:42:09 +01001423Haveged
1424~~~~~~~
1425
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001426If you are running headless server and are low on entropy,
1427you may set up Haveged:
Filip Pytloun8296bb92016-02-19 18:42:09 +01001428
1429.. code-block:: yaml
1430
1431 linux:
1432 system:
1433 haveged:
1434 enabled: true
1435
Filip Pytlounf5383a42015-10-06 16:28:32 +02001436Linux network
1437-------------
1438
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001439Linux with network manager:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001440
1441.. code-block:: yaml
1442
1443 linux:
1444 network:
1445 enabled: true
1446 network_manager: true
1447
Dzmitry Stremkouski00cdbe62018-10-31 16:41:54 +01001448Execute linux.network.interface state without ifupdown activity:
1449
1450.. code-block:: bash
1451
1452 salt-call linux.network.interface pillar='{"linux":{"network":{"noifupdown":True}}}'
1453
1454
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001455Linux with default static network interfaces, default gateway
1456interface and DNS servers:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001457
1458.. code-block:: yaml
1459
1460 linux:
1461 network:
1462 enabled: true
1463 interface:
1464 eth0:
1465 enabled: true
1466 type: eth
1467 address: 192.168.0.102
1468 netmask: 255.255.255.0
1469 gateway: 192.168.0.1
1470 name_servers:
1471 - 8.8.8.8
1472 - 8.8.4.4
1473 mtu: 1500
1474
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001475Linux with bonded interfaces and disabled ``NetworkManager``:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001476
1477.. code-block:: yaml
1478
1479 linux:
1480 network:
1481 enabled: true
1482 interface:
1483 eth0:
1484 type: eth
1485 ...
1486 eth1:
1487 type: eth
1488 ...
1489 bond0:
1490 enabled: true
1491 type: bond
1492 address: 192.168.0.102
1493 netmask: 255.255.255.0
1494 mtu: 1500
1495 use_in:
1496 - interface: ${linux:interface:eth0}
1497 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +01001498 network_manager:
1499 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001500
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001501Linux with VLAN ``interface_params``:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001502
1503.. code-block:: yaml
1504
1505 linux:
1506 network:
1507 enabled: true
1508 interface:
1509 vlan69:
1510 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +01001511 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001512 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001513
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001514Linux with wireless interface parameters:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001515
1516.. code-block:: yaml
1517
1518 linux:
1519 network:
1520 enabled: true
1521 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001522 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001523 interface:
1524 wlan0:
1525 type: eth
1526 wireless:
1527 essid: example
1528 key: example_key
1529 security: wpa
1530 priority: 1
1531
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001532Linux networks with routes defined:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001533
1534.. code-block:: yaml
1535
1536 linux:
1537 network:
1538 enabled: true
1539 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001540 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001541 interface:
1542 eth0:
1543 type: eth
1544 route:
1545 default:
1546 address: 192.168.0.123
1547 netmask: 255.255.255.0
1548 gateway: 192.168.0.1
1549
ivce5011da2019-01-23 07:56:53 +03001550Linux networks with implicit routes definition:
1551
1552- on node 1:
1553
1554.. code-block:: yaml
1555
1556 linux:
1557 network:
1558 enabled: true
1559 router:
1560 ctl:
1561 # router that connects 10.0.1.0/24 and 10.0.2.0/24
1562 addresses:
1563 - 10.0.1.1/24
1564 - 10.0.2.1/24
1565 test:
1566 addresses:
1567 - 10.0.1.2/24
1568 networks:
1569 - 10.100.0.0/16
1570 interface:
1571 ctl:
1572 name: eth0
1573 address: 10.0.1.101
1574 netmask: 255.255.255.0
1575
1576- on node2:
1577
1578.. code-block:: yaml
1579
1580 linux:
1581 network:
1582 enabled: true
1583 router:
1584 ctl:
1585 # equivalent of node1's ctl router with 'implicit_routes = false'
1586 options:
1587 implicit_routes: false
1588 addresses:
1589 - 10.0.1.1/24
1590 - 10.0.2.1/24
1591 networks:
1592 - 10.0.1.0/24
1593 - 10.0.2.0/24
1594 interface:
1595 ctl:
1596 name: eth0
1597 address: 10.0.2.101
1598 netmask: 255.255.255.0
1599
1600
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001601Native Linux Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001602
1603.. code-block:: yaml
1604
1605 linux:
1606 network:
1607 interface:
1608 eth1:
1609 enabled: true
1610 type: eth
1611 proto: manual
1612 up_cmds:
1613 - ip address add 0/0 dev $IFACE
1614 - ip link set $IFACE up
1615 down_cmds:
1616 - ip link set $IFACE down
1617 br-ex:
1618 enabled: true
1619 type: bridge
1620 address: ${linux:network:host:public_local:address}
1621 netmask: 255.255.255.0
1622 use_interfaces:
1623 - eth1
1624
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001625Open vSwitch Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001626
1627.. code-block:: yaml
1628
1629 linux:
1630 network:
1631 bridge: openvswitch
1632 interface:
1633 eth1:
1634 enabled: true
1635 type: eth
1636 proto: manual
1637 up_cmds:
1638 - ip address add 0/0 dev $IFACE
1639 - ip link set $IFACE up
1640 down_cmds:
1641 - ip link set $IFACE down
1642 br-ex:
1643 enabled: true
1644 type: bridge
1645 address: ${linux:network:host:public_local:address}
1646 netmask: 255.255.255.0
1647 use_interfaces:
1648 - eth1
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001649 br-prv:
1650 enabled: true
1651 type: ovs_bridge
1652 mtu: 65000
1653 br-ens7:
1654 enabled: true
1655 name: br-ens7
1656 type: ovs_bridge
1657 proto: manual
1658 mtu: 9000
1659 use_interfaces:
1660 - ens7
1661 patch-br-ens7-br-prv:
1662 enabled: true
1663 name: ens7-prv
1664 ovs_type: ovs_port
1665 type: ovs_port
1666 bridge: br-ens7
1667 port_type: patch
1668 peer: prv-ens7
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001669 tag: 109 # [] to unset a tag
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001670 mtu: 65000
1671 patch-br-prv-br-ens7:
1672 enabled: true
1673 name: prv-ens7
1674 bridge: br-prv
1675 ovs_type: ovs_port
1676 type: ovs_port
1677 port_type: patch
1678 peer: ens7-prv
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001679 tag: 109
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001680 mtu: 65000
1681 ens7:
1682 enabled: true
1683 name: ens7
1684 proto: manual
1685 ovs_port_type: OVSPort
1686 type: ovs_port
1687 ovs_bridge: br-ens7
1688 bridge: br-ens7
Oleg Gelbukh36f01072019-07-01 15:26:16 -07001689 ens6:
1690 enabled: true
1691 proto: manual
1692 type: eth
1693 ovs_bridge: br-ctl
1694 br-ctl:
1695 enabled: true
1696 type: ovs_bridge
1697 internal-br-ctl-port:
1698 enabled: true
1699 proto: static
1700 address: 172.172.0.10
1701 netmask: 255.255.0.0
1702 name_servers:
1703 - 8.8.8.8
1704 - 172.172.172.172
1705 name: port-br-ctl
1706 bridge: br-ctl
1707 ovs_type: ovs_port
1708 type: ovs_port
1709 port_type: internal
1710 mtu: 65000
Filip Pytlounf5383a42015-10-06 16:28:32 +02001711
Petr Jediný8f8ae542017-07-13 16:19:12 +02001712Debian manual proto interfaces
1713
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001714When you are changing interface proto from static in up state
1715to manual, you may need to flush ip addresses. For example,
1716if you want to use the interface and the ip on the bridge.
1717This can be done by setting the ``ipflush_onchange`` to true.
Petr Jediný8f8ae542017-07-13 16:19:12 +02001718
1719.. code-block:: yaml
1720
1721 linux:
1722 network:
1723 interface:
1724 eth1:
1725 enabled: true
1726 type: eth
1727 proto: manual
1728 mtu: 9100
1729 ipflush_onchange: true
1730
Jiri Broulik1a191e32018-01-15 15:54:21 +01001731Debian static proto interfaces
1732
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001733When you are changing interface proto from dhcp in up state to
1734static, you may need to flush ip addresses and restart interface
1735to assign ip address from a managed file. For example, if you wantto
1736use the interface and the ip on the bridge. This can be done by
1737setting the ``ipflush_onchange`` with combination ``restart_on_ipflush``
1738param set to true.
Jiri Broulik1a191e32018-01-15 15:54:21 +01001739
1740.. code-block:: yaml
1741
1742 linux:
1743 network:
1744 interface:
1745 eth1:
1746 enabled: true
1747 type: eth
1748 proto: static
1749 address: 10.1.0.22
1750 netmask: 255.255.255.0
1751 ipflush_onchange: true
1752 restart_on_ipflush: true
Petr Jediný8f8ae542017-07-13 16:19:12 +02001753
Petr Jedinýd577cb52017-06-28 20:17:49 +02001754Concatinating and removing interface files
1755
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001756Debian based distributions have ``/etc/network/interfaces.d/``
1757directory, where you can store configuration of network
1758interfaces in separate files. You can concatinate the files
1759to the defined destination when needed, this operation removes
1760the file from the ``/etc/network/interfaces.d/``. If you just need
1761to remove iface files, you can use the ``remove_iface_files`` key.
Petr Jedinýd577cb52017-06-28 20:17:49 +02001762
1763.. code-block:: yaml
1764
1765 linux:
1766 network:
1767 concat_iface_files:
1768 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
1769 dst: '/etc/network/interfaces'
1770 remove_iface_files:
1771 - '/etc/network/interfaces.d/90-custom.cfg'
1772
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001773Configure DHCP client
Petr Jedinýd577cb52017-06-28 20:17:49 +02001774
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001775None of the keys is mandatory, include only those you really need.
1776For full list of available options under send, supersede, prepend,
1777append refer to dhcp-options(5).
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001778
1779.. code-block:: yaml
1780
1781 linux:
1782 network:
1783 dhclient:
1784 enabled: true
1785 backoff_cutoff: 15
1786 initial_interval: 10
1787 reboot: 10
1788 retry: 60
1789 select_timeout: 0
1790 timeout: 120
1791 send:
1792 - option: host-name
1793 declaration: "= gethostname()"
1794 supersede:
1795 - option: host-name
1796 declaration: "spaceship"
1797 - option: domain-name
1798 declaration: "domain.home"
1799 #- option: arp-cache-timeout
1800 # declaration: 20
1801 prepend:
1802 - option: domain-name-servers
1803 declaration:
1804 - 8.8.8.8
1805 - 8.8.4.4
1806 - option: domain-search
1807 declaration:
1808 - example.com
1809 - eng.example.com
1810 #append:
1811 #- option: domain-name-servers
1812 # declaration: 127.0.0.1
1813 # ip or subnet to reject dhcp offer from
1814 reject:
1815 - 192.33.137.209
1816 - 10.0.2.0/24
1817 request:
1818 - subnet-mask
1819 - broadcast-address
1820 - time-offset
1821 - routers
1822 - domain-name
1823 - domain-name-servers
1824 - domain-search
1825 - host-name
1826 - dhcp6.name-servers
1827 - dhcp6.domain-search
1828 - dhcp6.fqdn
1829 - dhcp6.sntp-servers
1830 - netbios-name-servers
1831 - netbios-scope
1832 - interface-mtu
1833 - rfc3442-classless-static-routes
1834 - ntp-servers
1835 require:
1836 - subnet-mask
1837 - domain-name-servers
1838 # if per interface configuration required add below
1839 interface:
1840 ens2:
1841 initial_interval: 11
1842 reject:
1843 - 192.33.137.210
1844 ens3:
1845 initial_interval: 12
1846 reject:
1847 - 192.33.137.211
1848
Petr Michaleceb14b552017-06-01 10:27:05 +02001849Linux network systemd settings:
1850
1851.. code-block:: yaml
1852
1853 linux:
1854 network:
1855 ...
1856 systemd:
1857 link:
1858 10-iface-dmz:
1859 Match:
1860 MACAddress: c8:5b:67:fa:1a:af
1861 OriginalName: eth0
1862 Link:
1863 Name: dmz0
1864 netdev:
1865 20-bridge-dmz:
1866 match:
1867 name: dmz0
1868 network:
1869 mescription: bridge
1870 bridge: br-dmz0
1871 network:
1872 # works with lowercase, keys are by default capitalized
1873 40-dhcp:
1874 match:
1875 name: '*'
1876 network:
1877 DHCP: yes
1878
Petr Michalec10462bb2017-03-23 19:18:08 +01001879Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +01001880
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001881Use ``/etc/environment`` for static system wide variable assignment
1882after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001883
1884.. code-block:: yaml
1885
1886 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +01001887 system:
1888 env:
1889 BOB_VARIABLE: Alice
1890 ...
1891 BOB_PATH:
1892 - /srv/alice/bin
1893 - /srv/bob/bin
1894 ...
1895 ftp_proxy: none
1896 http_proxy: http://global-http-proxy.host.local:8080
1897 https_proxy: ${linux:system:proxy:https}
1898 no_proxy:
1899 - 192.168.0.80
1900 - 192.168.1.80
1901 - .domain.com
1902 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001903 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001904 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001905 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001906 ftp: ftp://proxy.host.local:2121
1907 http: http://proxy.host.local:3142
1908 https: https://proxy.host.local:3143
1909 noproxy:
1910 - .domain.com
1911 - .local
1912
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001913Configure the ``profile.d`` scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001914
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001915The ``profile.d`` scripts are being sourced during ``.sh`` execution
1916and support variable expansion in opposite to /etc/environment global
1917settings in ``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001918
1919.. code-block:: yaml
1920
1921 linux:
1922 system:
1923 profile:
1924 locales: |
1925 export LANG=C
1926 export LC_ALL=C
1927 ...
1928 vi_flavors.sh: |
1929 export PAGER=view
1930 export EDITOR=vim
1931 alias vi=vim
1932 shell_locales.sh: |
1933 export LANG=en_US
1934 export LC_ALL=en_US.UTF-8
1935 shell_proxies.sh: |
1936 export FTP_PROXY=ftp://127.0.3.3:2121
1937 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001938
Dmitry Teselkina0d31d12018-09-04 14:43:09 +03001939
1940Configure login.defs parameters
1941-------------------------------
1942
1943.. code-block:: yaml
1944
1945 linux:
1946 system:
1947 login_defs:
1948 <opt_name>:
1949 enabled: true
1950 value: <opt_value>
1951
1952<opt_name> is a configurational option defined in 'man login.defs'.
1953<opt_name> is case sensitive, should be UPPERCASE only!
1954
1955
Filip Pytlounf5383a42015-10-06 16:28:32 +02001956Linux with hosts
1957
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001958Parameter ``purge_hosts`` will enforce whole ``/etc/hosts file``,
1959removing entries that are not defined in model except defaults
1960for both IPv4 and IPv6 localhost and hostname as well as FQDN.
Ales Komarek417e8c52017-08-25 15:10:29 +02001961
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001962We recommend using this option to verify that ``/etc/hosts``
1963is always in a clean state. However it is not enabled by default
1964for security reasons.
Filip Pytloun86506fe2017-01-26 14:36:16 +01001965
Filip Pytlounf5383a42015-10-06 16:28:32 +02001966.. code-block:: yaml
1967
1968 linux:
1969 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001970 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001971 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001972 # No need to define this one if purge_hosts is true
1973 hostname:
1974 address: 127.0.1.1
1975 names:
1976 - ${linux:network:fqdn}
1977 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001978 node1:
1979 address: 192.168.10.200
1980 names:
1981 - node2.domain.com
1982 - service2.domain.com
1983 node2:
1984 address: 192.168.10.201
1985 names:
1986 - node2.domain.com
1987 - service2.domain.com
1988
Ales Komarek417e8c52017-08-25 15:10:29 +02001989Linux with hosts collected from mine
1990
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001991All DNS records defined within infrastrucuture
1992are passed to the local hosts records or any DNS server. Only
1993hosts with the ``grain`` parameter set to ``true`` will be propagated
1994to the mine.
Ales Komarek417e8c52017-08-25 15:10:29 +02001995
1996.. code-block:: yaml
1997
1998 linux:
1999 network:
2000 purge_hosts: true
2001 mine_dns_records: true
2002 host:
2003 node1:
2004 address: 192.168.10.200
2005 grain: true
2006 names:
2007 - node2.domain.com
2008 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01002009
Michael Polenchukc80ddd42019-01-15 18:47:48 +04002010Set up ``resolvconf's basic resolver info``, e.g. nameservers, search/domain and options:
Filip Pytlounde9bea52016-01-11 15:39:10 +01002011
2012.. code-block:: yaml
2013
2014 linux:
2015 network:
2016 resolv:
2017 dns:
Michael Polenchukc80ddd42019-01-15 18:47:48 +04002018 - 8.8.4.4
2019 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01002020 domain: my.example.com
2021 search:
Michael Polenchukc80ddd42019-01-15 18:47:48 +04002022 - my.example.com
2023 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01002024 options:
Michael Polenchukc80ddd42019-01-15 18:47:48 +04002025 - ndots:5
2026 - timeout:2
2027 - attempts:2
Filip Pytlounde9bea52016-01-11 15:39:10 +01002028
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002029Set up custom TX queue length for tap interfaces:
Andrii Petrenko735761d2017-03-21 17:17:35 -07002030
2031.. code-block:: yaml
2032
2033 linux:
2034 network:
2035 tap_custom_txqueuelen: 10000
2036
Michael Polenchukc37bd4a2019-04-22 15:20:03 +04002037Auto repair/re-attach libvirt's vnet interfaces:
2038
2039.. code-block:: yaml
2040
2041 linux:
2042 network:
2043 libvirt_vnet_repair: true
2044
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002045DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002046
2047**DPDK OVS NIC**
2048
2049.. code-block:: yaml
2050
2051 linux:
2052 network:
2053 bridge: openvswitch
2054 dpdk:
2055 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04002056 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002057 openvswitch:
2058 pmd_cpu_mask: "0x6"
2059 dpdk_socket_mem: "1024,1024"
2060 dpdk_lcore_mask: "0x400"
2061 memory_channels: 2
2062 interface:
2063 dpkd0:
2064 name: ${_param:dpdk_nic}
2065 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002066 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002067 enabled: true
2068 type: dpdk_ovs_port
2069 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002070 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002071 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01002072 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002073 br-prv:
2074 enabled: true
2075 type: dpdk_ovs_bridge
2076
2077**DPDK OVS Bond**
2078
2079.. code-block:: yaml
2080
2081 linux:
2082 network:
2083 bridge: openvswitch
2084 dpdk:
2085 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04002086 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002087 openvswitch:
2088 pmd_cpu_mask: "0x6"
2089 dpdk_socket_mem: "1024,1024"
2090 dpdk_lcore_mask: "0x400"
2091 memory_channels: 2
2092 interface:
2093 dpdk_second_nic:
2094 name: ${_param:primary_second_nic}
2095 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002096 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002097 bond: dpdkbond0
2098 enabled: true
2099 type: dpdk_ovs_port
2100 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002101 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002102 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002103 dpdk_first_nic:
2104 name: ${_param:primary_first_nic}
2105 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002106 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002107 bond: dpdkbond0
2108 enabled: true
2109 type: dpdk_ovs_port
2110 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002111 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002112 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002113 dpdkbond0:
2114 enabled: true
2115 bridge: br-prv
2116 type: dpdk_ovs_bond
2117 mode: active-backup
2118 br-prv:
2119 enabled: true
2120 type: dpdk_ovs_bridge
2121
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01002122**DPDK OVS LACP Bond with vlan tag**
2123
2124.. code-block:: yaml
2125
2126 linux:
2127 network:
2128 bridge: openvswitch
2129 dpdk:
2130 enabled: true
2131 driver: uio
2132 openvswitch:
2133 pmd_cpu_mask: "0x6"
2134 dpdk_socket_mem: "1024,1024"
2135 dpdk_lcore_mask: "0x400"
2136 memory_channels: "2"
2137 interface:
2138 eth3:
2139 enabled: true
2140 type: eth
2141 proto: manual
2142 name: ${_param:tenant_first_nic}
2143 eth4:
2144 enabled: true
2145 type: eth
2146 proto: manual
2147 name: ${_param:tenant_second_nic}
2148 dpdk0:
2149 name: ${_param:tenant_first_nic}
2150 pci: "0000:81:00.0"
2151 driver: igb_uio
2152 bond: bond1
2153 enabled: true
2154 type: dpdk_ovs_port
2155 n_rxq: 2
2156 dpdk1:
2157 name: ${_param:tenant_second_nic}
2158 pci: "0000:81:00.1"
2159 driver: igb_uio
2160 bond: bond1
2161 enabled: true
2162 type: dpdk_ovs_port
2163 n_rxq: 2
2164 bond1:
2165 enabled: true
2166 bridge: br-prv
2167 type: dpdk_ovs_bond
2168 mode: balance-slb
2169 br-prv:
2170 enabled: true
2171 type: dpdk_ovs_bridge
2172 tag: ${_param:tenant_vlan}
2173 address: ${_param:tenant_address}
2174 netmask: ${_param:tenant_network_netmask}
2175
Jakub Pavlikaa759062017-03-13 15:57:26 +01002176**DPDK OVS bridge for VXLAN**
2177
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002178If VXLAN is used as tenant segmentation, IP address must
2179be set on ``br-prv``.
Jakub Pavlikaa759062017-03-13 15:57:26 +01002180
2181.. code-block:: yaml
2182
2183 linux:
2184 network:
2185 ...
2186 interface:
2187 br-prv:
2188 enabled: true
2189 type: dpdk_ovs_bridge
2190 address: 192.168.50.0
2191 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04002192 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01002193 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002194
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02002195**DPDK OVS bridge with Linux network interface**
2196
2197.. code-block:: yaml
2198
2199 linux:
2200 network:
2201 ...
2202 interface:
2203 eth0:
2204 type: eth
2205 ovs_bridge: br-prv
2206 ...
2207 br-prv:
2208 enabled: true
2209 type: dpdk_ovs_bridge
2210 ...
2211
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002212Linux storage
2213-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02002214
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002215Linux with mounted Samba:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002216
2217.. code-block:: yaml
2218
2219 linux:
2220 storage:
2221 enabled: true
2222 mount:
2223 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01002224 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02002225 - path: /media/myuser/public/
2226 - device: //192.168.0.1/storage
2227 - file_system: cifs
2228 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
2229
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002230NFS mount:
Jiri Broulikb017f932017-03-31 13:55:36 +02002231
2232.. code-block:: yaml
2233
2234 linux:
2235 storage:
2236 enabled: true
2237 mount:
2238 nfs_glance:
2239 enabled: true
2240 path: /var/lib/glance/images
2241 device: 172.16.10.110:/var/nfs/glance
2242 file_system: nfs
2243 opts: rw,sync
2244
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002245File swap configuration:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002246
2247.. code-block:: yaml
2248
2249 linux:
2250 storage:
2251 enabled: true
2252 swap:
2253 file:
2254 enabled: true
2255 engine: file
2256 device: /swapfile
2257 size: 1024
2258
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002259Partition swap configuration:
Lachlan Evenson30676512016-01-22 15:43:28 -08002260
2261.. code-block:: yaml
2262
2263 linux:
2264 storage:
2265 enabled: true
2266 swap:
2267 partition:
2268 enabled: true
2269 engine: partition
2270 device: /dev/vg0/swap
2271
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002272LVM group ``vg1`` with one device and ``data`` volume mounted
2273into ``/mnt/data``.
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002274
2275.. code-block:: yaml
2276
2277 parameters:
2278 linux:
2279 storage:
2280 mount:
2281 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01002282 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002283 device: /dev/vg1/data
2284 file_system: ext4
2285 path: /mnt/data
2286 lvm:
2287 vg1:
2288 enabled: true
2289 devices:
2290 - /dev/sdb
2291 volume:
2292 data:
2293 size: 40G
2294 mount: ${linux:storage:mount:data}
root3387f332019-01-11 08:55:32 +00002295 # When set they will take precedence over filters aget from volume groups.
2296 lvm_filters:
2297 10:
2298 enabled: True
2299 value: "a|loop|"
2300 20:
2301 enabled: True
2302 value: "r|/dev/hdc|"
2303 30:
2304 enabled: True
2305 value: "a|/dev/ide|"
2306 40:
2307 enabled: True
2308 value: "r|.*|"
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002309
Jakub Pavlik4f742142017-08-08 15:05:50 +02002310Create partitions on disk. Specify size in MB. It expects empty
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002311disk without any existing partitions.
2312Set ``startsector=1`` if you want to start partitions from ``2048``.
Jakub Pavlik4f742142017-08-08 15:05:50 +02002313
2314.. code-block:: yaml
2315
2316 linux:
2317 storage:
2318 disk:
2319 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01002320 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02002321 name: /dev/loop1
2322 type: gpt
2323 partitions:
2324 - size: 200 #size in MB
2325 type: fat32
2326 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02002327 mkfs: True
2328 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02002329 /dev/vda1:
2330 partitions:
2331 - size: 5
2332 type: ext2
2333 - size: 10
2334 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02002335
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002336Multipath with Fujitsu Eternus DXL:
Ales Komareka634f4b2016-10-02 13:11:04 +02002337
2338.. code-block:: yaml
2339
2340 parameters:
2341 linux:
2342 storage:
2343 multipath:
2344 enabled: true
2345 blacklist_devices:
2346 - /dev/sda
2347 - /dev/sdb
2348 backends:
2349 - fujitsu_eternus_dxl
2350
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002351Multipath with Hitachi VSP 1000:
Ales Komareka634f4b2016-10-02 13:11:04 +02002352
2353.. code-block:: yaml
2354
2355 parameters:
2356 linux:
2357 storage:
2358 multipath:
2359 enabled: true
2360 blacklist_devices:
2361 - /dev/sda
2362 - /dev/sdb
2363 backends:
2364 - hitachi_vsp1000
2365
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002366Multipath with IBM Storwize:
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 - ibm_storwize
2380
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002381Multipath with multiple backends:
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 - /dev/sdc
2394 - /dev/sdd
2395 backends:
2396 - ibm_storwize
2397 - fujitsu_eternus_dxl
2398 - hitachi_vsp1000
2399
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002400PAM LDAP integration:
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002401
2402.. code-block:: yaml
2403
2404 parameters:
2405 linux:
2406 system:
2407 auth:
2408 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02002409 mkhomedir:
2410 enabled: true
2411 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002412 ldap:
2413 enabled: true
2414 binddn: cn=bind,ou=service_users,dc=example,dc=com
2415 bindpw: secret
2416 uri: ldap://127.0.0.1
2417 base: ou=users,dc=example,dc=com
2418 ldap_version: 3
2419 pagesize: 65536
2420 referrals: off
2421 filter:
2422 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2423 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2424 group: (&(objectClass=group)(gidNumber=*))
2425
Gleb Galkin93b9ae92018-10-18 13:57:30 +03002426PAM duo 2FA integration
2427
2428.. code-block:: yaml
2429
2430 parameters:
2431 linux:
2432 system:
2433 auth:
2434 enabled: true
2435 duo:
2436 enabled: true
2437 duo_host: localhost
2438 duo_ikey: DUO-INTEGRATION-KEY
2439 duo_skey: DUO-SECRET-KEY
2440
2441duo package version may be specified (optional)
2442
2443.. code-block:: yaml
2444
2445 linux:
2446 system:
2447 package:
2448 duo-unix:
2449 version: 1.10.1-0
2450
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002451Disabled multipath (the default setup):
Ales Komareka634f4b2016-10-02 13:11:04 +02002452
2453.. code-block:: yaml
2454
2455 parameters:
2456 linux:
2457 storage:
2458 multipath:
2459 enabled: false
2460
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002461Linux with local loopback device:
Simon Pasquier375001e2017-01-26 13:22:33 +01002462
2463.. code-block:: yaml
2464
2465 linux:
2466 storage:
2467 loopback:
2468 disk1:
2469 file: /srv/disk1
2470 size: 50G
2471
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002472External config generation
2473--------------------------
2474
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002475You are able to use config support metadata between formulas
2476and only generate configuration files for external use, for example, Docker, and so on.
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002477
2478.. code-block:: yaml
2479
2480 parameters:
2481 linux:
2482 system:
2483 config:
2484 pillar:
2485 jenkins:
2486 master:
2487 home: /srv/volumes/jenkins
2488 approved_scripts:
2489 - method java.net.URL openConnection
2490 credentials:
2491 - type: username_password
2492 scope: global
2493 id: test
2494 desc: Testing credentials
2495 username: test
2496 password: test
2497
Vladimir Ereminccf28842017-04-10 23:52:10 +03002498Netconsole Remote Kernel Logging
2499--------------------------------
2500
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002501Netconsole logger can be configured for the configfs-enabled kernels
2502(``CONFIG_NETCONSOLE_DYNAMIC`` must be enabled). The configuration
2503applies both in runtime (if network is already configured),
2504and on-boot after an interface initialization.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002505
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002506.. note::
2507
2508 * Receiver can be located only on the same L3 domain
2509 (or you need to configure gateway MAC manually).
2510 * The Receiver MAC is detected only on configuration time.
2511 * Using broadcast MAC is not recommended.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002512
2513.. code-block:: yaml
2514
2515 parameters:
2516 linux:
2517 system:
2518 netconsole:
2519 enabled: true
2520 port: 514 (optional)
2521 loglevel: debug (optional)
2522 target:
2523 192.168.0.1:
2524 interface: bond0
2525 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02002526
Dzmitry Stremkouskid1a268b2018-10-03 16:36:04 +02002527Check network params on the environment
2528---------------------------------------
2529
2530Grab nics and nics states
2531
2532.. code-block:: bash
2533
2534 salt osd001\* net_checks.get_nics
2535
2536**Example of system output:**
2537
2538.. code-block:: bash
2539
2540 osd001.domain.com:
2541 |_
2542 - bond0
2543 - None
2544 - 1e:c8:64:42:23:b9
2545 - 0
2546 - 1500
2547 |_
2548 - bond1
2549 - None
2550 - 3c:fd:fe:27:3b:00
2551 - 1
2552 - 9100
2553 |_
2554 - fourty1
2555 - None
2556 - 3c:fd:fe:27:3b:00
2557 - 1
2558 - 9100
2559 |_
2560 - fourty2
2561 - None
2562 - 3c:fd:fe:27:3b:02
2563 - 1
2564 - 9100
2565
2566Grab 10G nics PCI addresses for hugepages setup
2567
2568.. code-block:: bash
2569
2570 salt cmp001\* net_checks.get_ten_pci
2571
2572**Example of system output:**
2573
2574.. code-block:: bash
2575
2576 cmp001.domain.com:
2577 |_
2578 - ten1
2579 - 0000:19:00.0
2580 |_
2581 - ten2
2582 - 0000:19:00.1
2583 |_
2584 - ten3
2585 - 0000:19:00.2
2586 |_
2587 - ten4
2588 - 0000:19:00.3
2589
2590Grab ip address for an interface
2591
2592.. code-block:: bash
2593
2594 salt cmp001\* net_checks.get_ip iface=one4
2595
2596**Example of system output:**
2597
2598.. code-block:: bash
2599
2600 cmp001.domain.com:
2601 10.200.177.101
2602
2603Grab ip addresses map
2604
2605.. code-block:: bash
2606
2607 salt-call net_checks.nodes_addresses
2608
2609**Example of system output:**
2610
2611.. code-block:: bash
2612
2613 local:
2614 |_
2615 - cid01.domain.com
2616 |_
2617 |_
2618 - pxe
2619 - 10.200.177.91
2620 |_
2621 - control
2622 - 10.200.178.91
2623 |_
2624 - cmn02.domain.com
2625 |_
2626 |_
2627 - storage_access
2628 - 10.200.181.67
2629 |_
2630 - pxe
2631 - 10.200.177.67
2632 |_
2633 - control
2634 - 10.200.178.67
2635 |_
2636 - cmp010.domain.com
2637 |_
2638 |_
2639 - pxe
2640 - 10.200.177.110
2641 |_
2642 - storage_access
2643 - 10.200.181.110
2644 |_
2645 - control
2646 - 10.200.178.110
2647 |_
2648 - vxlan
2649 - 10.200.179.110
2650
2651Verify full mesh connectivity
2652
2653.. code-block:: bash
2654
2655 salt-call net_checks.ping_check
2656
2657**Example of positive system output:**
2658
2659.. code-block:: bash
2660
2661 ['PASSED']
2662 [INFO ] ['PASSED']
2663 local:
2664 True
2665
2666**Example of system output in case of failure:**
2667
2668.. code-block:: bash
2669
2670 FAILED
2671 [ERROR ] FAILED
2672 ['control: 10.0.1.92 -> 10.0.1.224: Failed']
2673 ['control: 10.0.1.93 -> 10.0.1.224: Failed']
2674 ['control: 10.0.1.51 -> 10.0.1.224: Failed']
2675 ['control: 10.0.1.102 -> 10.0.1.224: Failed']
2676 ['control: 10.0.1.13 -> 10.0.1.224: Failed']
2677 ['control: 10.0.1.81 -> 10.0.1.224: Failed']
2678 local:
2679 False
2680
2681For this feature to work, please mark addresses with some role.
2682Otherwise 'default' role is assumed and mesh would consist of all
2683addresses on the environment.
2684
2685Mesh mark is needed only for interfaces which are enabled and have
2686ip address assigned.
2687
2688Checking dhcp pxe network meaningless, as it is used for salt
2689master vs minion communications, therefore treated as checked.
2690
2691.. code-block:: yaml
2692
2693 parameters:
2694 linux:
2695 network:
2696 interface:
2697 ens3:
2698 enabled: true
2699 type: eth
2700 proto: static
2701 address: ${_param:deploy_address}
2702 netmask: ${_param:deploy_network_netmask}
2703 gateway: ${_param:deploy_network_gateway}
2704 mesh: pxe
2705
2706Check pillars for ip address duplicates
2707
2708.. code-block:: bash
2709
2710 salt-call net_checks.verify_addresses
2711
2712**Example of positive system output:**
2713
2714.. code-block:: bash
2715
2716 ['PASSED']
2717 [INFO ] ['PASSED']
2718 local:
2719 True
2720
2721**Example of system output in case of failure:**
2722
2723.. code-block:: bash
2724
2725 FAILED. Duplicates found
2726 [ERROR ] FAILED. Duplicates found
2727 ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2728 [ERROR ] ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2729 local:
2730 False
2731
2732Generate csv report for the env
2733
2734.. code-block:: bash
2735
2736 salt -C 'kvm* or cmp* or osd*' net_checks.get_nics_csv \
2737 | grep '^\ ' | sed 's/\ *//g' | grep -Ev ^server \
2738 | sed '1 i\server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr'
2739
2740**Example of system output:**
2741
2742.. code-block:: bash
2743
2744 server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr
2745 cmp010.domain.com,bond0,None,b4:96:91:10:5b:3a,1,1500,,,,
2746 cmp010.domain.com,bond0.21,10.200.178.110,b4:96:91:10:5b:3a,1,1500,,,,
2747 cmp010.domain.com,bond0.22,10.200.179.110,b4:96:91:10:5b:3a,1,1500,,,,
2748 cmp010.domain.com,bond1,None,3c:fd:fe:34:ad:22,0,1500,,,,
2749 cmp010.domain.com,bond1.24,10.200.181.110,3c:fd:fe:34:ad:22,0,1500,,,,
2750 cmp010.domain.com,fourty5,None,3c:fd:fe:34:ad:20,0,9000,,,,
2751 cmp010.domain.com,fourty6,None,3c:fd:fe:34:ad:22,0,9000,,,,
2752 cmp010.domain.com,one1,None,b4:96:91:10:5b:38,0,1500,,,,
2753 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
2754 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
2755 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
2756 cmp011.domain.com,bond0,None,b4:96:91:13:6c:aa,1,1500,,,,
2757 cmp011.domain.com,bond0.21,10.200.178.111,b4:96:91:13:6c:aa,1,1500,,,,
2758 cmp011.domain.com,bond0.22,10.200.179.111,b4:96:91:13:6c:aa,1,1500,,,,
2759 ...
2760
Filip Pytlounf5383a42015-10-06 16:28:32 +02002761Usage
2762=====
2763
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002764Set MTU of the eth0 network interface to 1400:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002765
2766.. code-block:: bash
2767
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002768 ip link set dev eth0 mtu 1400
Filip Pytlounf5383a42015-10-06 16:28:32 +02002769
2770Read more
2771=========
2772
2773* https://www.archlinux.org/
2774* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu