blob: 611a1ee7c3c41fbb3acf333e9f53aa61f46967d2 [file] [log] [blame]
Aleš Komárek63572992017-04-11 13:16:44 +02001============
2Linux Fomula
3============
Filip Pytlounf5383a42015-10-06 16:28:32 +02004
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03005Linux Operating Systems:
Filip Pytlounf5383a42015-10-06 16:28:32 +02006
7* Ubuntu
8* CentOS
9* RedHat
10* Fedora
11* Arch
12
Aleš Komárek63572992017-04-11 13:16:44 +020013Sample Pillars
Filip Pytlounf5383a42015-10-06 16:28:32 +020014==============
15
Aleš Komárek63572992017-04-11 13:16:44 +020016Linux System
Filip Pytlounf5383a42015-10-06 16:28:32 +020017------------
18
19Basic Linux box
20
21.. code-block:: yaml
22
23 linux:
24 system:
25 enabled: true
26 name: 'node1'
27 domain: 'domain.com'
28 cluster: 'system'
29 environment: prod
30 timezone: 'Europe/Prague'
31 utc: true
32
azvyagintsev967af132017-06-12 12:25:24 +030033Linux with system users, some with password set:
OlgaGusarenko2828f5f2018-07-30 19:37:05 +030034
35.. warning:: If no ``password`` variable is passed,
36 any predifined password will be removed.
Filip Pytlounf5383a42015-10-06 16:28:32 +020037
38.. code-block:: yaml
39
40 linux:
41 system:
42 ...
43 user:
44 jdoe:
45 name: 'jdoe'
46 enabled: true
47 sudo: true
48 shell: /bin/bash
49 full_name: 'Jonh Doe'
50 home: '/home/jdoe'
Martin Polreich4fcd5c02018-07-16 09:41:51 +020051 home_dir_mode: 755
Filip Pytlounf5383a42015-10-06 16:28:32 +020052 email: 'jonh@doe.com'
Dzmitry Stremkouskia0d8b2d2018-10-22 14:12:05 +020053 unique: false
Dzmitry Stremkouskifae59fb2018-11-21 10:10:10 +010054 groups:
55 - db-ops
56 - salt-ops
57 optional_groups:
58 - docker
Filip Pytlounf5383a42015-10-06 16:28:32 +020059 jsmith:
60 name: 'jsmith'
61 enabled: true
azvyagintsev967af132017-06-12 12:25:24 +030062 full_name: 'With clear password'
Filip Pytlounf5383a42015-10-06 16:28:32 +020063 home: '/home/jsmith'
azvyagintsev967af132017-06-12 12:25:24 +030064 hash_password: true
65 password: "userpassword"
66 mark:
67 name: 'mark'
68 enabled: true
69 full_name: "unchange password'
70 home: '/home/mark'
71 password: false
72 elizabeth:
73 name: 'elizabeth'
74 enabled: true
75 full_name: 'With hased password'
76 home: '/home/elizabeth'
77 password: "$6$nUI7QEz3$dFYjzQqK5cJ6HQ38KqG4gTWA9eJu3aKx6TRVDFh6BVJxJgFWg2akfAA7f1fCxcSUeOJ2arCO6EEI6XXnHXxG10"
Filip Pytlounf5383a42015-10-06 16:28:32 +020078
Dzmitry Stremkouski6839f542019-09-04 14:15:09 +020079Remove users data completely:
80
81.. code-block:: yaml
82
83 linux:
84 system:
85 user:
86 example:
87 email: disabled
88 enabled: false
89 full_name: disabled
90 name: example
91 force_delete: True
92
Dmitry Teselkin8e903562019-02-21 16:40:23 +030093Setting user defaults
94---------------------
95Default parameters that will be used by `useradd` command could be configured
96the following way:
97
98.. code-block:: yaml
99
100 linux:
101 system:
102 ...
103 defaults:
104 user:
105 shell: <SHELL>
106 gid: <GROUP>
107 home: <HOME>
108 inactdays: <INACTIVE>
109 expire: <EXPIRE>
110 skeleton: <SKEL>
111 create_mail_spool: <CREATE_MAIL_SPOOL>
112
113Other parameters that are used when creating user profile could be configured
114as well, acting as global defaults:
115
116.. code-block:: yaml
117
118 linux:
119 system:
120 ...
121 defaults:
122 user:
123 ...
124 maxdays: <PASS_MAX_DAYS>
125 mindays: <PASS_MIN_DAYS>
126 warndays: <PASS_WARN_AGE>
127
128.. note::
129
130 The three options above ('maxdays', 'mindays', 'warndays') could be
131 overriden in linux:system:login_defs using their 'real' names.
132 The reason they could be defined here is that it's quite logical to
133 have these parameters related to configuration of user account
134 behaviour in one place.
135
136
Dmitry Teselkin47e41f42018-09-27 14:10:09 +0300137Configure password expiration parameters
138----------------------------------------
139The following login.defs parameters can be overridden per-user:
140
141* PASS_MAX_DAYS
142* PASS_MIN_DAYS
143* PASS_WARN_DAYS
Dmitry Teselkin47e41f42018-09-27 14:10:09 +0300144
145.. code-block:: yaml
146
147 linux:
148 system:
149 ...
150 user:
151 jdoe:
152 name: 'jdoe'
153 enabled: true
154 ...
155 maxdays: <PASS_MAX_DAYS>
156 mindays: <PASS_MIN_DAYS>
Dmitry Teselkin8e903562019-02-21 16:40:23 +0300157 warndays: <PASS_WARN_AGE>
Dmitry Teselkin47e41f42018-09-27 14:10:09 +0300158
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100159Configure sudo for users and groups under ``/etc/sudoers.d/``.
160This ways ``linux.system.sudo`` pillar map to actual sudo attributes:
161
162.. code-block:: jinja
Aleš Komárek63572992017-04-11 13:16:44 +0200163
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100164 # simplified template:
165 Cmds_Alias {{ alias }}={{ commands }}
166 {{ user }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
167 %{{ group }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
168
169 # when rendered:
170 saltuser1 ALL=(ALL) NOPASSWD: ALL
171
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100172.. code-block:: yaml
Aleš Komárek63572992017-04-11 13:16:44 +0200173
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100174 linux:
175 system:
176 sudo:
177 enabled: true
Tomas Kammd8eb3002017-05-08 19:30:29 +0200178 aliases:
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100179 host:
180 LOCAL:
181 - localhost
182 PRODUCTION:
183 - db1
184 - db2
185 runas:
186 DBA:
187 - postgres
188 - mysql
189 SALT:
190 - root
191 command:
192 # Note: This is not 100% safe when ALL keyword is used, user still may modify configs and hide his actions.
193 # Best practice is to specify full list of commands user is allowed to run.
194 SUPPORT_RESTRICTED:
195 - /bin/vi /etc/sudoers*
196 - /bin/vim /etc/sudoers*
197 - /bin/nano /etc/sudoers*
198 - /bin/emacs /etc/sudoers*
199 - /bin/su - root
200 - /bin/su -
201 - /bin/su
202 - /usr/sbin/visudo
203 SUPPORT_SHELLS:
204 - /bin/sh
205 - /bin/ksh
206 - /bin/bash
207 - /bin/rbash
208 - /bin/dash
209 - /bin/zsh
210 - /bin/csh
211 - /bin/fish
212 - /bin/tcsh
213 - /usr/bin/login
214 - /usr/bin/su
215 - /usr/su
216 ALL_SALT_SAFE:
217 - /usr/bin/salt state*
218 - /usr/bin/salt service*
219 - /usr/bin/salt pillar*
220 - /usr/bin/salt grains*
221 - /usr/bin/salt saltutil*
222 - /usr/bin/salt-call state*
223 - /usr/bin/salt-call service*
224 - /usr/bin/salt-call pillar*
225 - /usr/bin/salt-call grains*
226 - /usr/bin/salt-call saltutil*
227 SALT_TRUSTED:
228 - /usr/bin/salt*
229 users:
230 # saltuser1 with default values: saltuser1 ALL=(ALL) NOPASSWD: ALL
231 saltuser1: {}
232 saltuser2:
233 hosts:
234 - LOCAL
235 # User Alias DBA
236 DBA:
237 hosts:
238 - ALL
239 commands:
240 - ALL_SALT_SAFE
241 groups:
242 db-ops:
243 hosts:
244 - ALL
245 - '!PRODUCTION'
246 runas:
247 - DBA
248 commands:
249 - /bin/cat *
250 - /bin/less *
251 - /bin/ls *
252 salt-ops:
253 hosts:
254 - 'ALL'
255 runas:
256 - SALT
257 commands:
258 - SUPPORT_SHELLS
259 salt-ops-2nd:
260 name: salt-ops
261 nopasswd: false
Jakub Josef7a9d9b92017-05-16 11:39:01 +0200262 setenv: true # Enable sudo -E option
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100263 runas:
264 - DBA
265 commands:
266 - ALL
267 - '!SUPPORT_SHELLS'
268 - '!SUPPORT_RESTRICTED'
269
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300270Linux with package, latest version:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200271
272.. code-block:: yaml
273
274 linux:
275 system:
276 ...
277 package:
278 package-name:
279 version: latest
280
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300281Linux with package from certail repo, version with no upgrades:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200282
283.. code-block:: yaml
284
285 linux:
286 system:
287 ...
288 package:
289 package-name:
290 version: 2132.323
291 repo: 'custom-repo'
292 hold: true
293
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300294Linux with package from certail repo, version with no GPG
295verification:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200296
297.. code-block:: yaml
298
299 linux:
300 system:
301 ...
302 package:
303 package-name:
304 version: 2132.323
305 repo: 'custom-repo'
306 verify: false
307
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300308Linux with autoupdates (automatically install security package
309updates):
Bruno Binet69a9d8d2017-02-16 22:34:32 +0100310
311.. code-block:: yaml
312
313 linux:
314 system:
315 ...
316 autoupdates:
317 enabled: true
318 mail: root@localhost
319 mail_only_on_error: true
320 remove_unused_dependencies: false
321 automatic_reboot: true
322 automatic_reboot_time: "02:00"
323
Dmitry Teselkin0f084a02018-08-29 14:46:38 +0300324Managing cron tasks
325-------------------
326
327There are two data structures that are related to managing cron itself and
328cron tasks:
329
330.. code-block:: yaml
331
332 linux:
333 system:
334 cron:
335
336and
337
338.. code-block:: yaml
339
340 linux:
341 system:
342 job:
343
344`linux:system:cron` manages cron packages, services, and '/etc/cron.allow' file.
345
346'deny' files are managed the only way - we're ensuring they are absent, that's
347a requirement from CIS 5.1.8
348
349'cron' pillar structure is the following:
350
351.. code-block:: yaml
352
353 linux:
354 system:
355 cron:
356 enabled: true
357 pkgs: [ <cron packages> ]
358 services: [ <cron services> ]
359 user:
360 <username>:
361 enabled: true
362
363To add user to '/etc/cron.allow' use 'enabled' key as shown above.
364
365'/etc/cron.deny' is not managed as CIS 5.1.8 requires it was removed.
366
367A user would be ignored if any of the following is true:
368* user is disabled in `linux:system:user:<username>`
369* user is disabled in `linux:system:cron:user:<username>`
370
371`linux:system:job` manages individual cron tasks.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300372
373By default, it will use name as an identifier, unless identifier key is
Filip Pytloun91222222017-08-04 10:55:27 +0200374explicitly set or False (then it will use Salt's default behavior which is
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300375identifier same as command resulting in not being able to change it):
Filip Pytlounf5383a42015-10-06 16:28:32 +0200376
377.. code-block:: yaml
378
379 linux:
380 system:
381 ...
382 job:
383 cmd1:
384 command: '/cmd/to/run'
Filip Pytloun91222222017-08-04 10:55:27 +0200385 identifier: cmd1
Filip Pytlounf5383a42015-10-06 16:28:32 +0200386 enabled: true
387 user: 'root'
388 hour: 2
389 minute: 0
390
Dmitry Teselkin0f084a02018-08-29 14:46:38 +0300391Managing 'at' tasks
392-------------------
393
394Pillar for managing `at` tasks is similar to one for `cron` tasks:
395
396.. code-block:: yaml
397
398 linux:
399 system:
400 at:
401 enabled: true
402 pkgs: [ <at packages> ]
403 services: [ <at services> ]
404 user:
405 <username>:
406 enabled: true
407
408To add a user to '/etc/at.allow' use 'enabled' key as shown above.
409
410'/etc/at.deny' is not managed as CIS 5.1.8 requires it was removed.
411
412A user will be ignored if any of the following is true:
413* user is disabled in `linux:system:user:<username>`
414* user is disabled in `linux:system:at:user:<username>`
415
416
Filip Pytlound0a29e72015-11-30 15:23:34 +0100417Linux security limits (limit sensu user memory usage to max 1GB):
418
419.. code-block:: yaml
420
421 linux:
422 system:
423 ...
424 limit:
425 sensu:
426 enabled: true
427 domain: sensu
428 limits:
429 - type: hard
430 item: as
431 value: 1000000
432
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300433Enable autologin on ``tty1`` (may work only for Ubuntu 14.04):
Filip Pytloun7fee0542015-10-15 11:19:24 +0200434
435.. code-block:: yaml
436
437 linux:
438 system:
439 console:
440 tty1:
441 autologin: root
Filip Pytloun281d0202016-01-29 14:03:51 +0100442 # Enable serial console
443 ttyS0:
444 autologin: root
445 rate: 115200
446 term: xterm
Filip Pytloun7fee0542015-10-15 11:19:24 +0200447
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300448To disable set autologin to ``false``.
Filip Pytloun7fee0542015-10-15 11:19:24 +0200449
Filip Pytloun7731b852016-02-01 11:13:47 +0100450Set ``policy-rc.d`` on Debian-based systems. Action can be any available
451command in ``while true`` loop and ``case`` context.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300452Following will disallow dpkg to stop/start services for the Cassandra
453package automatically:
Filip Pytloun7731b852016-02-01 11:13:47 +0100454
455.. code-block:: yaml
456
457 linux:
458 system:
459 policyrcd:
460 - package: cassandra
461 action: exit 101
462 - package: '*'
463 action: switch
464
Filip Pytlounc49445a2016-04-04 14:23:20 +0200465Set system locales:
466
467.. code-block:: yaml
468
469 linux:
470 system:
471 locale:
472 en_US.UTF-8:
473 default: true
Filip Pytlounee1745f2016-04-04 17:39:41 +0200474 "cs_CZ.UTF-8 UTF-8":
Filip Pytlounc49445a2016-04-04 14:23:20 +0200475 enabled: true
476
Andrey Shestakove7cca052017-05-24 23:06:24 +0300477Systemd settings:
478
479.. code-block:: yaml
480
481 linux:
482 system:
483 ...
484 systemd:
485 system:
486 Manager:
487 DefaultLimitNOFILE: 307200
488 DefaultLimitNPROC: 307200
489 user:
490 Manager:
491 DefaultLimitCPU: 2
492 DefaultLimitNPROC: 4
493
Filip Pytloun8b2131e2017-11-08 13:29:03 +0100494Ensure presence of directory:
495
496.. code-block:: yaml
497
498 linux:
499 system:
500 directory:
501 /tmp/test:
502 user: root
503 group: root
504 mode: 700
505 makedirs: true
506
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300507Ensure presence of file by specifying its source:
Richard Felkl2e07d652018-01-19 10:19:06 +0100508
509.. code-block:: yaml
510
511 linux:
512 system:
513 file:
514 /tmp/test.txt:
515 source: http://example.com/test.txt
Richard Felklf40599a2018-02-06 22:56:41 +0100516 user: root #optional
517 group: root #optional
518 mode: 700 #optional
519 dir_mode: 700 #optional
520 encoding: utf-8 #optional
521 hash: <<hash>> or <<URI to hash>> #optional
522 makedirs: true #optional
523
524 linux:
525 system:
526 file:
527 test.txt:
528 name: /tmp/test.txt
529 source: http://example.com/test.txt
Richard Felkl2e07d652018-01-19 10:19:06 +0100530
Gabor Orosz35815c02018-09-07 17:31:05 +0200531 linux:
532 system:
533 file:
534 test2:
535 name: /tmp/test2.txt
536 source: http://example.com/test2.jinja
537 template: jinja
538
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300539Ensure presence of file by specifying its contents:
Richard Felkl2e07d652018-01-19 10:19:06 +0100540
541.. code-block:: yaml
542
543 linux:
544 system:
545 file:
546 /tmp/test.txt:
547 contents: |
548 line1
549 line2
Richard Felklf40599a2018-02-06 22:56:41 +0100550
551 linux:
552 system:
553 file:
554 /tmp/test.txt:
555 contents_pillar: linux:network:hostname
556
557 linux:
558 system:
559 file:
560 /tmp/test.txt:
561 contents_grains: motd
562
Ivan Berezovskiyf9301e12019-07-22 13:14:14 +0400563Ensure presence of file by specifying its secured source:
564
565.. code-block:: yaml
566
567 linux:
568 system:
569 file:
570 /tmp/test.txt:
571 secured_source:
572 protocol: http #optional
573 user: foo
574 password: bar
575 url: example.com/test.txt
576 secured_hash: #optional
577 url: example.com/test.txt.md5
578 user: root #optional
579 group: root #optional
580 mode: 700 #optional
581 dir_mode: 700 #optional
582 encoding: utf-8 #optional
583 makedirs: true #optional
584
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300585Ensure presence of file to be serialized through one of the
586serializer modules (see:
587https://docs.saltstack.com/en/latest/ref/serializers/all/index.html):
Bruno Binet9c2fe222018-06-08 16:57:32 +0200588
589.. code-block:: yaml
590
591 linux:
592 system:
593 file:
594 /tmp/test.json:
595 serialize: json
596 contents:
597 foo: 1
598 bar: 'bar'
599
agoriunovd7b19ce2019-02-18 11:37:32 +0200600Ensure presence of file to be decoded through file.decode module (see:
601https://docs.saltstack.com/en/latest/ref/states/all/salt.states.file.html#salt.states.file.decode):
602
603.. code-block:: yaml
604
605 linux:
606 system:
607 file:
608 /tmp/test4.txt:
609 decode: True
610 encoded_data: |
611 dGVzdDQK
612
Filip Pytloun281034a2016-01-04 18:06:22 +0100613Kernel
614~~~~~~
615
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300616Install always up to date LTS kernel and headers from Ubuntu Trusty:
Filip Pytloun281034a2016-01-04 18:06:22 +0100617
618.. code-block:: yaml
619
620 linux:
621 system:
622 kernel:
623 type: generic
624 lts: trusty
625 headers: true
626
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300627Load kernel modules and add them to ``/etc/modules``:
Tomáš Kukrálba35b212017-02-15 17:59:46 +0100628
629.. code-block:: yaml
630
631 linux:
632 system:
633 kernel:
634 modules:
635 - nf_conntrack
636 - tp_smapi
637 - 8021q
638
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300639Configure or blacklist kernel modules with additional options to
640``/etc/modprobe.d`` following example will add
641``/etc/modprobe.d/nf_conntrack.conf`` file with line
642``options nf_conntrack hashsize=262144``:
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300643
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300644'option' can be a mapping (with 'enabled' and 'value' keys) or a scalar.
645
646Example for 'scalar' option value:
647
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300648.. code-block:: yaml
649
650 linux:
651 system:
652 kernel:
653 module:
654 nf_conntrack:
655 option:
656 hashsize: 262144
657
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300658Example for 'mapping' option value:
659
660.. code-block:: yaml
661
662 linux:
663 system:
664 kernel:
665 module:
666 nf_conntrack:
667 option:
668 hashsize:
669 enabled: true
670 value: 262144
671
672NOTE: 'enabled' key is optional and is True by default.
673
674Blacklist a module:
675
676.. code-block:: yaml
677
678 linux:
679 system:
680 kernel:
681 module:
682 nf_conntrack:
683 blacklist: true
684
685A module can have a number of aliases, wildcards are allowed.
686Define an alias for a module:
687
688.. code-block:: yaml
689
690 linux:
691 system:
692 kernel:
693 module:
694 nf_conntrack:
695 alias:
696 nfct:
697 enabled: true
698 "nf_conn*":
699 enabled: true
700
701NOTE: 'enabled' key is mandatory as there are no other keys exist.
702
703Execute custom command instead of 'insmod' when inserting a module:
704
705.. code-block:: yaml
706
707 linux:
708 system:
709 kernel:
710 module:
711 nf_conntrack:
712 install:
713 enabled: true
714 command: /bin/true
715
716NOTE: 'enabled' key is optional and is True by default.
717
718Execute custom command instead of 'rmmod' when removing a module:
719
720.. code-block:: yaml
721
722 linux:
723 system:
724 kernel:
725 module:
726 nf_conntrack:
727 remove:
728 enabled: true
729 command: /bin/true
730
731NOTE: 'enabled' key is optional and is True by default.
732
733Define module dependencies:
734
735.. code-block:: yaml
736
737 linux:
738 system:
739 kernel:
740 module:
741 nf_conntrack:
742 softdep:
743 pre:
744 1:
745 enabled: true
746 value: a
747 2:
748 enabled: true
749 value: b
750 3:
751 enabled: true
752 value: c
753 post:
754 1:
755 enabled: true
756 value: x
757 2:
758 enabled: true
759 value: y
760 3:
761 enabled: true
762 value: z
763
764NOTE: 'enabled' key is optional and is True by default.
765
766
Filip Pytloun281034a2016-01-04 18:06:22 +0100767Install specific kernel version and ensure all other kernel packages are
768not present. Also install extra modules and headers for this kernel:
769
770.. code-block:: yaml
771
772 linux:
773 system:
774 kernel:
775 type: generic
776 extra: true
777 headers: true
778 version: 4.2.0-22
779
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300780Systcl kernel parameters:
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100781
782.. code-block:: yaml
783
784 linux:
785 system:
786 kernel:
787 sysctl:
788 net.ipv4.tcp_keepalive_intvl: 3
789 net.ipv4.tcp_keepalive_time: 30
790 net.ipv4.tcp_keepalive_probes: 8
791
Michael Polenchukebf55522018-01-25 13:22:39 +0400792Configure kernel boot options:
793
794.. code-block:: yaml
795
796 linux:
797 system:
798 kernel:
799 boot_options:
800 - elevator=deadline
801 - spectre_v2=off
802 - nopti
803
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100804CPU
805~~~
806
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300807Enable cpufreq governor for every cpu:
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100808
809.. code-block:: yaml
810
811 linux:
812 system:
813 cpu:
814 governor: performance
815
Nick Metzf04f5f32018-01-08 15:25:04 +0100816
Jiri Broulik303905d2018-01-11 14:12:48 +0100817CGROUPS
818~~~~~~~
819
820Setup linux cgroups:
821
822.. code-block:: yaml
823
824 linux:
825 system:
826 cgroup:
827 enabled: true
828 group:
829 ceph_group_1:
830 controller:
831 cpu:
832 shares:
833 value: 250
834 cpuacct:
835 usage:
836 value: 0
837 cpuset:
838 cpus:
839 value: 1,2,3
840 memory:
841 limit_in_bytes:
842 value: 2G
843 memsw.limit_in_bytes:
844 value: 3G
845 mapping:
846 subjects:
847 - '@ceph'
848 generic_group_1:
849 controller:
850 cpu:
851 shares:
852 value: 250
853 cpuacct:
854 usage:
855 value: 0
856 mapping:
857 subjects:
858 - '*:firefox'
859 - 'student:cp'
860
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300861Shared libraries
Nick Metzf04f5f32018-01-08 15:25:04 +0100862~~~~~~~~~~~~~~~~
863
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300864Set additional shared library to Linux system library path:
Nick Metzf04f5f32018-01-08 15:25:04 +0100865
866.. code-block:: yaml
867
868 linux:
869 system:
870 ld:
871 library:
872 java:
873 - /usr/lib/jvm/jre-openjdk/lib/amd64/server
874 - /opt/java/jre/lib/amd64/server
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200875
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200876Certificates
877~~~~~~~~~~~~
878
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300879Add certificate authority into system trusted CA bundle:
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200880
881.. code-block:: yaml
882
883 linux:
884 system:
885 ca_certificates:
886 mycert: |
887 -----BEGIN CERTIFICATE-----
888 MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
889 A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
890 cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
891 MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
892 BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
893 YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
894 ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
895 BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
896 I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
897 CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
898 lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
899 AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
900 -----END CERTIFICATE-----
901
Filip Pytloun361096c2017-08-23 10:57:20 +0200902Sysfs
903~~~~~
904
905Install sysfsutils and set sysfs attributes:
906
907.. code-block:: yaml
908
909 linux:
910 system:
911 sysfs:
912 scheduler:
913 block/sda/queue/scheduler: deadline
914 power:
915 mode:
916 power/state: 0660
917 owner:
918 power/state: "root:power"
919 devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
920
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200921Optional: You can also use list that will ensure order of items.
922
923.. code-block:: yaml
924
925 linux:
926 system:
927 sysfs:
928 scheduler:
929 block/sda/queue/scheduler: deadline
930 power:
931 - mode:
932 power/state: 0660
933 - owner:
934 power/state: "root:power"
935 - devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
936
Martin Polreich148e1b82018-09-13 15:54:25 +0200937Sysfs definition with disabled automatic write. Attributes are saved
938to configuration, but are not applied during the run.
939Thay will be applied automatically after the reboot.
940
941
942.. code-block:: yaml
943
944 linux:
945 system:
946 sysfs:
947 enable_apply: false
948 scheduler:
949 block/sda/queue/scheduler: deadline
950
951.. note:: The `enable_apply` parameter defaults to `True` if not defined.
952
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100953Huge Pages
954~~~~~~~~~~~~
955
956Huge Pages give a performance boost to applications that intensively deal
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300957with memory allocation/deallocation by decreasing memory fragmentation:
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100958
959.. code-block:: yaml
960
961 linux:
962 system:
963 kernel:
964 hugepages:
965 small:
966 size: 2M
967 count: 107520
968 mount_point: /mnt/hugepages_2MB
Michael Polenchukd9369fe2018-05-08 17:53:08 +0400969 mount: false/true # default is true (mount immediately) / false (just save in the fstab)
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100970 large:
971 default: true # default automatically mounted
972 size: 1G
973 count: 210
974 mount_point: /mnt/hugepages_1GB
975
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300976.. note:: Not recommended to use both pagesizes concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100977
Jakub Pavlik5398d872017-02-13 22:30:47 +0100978Intel SR-IOV
979~~~~~~~~~~~~
980
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300981PCI-SIG Single Root I/O Virtualization and Sharing (SR-IOV)
982specification defines a standardized mechanism to virtualize
983PCIe devices. The mechanism can virtualize a single PCIe
984Ethernet controller to appear as multiple PCIe devices:
Jakub Pavlik5398d872017-02-13 22:30:47 +0100985
986.. code-block:: yaml
987
988 linux:
989 system:
990 kernel:
991 sriov: True
992 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
993 rc:
994 local: |
995 #!/bin/sh -e
996 # Enable 7 VF on eth1
997 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
998 exit 0
999
Jakub Pavlik6c9ead12017-02-16 21:53:13 +01001000Isolate CPU options
1001~~~~~~~~~~~~~~~~~~~
1002
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001003Remove the specified CPUs, as defined by the cpu_number values, from
1004the general kernel SMP balancing and scheduler algroithms. The only
1005way to move a process onto or off an *isolated* CPU is via the CPU
1006affinity syscalls. ``cpu_number begins`` at ``0``, so the
1007maximum value is ``1`` less than the number of CPUs on the system.:
Jakub Pavlik6c9ead12017-02-16 21:53:13 +01001008
1009.. code-block:: yaml
1010
1011 linux:
1012 system:
1013 kernel:
1014 isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
Jiri Broulikf8f55a22017-01-26 14:36:46 +01001015
Filip Pytlounf5383a42015-10-06 16:28:32 +02001016Repositories
1017~~~~~~~~~~~~
1018
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001019RedHat-based Linux with additional OpenStack repo:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001020
1021.. code-block:: yaml
1022
1023 linux:
1024 system:
1025 ...
1026 repo:
1027 rdo-icehouse:
1028 enabled: true
1029 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
1030 pgpcheck: 0
1031
1032Ensure system repository to use czech Debian mirror (``default: true``)
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001033Also pin it's packages with priority ``900``:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001034
1035.. code-block:: yaml
1036
1037 linux:
1038 system:
1039 repo:
1040 debian:
1041 default: true
1042 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
1043 # Import signing key from URL if needed
1044 key_url: "http://dummy.com/public.gpg"
1045 pin:
1046 - pin: 'origin "ftp.cz.debian.org"'
1047 priority: 900
1048 package: '*'
1049
azvyagintseva3a73d02018-12-06 14:49:58 +02001050Sometimes better to use one pining rule file, to decrease mistaken
1051ordering. You can use those option ``system:apt:preferences``, which would add opts into
1052``/etc/apt/preferences`` file:
1053
1054.. code-block:: yaml
1055
1056 parameters:
1057 linux:
1058 system:
1059 apt:
1060 preferences:
1061 enabled: true
1062 rules:
1063 100:
1064 enabled: true
1065 name: 'some origin pin'
1066 pin: 'release o=Debian'
1067 priority: 1100
1068 package: '*'
1069
1070
azvyagintsev4494a472018-09-14 19:19:23 +03001071If you need to add multiple pin rules for one repo, please use new,ordered definition format
1072('pinning' definition will be in priotity to use):
1073
1074.. code-block:: yaml
1075
1076 linux:
1077 system:
1078 repo:
1079 mcp_saltstack:
1080 source: "deb [arch=amd64] http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/ xenial main"
1081 architectures: amd64
1082 clean_file: true
1083 pinning:
1084 10:
1085 enabled: true
1086 pin: 'release o=SaltStack'
1087 priority: 50
1088 package: 'libsodium18'
1089 20:
1090 enabled: true
1091 pin: 'release o=SaltStack'
1092 priority: 1100
1093 package: '*'
1094
1095
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001096.. note:: For old Ubuntu releases (<xenial)
azvyagintsevff089d22018-07-27 16:52:34 +02001097 extra packages for apt transport, like ``apt-transport-https``
1098 may be required to be installed manually.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001099 (Chicken-eggs issue: we need to install packages to
azvyagintsevff089d22018-07-27 16:52:34 +02001100 reach repo from where they should be installed)
1101 Otherwise, you still can try 'fortune' and install prereq.packages before
1102 any repo configuration, using list of requires in map.jinja.
1103
1104
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001105Disabling any prerequisite packages installation:
1106
azvyagintsevff089d22018-07-27 16:52:34 +02001107You can simply drop any package pre-installation (before system.linux.repo
1108will be processed) via cluster lvl:
1109
1110.. code-block:: yaml
1111
1112 linux:
1113 system:
1114 pkgs: ~
1115
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001116Package manager proxy global setup:
Petr Michalec10462bb2017-03-23 19:18:08 +01001117
1118.. code-block:: yaml
1119
1120 linux:
1121 system:
1122 ...
1123 repo:
1124 apt-mk:
1125 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1126 ...
1127 proxy:
1128 pkg:
1129 enabled: true
1130 ftp: ftp://ftp-proxy-for-apt.host.local:2121
1131 ...
1132 # NOTE: Global defaults for any other componet that configure proxy on the system.
1133 # If your environment has just one simple proxy, set it on linux:system:proxy.
1134 #
1135 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
1136 # as for https and http
1137 ftp: ftp://proxy.host.local:2121
1138 http: http://proxy.host.local:3142
1139 https: https://proxy.host.local:3143
1140
1141Package manager proxy setup per repository:
1142
1143.. code-block:: yaml
1144
1145 linux:
1146 system:
1147 ...
1148 repo:
1149 debian:
1150 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1151 ...
1152 apt-mk:
1153 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1154 # per repository proxy
1155 proxy:
1156 enabled: true
1157 http: http://maas-01:8080
1158 https: http://maas-01:8080
1159 ...
1160 proxy:
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001161 # package manager fallback defaults
Petr Michalec10462bb2017-03-23 19:18:08 +01001162 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
1163 pkg:
1164 enabled: true
1165 ftp: ftp://proxy.host.local:2121
1166 #http: http://proxy.host.local:3142
1167 #https: https://proxy.host.local:3143
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001168 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001169 # global system fallback system defaults
1170 ftp: ftp://proxy.host.local:2121
1171 http: http://proxy.host.local:3142
1172 https: https://proxy.host.local:3143
1173
Ivan Berezovskiy6335da52019-06-25 20:15:51 +04001174
1175Add secured apt repository:
1176
1177.. code-block:: yaml
1178
1179 linux:
1180 system:
1181 ...
1182 repo:
1183 test:
1184 secure: true
1185 url: example.org/ubuntu
1186 arch: deb
1187 protocol: http
1188 user: foo
1189 password: bar
1190 distribution: stable
1191 component: main
1192
1193Add multiply secured apt repositories with same credentials:
1194
1195.. code-block:: yaml
1196
1197 linux:
1198 system:
1199 ...
1200 common_repo_secured:
1201 arch: deb
1202 protocol: http
1203 user: foo
1204 password: bar
1205 distribution: stable
1206 component: main
1207 repo:
1208 test1:
1209 secure: true
1210 url: example1.org/ubuntu
1211 test2:
1212 secure: true
1213 url: example2.org/ubuntu
1214
Jiri Broulik34a29b42017-04-25 14:42:54 +02001215Remove all repositories:
1216
1217.. code-block:: yaml
1218
1219 linux:
1220 system:
1221 purge_repos: true
1222
azvyagintsevff089d22018-07-27 16:52:34 +02001223Refresh repositories metada, after configuration:
1224
1225.. code-block:: yaml
1226
1227 linux:
1228 system:
1229 refresh_repos_meta: true
1230
Filip Pytlounc512e6c2017-11-22 14:28:10 +01001231Setup custom apt config options:
1232
1233.. code-block:: yaml
1234
1235 linux:
1236 system:
1237 apt:
1238 config:
1239 compression-workaround:
1240 "Acquire::CompressionTypes::Order": "gz"
1241 docker-clean:
1242 "DPkg::Post-Invoke":
1243 - "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"
1244 "APT::Update::Post-Invoke":
1245 - "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 +02001246
Petr Michalec10462bb2017-03-23 19:18:08 +01001247RC
1248~~
1249
Jakub Pavlik78859382016-01-21 11:26:39 +01001250rc.local example
1251
1252.. code-block:: yaml
1253
1254 linux:
1255 system:
1256 rc:
1257 local: |
1258 #!/bin/sh -e
1259 #
1260 # rc.local
1261 #
1262 # This script is executed at the end of each multiuser runlevel.
1263 # Make sure that the script will "exit 0" on success or any other
1264 # value on error.
1265 #
1266 # In order to enable or disable this script just change the execution
1267 # bits.
1268 #
1269 # By default this script does nothing.
1270 exit 0
1271
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001272Prompt
1273~~~~~~
1274
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001275Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``.
1276Every user can have different prompt:
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001277
1278.. code-block:: yaml
1279
1280 linux:
1281 system:
1282 prompt:
1283 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\\]
1284 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
1285
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001286On Debian systems, to set prompt system-wide, it's necessary to
1287remove setting PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc``,
1288which comes from ``/etc/skel/.bashrc``. This formula will do
1289this automatically, but will not touch existing user's
1290``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +01001291
Filip Pytlouneef11c12016-03-25 11:00:23 +01001292Bash
1293~~~~
1294
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001295Fix bash configuration to preserve history across sessions
1296like ZSH does by default:
Filip Pytlouneef11c12016-03-25 11:00:23 +01001297
1298.. code-block:: yaml
1299
1300 linux:
1301 system:
1302 bash:
1303 preserve_history: true
1304
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001305Login banner message
1306~~~~~~~~~~~~~~~~~~~~
1307
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001308``/etc/issue`` is a text file which contains a message or system
1309identification to be printed before the login prompt. It may contain
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001310various @char and \char sequences, if supported by the getty-type
1311program employed on the system.
1312
1313Setting logon banner message is easy:
1314
1315.. code-block:: yaml
1316
1317 liunx:
1318 system:
1319 banner:
1320 enabled: true
1321 contents: |
1322 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1323
1324 You must have explicit, authorized permission to access or configure this
1325 device. Unauthorized attempts and actions to access or use this system may
1326 result in civil and/or criminal penalties.
1327 All activities performed on this system are logged and monitored.
1328
Filip Pytloune874dfb2016-01-22 16:57:34 +01001329Message of the day
1330~~~~~~~~~~~~~~~~~~
1331
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001332``pam_motd`` from package ``libpam-modules`` is used for dynamic
1333messages of the day. Setting custom ``motd`` will clean up existing ones.
Filip Pytloune874dfb2016-01-22 16:57:34 +01001334
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001335Setting static ``motd`` will replace existing ``/etc/motd`` and remove
1336scripts from ``/etc/update-motd.d``.
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001337
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001338Setting static ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001339
1340.. code-block:: yaml
1341
1342 linux:
1343 system:
1344 motd: |
1345 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1346
1347 You must have explicit, authorized permission to access or configure this
1348 device. Unauthorized attempts and actions to access or use this system may
1349 result in civil and/or criminal penalties.
1350 All activities performed on this system are logged and monitored.
1351
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001352Setting dynamic ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001353
Filip Pytloune874dfb2016-01-22 16:57:34 +01001354.. code-block:: yaml
1355
1356 linux:
1357 system:
1358 motd:
1359 - release: |
1360 #!/bin/sh
1361 [ -r /etc/lsb-release ] && . /etc/lsb-release
1362
1363 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
1364 # Fall back to using the very slow lsb_release utility
1365 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
1366 fi
1367
1368 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
1369 - warning: |
1370 #!/bin/sh
1371 printf "This is [company name] network.\n"
1372 printf "Unauthorized access strictly prohibited.\n"
1373
Marek Celoud713e9072017-05-18 15:20:25 +02001374Services
1375~~~~~~~~
1376
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001377Stop and disable the ``linux`` service:
Marek Celoud713e9072017-05-18 15:20:25 +02001378
1379.. code-block:: yaml
1380
1381 linux:
1382 system:
1383 service:
1384 apt-daily.timer:
1385 status: dead
1386
Dzmitry Stremkouski70d09782018-11-30 16:04:59 +01001387Override systemd service unit:
1388
1389.. code-block:: yaml
1390
1391 parameters:
1392
1393 linux:
1394 system:
1395 service:
1396 tgt:
1397 name: tgt
1398 status: running
1399 enabled: True
1400 override:
1401 50:
1402 target: tgt.service.d
1403 name: bind
1404 content: |
1405 [Service]
1406 ExecStart=
1407 ExecStart=/usr/sbin/tgtd -f --iscsi portal=${_param:single_address}:3260
1408
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001409Possible statuses are ``dead`` (disable service by default), ``running``
1410(enable service by default), ``enabled``, ``disabled``:
Marek Celoud713e9072017-05-18 15:20:25 +02001411
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001412Linux with the ``atop`` service:
Serhiy Ovsianikov67bd56a2017-08-11 15:56:01 +03001413
1414.. code-block:: yaml
1415
1416 linux:
1417 system:
1418 atop:
1419 enabled: true
1420 interval: 20
1421 logpath: "/var/log/atop"
1422 outfile: "/var/log/atop/daily.log"
1423
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001424Linux with the ``mcelog`` service:
Oleksii Chupryn144432b2018-05-22 10:34:48 +03001425
1426.. code-block:: yaml
1427
1428 linux:
1429 system:
1430 mcelog:
1431 enabled: true
1432 logging:
1433 syslog: true
1434 syslog_error: true
1435
Filip Pytloun2f70b492016-02-19 15:55:25 +01001436RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +01001437^^^^^^^^^^^^^
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001438Currently, ``update-motd`` is not available
1439for RHEL. So there is no native support for dynamic ``motd``.
1440You can still set a static one, with a different pillar structure:
Filip Pytloun2f70b492016-02-19 15:55:25 +01001441
1442.. code-block:: yaml
1443
1444 linux:
1445 system:
1446 motd: |
1447 This is [company name] network.
1448 Unauthorized access strictly prohibited.
1449
Filip Pytloun8296bb92016-02-19 18:42:09 +01001450Haveged
1451~~~~~~~
1452
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001453If you are running headless server and are low on entropy,
1454you may set up Haveged:
Filip Pytloun8296bb92016-02-19 18:42:09 +01001455
1456.. code-block:: yaml
1457
1458 linux:
1459 system:
1460 haveged:
1461 enabled: true
1462
Filip Pytlounf5383a42015-10-06 16:28:32 +02001463Linux network
1464-------------
1465
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001466Linux with network manager:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001467
1468.. code-block:: yaml
1469
1470 linux:
1471 network:
1472 enabled: true
1473 network_manager: true
1474
Dzmitry Stremkouski00cdbe62018-10-31 16:41:54 +01001475Execute linux.network.interface state without ifupdown activity:
1476
1477.. code-block:: bash
1478
1479 salt-call linux.network.interface pillar='{"linux":{"network":{"noifupdown":True}}}'
1480
1481
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001482Linux with default static network interfaces, default gateway
1483interface and DNS servers:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001484
1485.. code-block:: yaml
1486
1487 linux:
1488 network:
1489 enabled: true
1490 interface:
1491 eth0:
1492 enabled: true
1493 type: eth
1494 address: 192.168.0.102
1495 netmask: 255.255.255.0
1496 gateway: 192.168.0.1
1497 name_servers:
1498 - 8.8.8.8
1499 - 8.8.4.4
1500 mtu: 1500
1501
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001502Linux with bonded interfaces and disabled ``NetworkManager``:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001503
1504.. code-block:: yaml
1505
1506 linux:
1507 network:
1508 enabled: true
1509 interface:
1510 eth0:
1511 type: eth
1512 ...
1513 eth1:
1514 type: eth
1515 ...
1516 bond0:
1517 enabled: true
1518 type: bond
1519 address: 192.168.0.102
1520 netmask: 255.255.255.0
Dzmitry Stremkouskif6fb7212019-08-26 16:48:05 +02001521 proto: manual
1522 mtu: 9000
1523 name: ${_param:vlan_bond_name}
1524 slaves: ${_param:vlan_nic1} ${_param:vlan_nic2}
1525 mode: 802.3ad
1526 lacp_rate: slow
1527 downdelay: 200
1528 xmit_hash_policy: layer3+4
1529 miimon: 100
1530 use_interfaces:
1531 - ${_param:vlan_nic1}
1532 - ${_param:vlan_nic2}
1533 require_interfaces:
1534 - ${_param:vlan_nic1}
1535 - ${_param:vlan_nic2}
jan kaufman6d30adf2016-01-18 17:30:12 +01001536 network_manager:
1537 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001538
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001539Linux with VLAN ``interface_params``:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001540
1541.. code-block:: yaml
1542
1543 linux:
1544 network:
1545 enabled: true
1546 interface:
1547 vlan69:
1548 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +01001549 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001550 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001551
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001552Linux with wireless interface parameters:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001553
1554.. code-block:: yaml
1555
1556 linux:
1557 network:
1558 enabled: true
1559 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001560 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001561 interface:
1562 wlan0:
1563 type: eth
1564 wireless:
1565 essid: example
1566 key: example_key
1567 security: wpa
1568 priority: 1
1569
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001570Linux networks with routes defined:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001571
1572.. code-block:: yaml
1573
1574 linux:
1575 network:
1576 enabled: true
1577 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001578 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001579 interface:
1580 eth0:
1581 type: eth
1582 route:
1583 default:
1584 address: 192.168.0.123
1585 netmask: 255.255.255.0
1586 gateway: 192.168.0.1
1587
ivcc4730b12019-01-23 07:56:53 +03001588Linux networks with implicit routes definition:
1589
1590- on node 1:
1591
1592.. code-block:: yaml
1593
1594 linux:
1595 network:
1596 enabled: true
1597 router:
1598 ctl:
1599 # router that connects 10.0.1.0/24 and 10.0.2.0/24
1600 addresses:
1601 - 10.0.1.1/24
1602 - 10.0.2.1/24
1603 test:
1604 addresses:
1605 - 10.0.1.2/24
1606 networks:
1607 - 10.100.0.0/16
1608 interface:
1609 ctl:
1610 name: eth0
1611 address: 10.0.1.101
1612 netmask: 255.255.255.0
1613
1614- on node2:
1615
1616.. code-block:: yaml
1617
1618 linux:
1619 network:
1620 enabled: true
1621 router:
1622 ctl:
1623 # equivalent of node1's ctl router with 'implicit_routes = false'
1624 options:
1625 implicit_routes: false
1626 addresses:
1627 - 10.0.1.1/24
1628 - 10.0.2.1/24
1629 networks:
1630 - 10.0.1.0/24
1631 - 10.0.2.0/24
1632 interface:
1633 ctl:
1634 name: eth0
1635 address: 10.0.2.101
1636 netmask: 255.255.255.0
1637
1638
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001639Native Linux Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001640
1641.. code-block:: yaml
1642
1643 linux:
1644 network:
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
1662
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001663Open vSwitch Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001664
1665.. code-block:: yaml
1666
1667 linux:
1668 network:
1669 bridge: openvswitch
1670 interface:
1671 eth1:
1672 enabled: true
1673 type: eth
1674 proto: manual
1675 up_cmds:
1676 - ip address add 0/0 dev $IFACE
1677 - ip link set $IFACE up
1678 down_cmds:
1679 - ip link set $IFACE down
1680 br-ex:
1681 enabled: true
1682 type: bridge
1683 address: ${linux:network:host:public_local:address}
1684 netmask: 255.255.255.0
1685 use_interfaces:
1686 - eth1
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001687 br-prv:
1688 enabled: true
1689 type: ovs_bridge
1690 mtu: 65000
1691 br-ens7:
1692 enabled: true
1693 name: br-ens7
1694 type: ovs_bridge
1695 proto: manual
1696 mtu: 9000
1697 use_interfaces:
1698 - ens7
1699 patch-br-ens7-br-prv:
1700 enabled: true
1701 name: ens7-prv
1702 ovs_type: ovs_port
1703 type: ovs_port
1704 bridge: br-ens7
1705 port_type: patch
1706 peer: prv-ens7
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001707 tag: 109 # [] to unset a tag
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001708 mtu: 65000
1709 patch-br-prv-br-ens7:
1710 enabled: true
1711 name: prv-ens7
1712 bridge: br-prv
1713 ovs_type: ovs_port
1714 type: ovs_port
1715 port_type: patch
1716 peer: ens7-prv
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001717 tag: 109
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001718 mtu: 65000
1719 ens7:
1720 enabled: true
1721 name: ens7
1722 proto: manual
1723 ovs_port_type: OVSPort
1724 type: ovs_port
1725 ovs_bridge: br-ens7
1726 bridge: br-ens7
Oleg Gelbukh52f9f762019-07-01 15:26:16 -07001727 ens6:
1728 enabled: true
1729 proto: manual
1730 type: eth
1731 ovs_bridge: br-ctl
1732 br-ctl:
1733 enabled: true
1734 type: ovs_bridge
1735 internal-br-ctl-port:
1736 enabled: true
1737 proto: static
1738 address: 172.172.0.10
1739 netmask: 255.255.0.0
1740 name_servers:
1741 - 8.8.8.8
1742 - 172.172.172.172
1743 name: port-br-ctl
1744 bridge: br-ctl
1745 ovs_type: ovs_port
1746 type: ovs_port
1747 port_type: internal
1748 mtu: 65000
Filip Pytlounf5383a42015-10-06 16:28:32 +02001749
Petr Jediný8f8ae542017-07-13 16:19:12 +02001750Debian manual proto interfaces
1751
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001752When you are changing interface proto from static in up state
1753to manual, you may need to flush ip addresses. For example,
1754if you want to use the interface and the ip on the bridge.
1755This can be done by setting the ``ipflush_onchange`` to true.
Petr Jediný8f8ae542017-07-13 16:19:12 +02001756
1757.. code-block:: yaml
1758
1759 linux:
1760 network:
1761 interface:
1762 eth1:
1763 enabled: true
1764 type: eth
1765 proto: manual
1766 mtu: 9100
1767 ipflush_onchange: true
1768
Jiri Broulik1a191e32018-01-15 15:54:21 +01001769Debian static proto interfaces
1770
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001771When you are changing interface proto from dhcp in up state to
1772static, you may need to flush ip addresses and restart interface
1773to assign ip address from a managed file. For example, if you wantto
1774use the interface and the ip on the bridge. This can be done by
1775setting the ``ipflush_onchange`` with combination ``restart_on_ipflush``
1776param set to true.
Jiri Broulik1a191e32018-01-15 15:54:21 +01001777
1778.. code-block:: yaml
1779
1780 linux:
1781 network:
1782 interface:
1783 eth1:
1784 enabled: true
1785 type: eth
1786 proto: static
1787 address: 10.1.0.22
1788 netmask: 255.255.255.0
1789 ipflush_onchange: true
1790 restart_on_ipflush: true
Petr Jediný8f8ae542017-07-13 16:19:12 +02001791
Petr Jedinýd577cb52017-06-28 20:17:49 +02001792Concatinating and removing interface files
1793
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001794Debian based distributions have ``/etc/network/interfaces.d/``
1795directory, where you can store configuration of network
1796interfaces in separate files. You can concatinate the files
1797to the defined destination when needed, this operation removes
1798the file from the ``/etc/network/interfaces.d/``. If you just need
1799to remove iface files, you can use the ``remove_iface_files`` key.
Petr Jedinýd577cb52017-06-28 20:17:49 +02001800
1801.. code-block:: yaml
1802
1803 linux:
1804 network:
1805 concat_iface_files:
1806 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
1807 dst: '/etc/network/interfaces'
1808 remove_iface_files:
1809 - '/etc/network/interfaces.d/90-custom.cfg'
1810
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001811Configure DHCP client
Petr Jedinýd577cb52017-06-28 20:17:49 +02001812
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001813None of the keys is mandatory, include only those you really need.
1814For full list of available options under send, supersede, prepend,
1815append refer to dhcp-options(5).
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001816
1817.. code-block:: yaml
1818
1819 linux:
1820 network:
1821 dhclient:
1822 enabled: true
1823 backoff_cutoff: 15
1824 initial_interval: 10
1825 reboot: 10
1826 retry: 60
1827 select_timeout: 0
1828 timeout: 120
1829 send:
1830 - option: host-name
1831 declaration: "= gethostname()"
1832 supersede:
1833 - option: host-name
1834 declaration: "spaceship"
1835 - option: domain-name
1836 declaration: "domain.home"
1837 #- option: arp-cache-timeout
1838 # declaration: 20
1839 prepend:
1840 - option: domain-name-servers
1841 declaration:
1842 - 8.8.8.8
1843 - 8.8.4.4
1844 - option: domain-search
1845 declaration:
1846 - example.com
1847 - eng.example.com
1848 #append:
1849 #- option: domain-name-servers
1850 # declaration: 127.0.0.1
1851 # ip or subnet to reject dhcp offer from
1852 reject:
1853 - 192.33.137.209
1854 - 10.0.2.0/24
1855 request:
1856 - subnet-mask
1857 - broadcast-address
1858 - time-offset
1859 - routers
1860 - domain-name
1861 - domain-name-servers
1862 - domain-search
1863 - host-name
1864 - dhcp6.name-servers
1865 - dhcp6.domain-search
1866 - dhcp6.fqdn
1867 - dhcp6.sntp-servers
1868 - netbios-name-servers
1869 - netbios-scope
1870 - interface-mtu
1871 - rfc3442-classless-static-routes
1872 - ntp-servers
1873 require:
1874 - subnet-mask
1875 - domain-name-servers
1876 # if per interface configuration required add below
1877 interface:
1878 ens2:
1879 initial_interval: 11
1880 reject:
1881 - 192.33.137.210
1882 ens3:
1883 initial_interval: 12
1884 reject:
1885 - 192.33.137.211
1886
Petr Michaleceb14b552017-06-01 10:27:05 +02001887Linux network systemd settings:
1888
1889.. code-block:: yaml
1890
1891 linux:
1892 network:
1893 ...
1894 systemd:
1895 link:
1896 10-iface-dmz:
1897 Match:
1898 MACAddress: c8:5b:67:fa:1a:af
1899 OriginalName: eth0
1900 Link:
1901 Name: dmz0
1902 netdev:
1903 20-bridge-dmz:
1904 match:
1905 name: dmz0
1906 network:
1907 mescription: bridge
1908 bridge: br-dmz0
1909 network:
1910 # works with lowercase, keys are by default capitalized
1911 40-dhcp:
1912 match:
1913 name: '*'
1914 network:
1915 DHCP: yes
1916
Petr Michalec10462bb2017-03-23 19:18:08 +01001917Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +01001918
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001919Use ``/etc/environment`` for static system wide variable assignment
1920after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001921
1922.. code-block:: yaml
1923
1924 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +01001925 system:
1926 env:
1927 BOB_VARIABLE: Alice
1928 ...
1929 BOB_PATH:
1930 - /srv/alice/bin
1931 - /srv/bob/bin
1932 ...
1933 ftp_proxy: none
1934 http_proxy: http://global-http-proxy.host.local:8080
1935 https_proxy: ${linux:system:proxy:https}
1936 no_proxy:
1937 - 192.168.0.80
1938 - 192.168.1.80
1939 - .domain.com
1940 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001941 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001942 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001943 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001944 ftp: ftp://proxy.host.local:2121
1945 http: http://proxy.host.local:3142
1946 https: https://proxy.host.local:3143
1947 noproxy:
1948 - .domain.com
1949 - .local
1950
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001951Configure the ``profile.d`` scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001952
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001953The ``profile.d`` scripts are being sourced during ``.sh`` execution
1954and support variable expansion in opposite to /etc/environment global
1955settings in ``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001956
1957.. code-block:: yaml
1958
1959 linux:
1960 system:
1961 profile:
1962 locales: |
1963 export LANG=C
1964 export LC_ALL=C
1965 ...
1966 vi_flavors.sh: |
1967 export PAGER=view
1968 export EDITOR=vim
1969 alias vi=vim
1970 shell_locales.sh: |
1971 export LANG=en_US
1972 export LC_ALL=en_US.UTF-8
1973 shell_proxies.sh: |
1974 export FTP_PROXY=ftp://127.0.3.3:2121
1975 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001976
Dmitry Teselkina0d31d12018-09-04 14:43:09 +03001977
1978Configure login.defs parameters
1979-------------------------------
1980
1981.. code-block:: yaml
1982
1983 linux:
1984 system:
1985 login_defs:
1986 <opt_name>:
1987 enabled: true
1988 value: <opt_value>
1989
1990<opt_name> is a configurational option defined in 'man login.defs'.
1991<opt_name> is case sensitive, should be UPPERCASE only!
1992
1993
Filip Pytlounf5383a42015-10-06 16:28:32 +02001994Linux with hosts
1995
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001996Parameter ``purge_hosts`` will enforce whole ``/etc/hosts file``,
1997removing entries that are not defined in model except defaults
1998for both IPv4 and IPv6 localhost and hostname as well as FQDN.
Ales Komarek417e8c52017-08-25 15:10:29 +02001999
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002000We recommend using this option to verify that ``/etc/hosts``
2001is always in a clean state. However it is not enabled by default
2002for security reasons.
Filip Pytloun86506fe2017-01-26 14:36:16 +01002003
Filip Pytlounf5383a42015-10-06 16:28:32 +02002004.. code-block:: yaml
2005
2006 linux:
2007 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01002008 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02002009 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01002010 # No need to define this one if purge_hosts is true
2011 hostname:
2012 address: 127.0.1.1
2013 names:
2014 - ${linux:network:fqdn}
2015 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02002016 node1:
2017 address: 192.168.10.200
2018 names:
2019 - node2.domain.com
2020 - service2.domain.com
2021 node2:
2022 address: 192.168.10.201
2023 names:
2024 - node2.domain.com
2025 - service2.domain.com
2026
Ales Komarek417e8c52017-08-25 15:10:29 +02002027Linux with hosts collected from mine
2028
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002029All DNS records defined within infrastrucuture
2030are passed to the local hosts records or any DNS server. Only
2031hosts with the ``grain`` parameter set to ``true`` will be propagated
2032to the mine.
Ales Komarek417e8c52017-08-25 15:10:29 +02002033
2034.. code-block:: yaml
2035
2036 linux:
2037 network:
2038 purge_hosts: true
2039 mine_dns_records: true
2040 host:
2041 node1:
2042 address: 192.168.10.200
2043 grain: true
2044 names:
2045 - node2.domain.com
2046 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01002047
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04002048Set up ``resolvconf's basic resolver info``, e.g. nameservers, search/domain and options:
Filip Pytlounde9bea52016-01-11 15:39:10 +01002049
2050.. code-block:: yaml
2051
2052 linux:
2053 network:
2054 resolv:
2055 dns:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04002056 - 8.8.4.4
2057 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01002058 domain: my.example.com
2059 search:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04002060 - my.example.com
2061 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01002062 options:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04002063 - ndots:5
2064 - timeout:2
2065 - attempts:2
Filip Pytlounde9bea52016-01-11 15:39:10 +01002066
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002067Set up custom TX queue length for tap interfaces:
Andrii Petrenko735761d2017-03-21 17:17:35 -07002068
2069.. code-block:: yaml
2070
2071 linux:
2072 network:
2073 tap_custom_txqueuelen: 10000
2074
Michael Polenchuk6e3042b2019-04-22 15:20:03 +04002075Auto repair/re-attach libvirt's vnet interfaces:
2076
2077.. code-block:: yaml
2078
2079 linux:
2080 network:
2081 libvirt_vnet_repair: true
2082
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002083DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002084
2085**DPDK OVS NIC**
2086
2087.. code-block:: yaml
2088
2089 linux:
2090 network:
2091 bridge: openvswitch
2092 dpdk:
2093 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04002094 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002095 openvswitch:
2096 pmd_cpu_mask: "0x6"
2097 dpdk_socket_mem: "1024,1024"
2098 dpdk_lcore_mask: "0x400"
2099 memory_channels: 2
2100 interface:
2101 dpkd0:
2102 name: ${_param:dpdk_nic}
2103 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002104 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002105 enabled: true
2106 type: dpdk_ovs_port
2107 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002108 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002109 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01002110 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002111 br-prv:
2112 enabled: true
2113 type: dpdk_ovs_bridge
Michael Polenchukd3378db2018-12-29 16:46:50 +04002114 br-floating:
2115 enabled: true
2116 type: ovs_bridge
2117 name_servers:
2118 - 1.1.1.1
2119 - 9.9.9.9
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002120
2121**DPDK OVS Bond**
2122
2123.. code-block:: yaml
2124
2125 linux:
2126 network:
2127 bridge: openvswitch
2128 dpdk:
2129 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04002130 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002131 openvswitch:
2132 pmd_cpu_mask: "0x6"
2133 dpdk_socket_mem: "1024,1024"
2134 dpdk_lcore_mask: "0x400"
2135 memory_channels: 2
2136 interface:
2137 dpdk_second_nic:
2138 name: ${_param:primary_second_nic}
2139 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002140 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002141 bond: dpdkbond0
2142 enabled: true
2143 type: dpdk_ovs_port
2144 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002145 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002146 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002147 dpdk_first_nic:
2148 name: ${_param:primary_first_nic}
2149 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002150 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002151 bond: dpdkbond0
2152 enabled: true
2153 type: dpdk_ovs_port
2154 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002155 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002156 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002157 dpdkbond0:
2158 enabled: true
2159 bridge: br-prv
2160 type: dpdk_ovs_bond
2161 mode: active-backup
2162 br-prv:
2163 enabled: true
2164 type: dpdk_ovs_bridge
2165
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01002166**DPDK OVS LACP Bond with vlan tag**
2167
2168.. code-block:: yaml
2169
2170 linux:
2171 network:
2172 bridge: openvswitch
2173 dpdk:
2174 enabled: true
2175 driver: uio
2176 openvswitch:
2177 pmd_cpu_mask: "0x6"
2178 dpdk_socket_mem: "1024,1024"
2179 dpdk_lcore_mask: "0x400"
2180 memory_channels: "2"
2181 interface:
2182 eth3:
2183 enabled: true
2184 type: eth
2185 proto: manual
2186 name: ${_param:tenant_first_nic}
2187 eth4:
2188 enabled: true
2189 type: eth
2190 proto: manual
2191 name: ${_param:tenant_second_nic}
2192 dpdk0:
2193 name: ${_param:tenant_first_nic}
2194 pci: "0000:81:00.0"
2195 driver: igb_uio
2196 bond: bond1
2197 enabled: true
2198 type: dpdk_ovs_port
2199 n_rxq: 2
2200 dpdk1:
2201 name: ${_param:tenant_second_nic}
2202 pci: "0000:81:00.1"
2203 driver: igb_uio
2204 bond: bond1
2205 enabled: true
2206 type: dpdk_ovs_port
2207 n_rxq: 2
2208 bond1:
2209 enabled: true
2210 bridge: br-prv
2211 type: dpdk_ovs_bond
2212 mode: balance-slb
2213 br-prv:
2214 enabled: true
2215 type: dpdk_ovs_bridge
2216 tag: ${_param:tenant_vlan}
2217 address: ${_param:tenant_address}
2218 netmask: ${_param:tenant_network_netmask}
2219
Jakub Pavlikaa759062017-03-13 15:57:26 +01002220**DPDK OVS bridge for VXLAN**
2221
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002222If VXLAN is used as tenant segmentation, IP address must
2223be set on ``br-prv``.
Jakub Pavlikaa759062017-03-13 15:57:26 +01002224
2225.. code-block:: yaml
2226
2227 linux:
2228 network:
2229 ...
2230 interface:
2231 br-prv:
2232 enabled: true
2233 type: dpdk_ovs_bridge
2234 address: 192.168.50.0
2235 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04002236 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01002237 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002238
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02002239**DPDK OVS bridge with Linux network interface**
2240
2241.. code-block:: yaml
2242
2243 linux:
2244 network:
2245 ...
2246 interface:
2247 eth0:
2248 type: eth
2249 ovs_bridge: br-prv
2250 ...
2251 br-prv:
2252 enabled: true
2253 type: dpdk_ovs_bridge
2254 ...
2255
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002256Linux storage
2257-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02002258
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002259Linux with mounted Samba:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002260
2261.. code-block:: yaml
2262
2263 linux:
2264 storage:
2265 enabled: true
2266 mount:
2267 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01002268 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02002269 - path: /media/myuser/public/
2270 - device: //192.168.0.1/storage
2271 - file_system: cifs
2272 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
2273
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002274NFS mount:
Jiri Broulikb017f932017-03-31 13:55:36 +02002275
2276.. code-block:: yaml
2277
2278 linux:
2279 storage:
2280 enabled: true
2281 mount:
2282 nfs_glance:
2283 enabled: true
2284 path: /var/lib/glance/images
2285 device: 172.16.10.110:/var/nfs/glance
2286 file_system: nfs
2287 opts: rw,sync
2288
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002289File swap configuration:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002290
2291.. code-block:: yaml
2292
2293 linux:
2294 storage:
2295 enabled: true
2296 swap:
2297 file:
2298 enabled: true
2299 engine: file
2300 device: /swapfile
2301 size: 1024
2302
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002303Partition swap configuration:
Lachlan Evenson30676512016-01-22 15:43:28 -08002304
2305.. code-block:: yaml
2306
2307 linux:
2308 storage:
2309 enabled: true
2310 swap:
2311 partition:
2312 enabled: true
2313 engine: partition
2314 device: /dev/vg0/swap
2315
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002316LVM group ``vg1`` with one device and ``data`` volume mounted
2317into ``/mnt/data``.
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002318
2319.. code-block:: yaml
2320
2321 parameters:
2322 linux:
2323 storage:
2324 mount:
2325 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01002326 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002327 device: /dev/vg1/data
2328 file_system: ext4
2329 path: /mnt/data
2330 lvm:
2331 vg1:
2332 enabled: true
2333 devices:
2334 - /dev/sdb
2335 volume:
2336 data:
2337 size: 40G
2338 mount: ${linux:storage:mount:data}
root40bb5e72019-01-11 08:55:32 +00002339 # When set they will take precedence over filters aget from volume groups.
2340 lvm_filters:
2341 10:
2342 enabled: True
2343 value: "a|loop|"
2344 20:
2345 enabled: True
2346 value: "r|/dev/hdc|"
2347 30:
2348 enabled: True
2349 value: "a|/dev/ide|"
2350 40:
2351 enabled: True
2352 value: "r|.*|"
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002353
Jakub Pavlik4f742142017-08-08 15:05:50 +02002354Create partitions on disk. Specify size in MB. It expects empty
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002355disk without any existing partitions.
2356Set ``startsector=1`` if you want to start partitions from ``2048``.
Jakub Pavlik4f742142017-08-08 15:05:50 +02002357
2358.. code-block:: yaml
2359
2360 linux:
2361 storage:
2362 disk:
2363 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01002364 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02002365 name: /dev/loop1
2366 type: gpt
2367 partitions:
2368 - size: 200 #size in MB
2369 type: fat32
2370 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02002371 mkfs: True
2372 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02002373 /dev/vda1:
2374 partitions:
2375 - size: 5
2376 type: ext2
2377 - size: 10
2378 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02002379
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002380Multipath with Fujitsu Eternus DXL:
Ales Komareka634f4b2016-10-02 13:11:04 +02002381
2382.. code-block:: yaml
2383
2384 parameters:
2385 linux:
2386 storage:
2387 multipath:
2388 enabled: true
2389 blacklist_devices:
2390 - /dev/sda
2391 - /dev/sdb
2392 backends:
2393 - fujitsu_eternus_dxl
2394
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002395Multipath with Hitachi VSP 1000:
Ales Komareka634f4b2016-10-02 13:11:04 +02002396
2397.. code-block:: yaml
2398
2399 parameters:
2400 linux:
2401 storage:
2402 multipath:
2403 enabled: true
2404 blacklist_devices:
2405 - /dev/sda
2406 - /dev/sdb
2407 backends:
2408 - hitachi_vsp1000
2409
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002410Multipath with IBM Storwize:
Ales Komareka634f4b2016-10-02 13:11:04 +02002411
2412.. code-block:: yaml
2413
2414 parameters:
2415 linux:
2416 storage:
2417 multipath:
2418 enabled: true
2419 blacklist_devices:
2420 - /dev/sda
2421 - /dev/sdb
2422 backends:
2423 - ibm_storwize
2424
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002425Multipath with multiple backends:
Ales Komareka634f4b2016-10-02 13:11:04 +02002426
2427.. code-block:: yaml
2428
2429 parameters:
2430 linux:
2431 storage:
2432 multipath:
2433 enabled: true
2434 blacklist_devices:
2435 - /dev/sda
2436 - /dev/sdb
2437 - /dev/sdc
2438 - /dev/sdd
2439 backends:
2440 - ibm_storwize
2441 - fujitsu_eternus_dxl
2442 - hitachi_vsp1000
2443
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002444PAM LDAP integration:
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002445
2446.. code-block:: yaml
2447
2448 parameters:
2449 linux:
2450 system:
2451 auth:
2452 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02002453 mkhomedir:
2454 enabled: true
2455 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002456 ldap:
2457 enabled: true
2458 binddn: cn=bind,ou=service_users,dc=example,dc=com
2459 bindpw: secret
2460 uri: ldap://127.0.0.1
2461 base: ou=users,dc=example,dc=com
2462 ldap_version: 3
2463 pagesize: 65536
2464 referrals: off
2465 filter:
2466 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2467 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2468 group: (&(objectClass=group)(gidNumber=*))
2469
Gleb Galkin93b9ae92018-10-18 13:57:30 +03002470PAM duo 2FA integration
2471
2472.. code-block:: yaml
2473
2474 parameters:
2475 linux:
2476 system:
2477 auth:
2478 enabled: true
2479 duo:
2480 enabled: true
2481 duo_host: localhost
2482 duo_ikey: DUO-INTEGRATION-KEY
2483 duo_skey: DUO-SECRET-KEY
2484
2485duo package version may be specified (optional)
2486
2487.. code-block:: yaml
2488
2489 linux:
2490 system:
2491 package:
2492 duo-unix:
2493 version: 1.10.1-0
2494
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002495Disabled multipath (the default setup):
Ales Komareka634f4b2016-10-02 13:11:04 +02002496
2497.. code-block:: yaml
2498
2499 parameters:
2500 linux:
2501 storage:
2502 multipath:
2503 enabled: false
2504
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002505Linux with local loopback device:
Simon Pasquier375001e2017-01-26 13:22:33 +01002506
2507.. code-block:: yaml
2508
2509 linux:
2510 storage:
2511 loopback:
2512 disk1:
2513 file: /srv/disk1
2514 size: 50G
2515
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002516External config generation
2517--------------------------
2518
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002519You are able to use config support metadata between formulas
2520and only generate configuration files for external use, for example, Docker, and so on.
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002521
2522.. code-block:: yaml
2523
2524 parameters:
2525 linux:
2526 system:
2527 config:
2528 pillar:
2529 jenkins:
2530 master:
2531 home: /srv/volumes/jenkins
2532 approved_scripts:
2533 - method java.net.URL openConnection
2534 credentials:
2535 - type: username_password
2536 scope: global
2537 id: test
2538 desc: Testing credentials
2539 username: test
2540 password: test
2541
Vladimir Ereminccf28842017-04-10 23:52:10 +03002542Netconsole Remote Kernel Logging
2543--------------------------------
2544
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002545Netconsole logger can be configured for the configfs-enabled kernels
2546(``CONFIG_NETCONSOLE_DYNAMIC`` must be enabled). The configuration
2547applies both in runtime (if network is already configured),
2548and on-boot after an interface initialization.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002549
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002550.. note::
2551
2552 * Receiver can be located only on the same L3 domain
2553 (or you need to configure gateway MAC manually).
2554 * The Receiver MAC is detected only on configuration time.
2555 * Using broadcast MAC is not recommended.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002556
2557.. code-block:: yaml
2558
2559 parameters:
2560 linux:
2561 system:
2562 netconsole:
2563 enabled: true
2564 port: 514 (optional)
2565 loglevel: debug (optional)
2566 target:
2567 192.168.0.1:
2568 interface: bond0
2569 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02002570
Dzmitry Stremkouskid1a268b2018-10-03 16:36:04 +02002571Check network params on the environment
2572---------------------------------------
2573
2574Grab nics and nics states
2575
2576.. code-block:: bash
2577
2578 salt osd001\* net_checks.get_nics
2579
2580**Example of system output:**
2581
2582.. code-block:: bash
2583
2584 osd001.domain.com:
2585 |_
2586 - bond0
2587 - None
2588 - 1e:c8:64:42:23:b9
2589 - 0
2590 - 1500
2591 |_
2592 - bond1
2593 - None
2594 - 3c:fd:fe:27:3b:00
2595 - 1
2596 - 9100
2597 |_
2598 - fourty1
2599 - None
2600 - 3c:fd:fe:27:3b:00
2601 - 1
2602 - 9100
2603 |_
2604 - fourty2
2605 - None
2606 - 3c:fd:fe:27:3b:02
2607 - 1
2608 - 9100
2609
2610Grab 10G nics PCI addresses for hugepages setup
2611
2612.. code-block:: bash
2613
2614 salt cmp001\* net_checks.get_ten_pci
2615
2616**Example of system output:**
2617
2618.. code-block:: bash
2619
2620 cmp001.domain.com:
2621 |_
2622 - ten1
2623 - 0000:19:00.0
2624 |_
2625 - ten2
2626 - 0000:19:00.1
2627 |_
2628 - ten3
2629 - 0000:19:00.2
2630 |_
2631 - ten4
2632 - 0000:19:00.3
2633
2634Grab ip address for an interface
2635
2636.. code-block:: bash
2637
2638 salt cmp001\* net_checks.get_ip iface=one4
2639
2640**Example of system output:**
2641
2642.. code-block:: bash
2643
2644 cmp001.domain.com:
2645 10.200.177.101
2646
2647Grab ip addresses map
2648
2649.. code-block:: bash
2650
2651 salt-call net_checks.nodes_addresses
2652
2653**Example of system output:**
2654
2655.. code-block:: bash
2656
2657 local:
2658 |_
2659 - cid01.domain.com
2660 |_
2661 |_
2662 - pxe
2663 - 10.200.177.91
2664 |_
2665 - control
2666 - 10.200.178.91
2667 |_
2668 - cmn02.domain.com
2669 |_
2670 |_
2671 - storage_access
2672 - 10.200.181.67
2673 |_
2674 - pxe
2675 - 10.200.177.67
2676 |_
2677 - control
2678 - 10.200.178.67
2679 |_
2680 - cmp010.domain.com
2681 |_
2682 |_
2683 - pxe
2684 - 10.200.177.110
2685 |_
2686 - storage_access
2687 - 10.200.181.110
2688 |_
2689 - control
2690 - 10.200.178.110
2691 |_
2692 - vxlan
2693 - 10.200.179.110
2694
2695Verify full mesh connectivity
2696
2697.. code-block:: bash
2698
2699 salt-call net_checks.ping_check
2700
2701**Example of positive system output:**
2702
2703.. code-block:: bash
2704
2705 ['PASSED']
2706 [INFO ] ['PASSED']
2707 local:
2708 True
2709
2710**Example of system output in case of failure:**
2711
2712.. code-block:: bash
2713
2714 FAILED
2715 [ERROR ] FAILED
2716 ['control: 10.0.1.92 -> 10.0.1.224: Failed']
2717 ['control: 10.0.1.93 -> 10.0.1.224: Failed']
2718 ['control: 10.0.1.51 -> 10.0.1.224: Failed']
2719 ['control: 10.0.1.102 -> 10.0.1.224: Failed']
2720 ['control: 10.0.1.13 -> 10.0.1.224: Failed']
2721 ['control: 10.0.1.81 -> 10.0.1.224: Failed']
2722 local:
2723 False
2724
2725For this feature to work, please mark addresses with some role.
2726Otherwise 'default' role is assumed and mesh would consist of all
2727addresses on the environment.
2728
2729Mesh mark is needed only for interfaces which are enabled and have
2730ip address assigned.
2731
2732Checking dhcp pxe network meaningless, as it is used for salt
2733master vs minion communications, therefore treated as checked.
2734
2735.. code-block:: yaml
2736
2737 parameters:
2738 linux:
2739 network:
2740 interface:
2741 ens3:
2742 enabled: true
2743 type: eth
2744 proto: static
2745 address: ${_param:deploy_address}
2746 netmask: ${_param:deploy_network_netmask}
2747 gateway: ${_param:deploy_network_gateway}
2748 mesh: pxe
2749
2750Check pillars for ip address duplicates
2751
2752.. code-block:: bash
2753
2754 salt-call net_checks.verify_addresses
2755
2756**Example of positive system output:**
2757
2758.. code-block:: bash
2759
2760 ['PASSED']
2761 [INFO ] ['PASSED']
2762 local:
2763 True
2764
2765**Example of system output in case of failure:**
2766
2767.. code-block:: bash
2768
2769 FAILED. Duplicates found
2770 [ERROR ] FAILED. Duplicates found
2771 ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2772 [ERROR ] ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2773 local:
2774 False
2775
2776Generate csv report for the env
2777
2778.. code-block:: bash
2779
2780 salt -C 'kvm* or cmp* or osd*' net_checks.get_nics_csv \
2781 | grep '^\ ' | sed 's/\ *//g' | grep -Ev ^server \
2782 | sed '1 i\server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr'
2783
2784**Example of system output:**
2785
2786.. code-block:: bash
2787
2788 server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr
2789 cmp010.domain.com,bond0,None,b4:96:91:10:5b:3a,1,1500,,,,
2790 cmp010.domain.com,bond0.21,10.200.178.110,b4:96:91:10:5b:3a,1,1500,,,,
2791 cmp010.domain.com,bond0.22,10.200.179.110,b4:96:91:10:5b:3a,1,1500,,,,
2792 cmp010.domain.com,bond1,None,3c:fd:fe:34:ad:22,0,1500,,,,
2793 cmp010.domain.com,bond1.24,10.200.181.110,3c:fd:fe:34:ad:22,0,1500,,,,
2794 cmp010.domain.com,fourty5,None,3c:fd:fe:34:ad:20,0,9000,,,,
2795 cmp010.domain.com,fourty6,None,3c:fd:fe:34:ad:22,0,9000,,,,
2796 cmp010.domain.com,one1,None,b4:96:91:10:5b:38,0,1500,,,,
2797 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
2798 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
2799 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
2800 cmp011.domain.com,bond0,None,b4:96:91:13:6c:aa,1,1500,,,,
2801 cmp011.domain.com,bond0.21,10.200.178.111,b4:96:91:13:6c:aa,1,1500,,,,
2802 cmp011.domain.com,bond0.22,10.200.179.111,b4:96:91:13:6c:aa,1,1500,,,,
2803 ...
2804
Filip Pytlounf5383a42015-10-06 16:28:32 +02002805Usage
2806=====
2807
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002808Set MTU of the eth0 network interface to 1400:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002809
2810.. code-block:: bash
2811
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002812 ip link set dev eth0 mtu 1400
Filip Pytlounf5383a42015-10-06 16:28:32 +02002813
2814Read more
2815=========
2816
2817* https://www.archlinux.org/
2818* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu