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