blob: f8ad2165bef105f8fffdc8f2243b483b0ccdf989 [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
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300549Ensure presence of file to be serialized through one of the
550serializer modules (see:
551https://docs.saltstack.com/en/latest/ref/serializers/all/index.html):
Bruno Binet9c2fe222018-06-08 16:57:32 +0200552
553.. code-block:: yaml
554
555 linux:
556 system:
557 file:
558 /tmp/test.json:
559 serialize: json
560 contents:
561 foo: 1
562 bar: 'bar'
563
agoriunovd7b19ce2019-02-18 11:37:32 +0200564Ensure presence of file to be decoded through file.decode module (see:
565https://docs.saltstack.com/en/latest/ref/states/all/salt.states.file.html#salt.states.file.decode):
566
567.. code-block:: yaml
568
569 linux:
570 system:
571 file:
572 /tmp/test4.txt:
573 decode: True
574 encoded_data: |
575 dGVzdDQK
576
Filip Pytloun281034a2016-01-04 18:06:22 +0100577Kernel
578~~~~~~
579
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300580Install always up to date LTS kernel and headers from Ubuntu Trusty:
Filip Pytloun281034a2016-01-04 18:06:22 +0100581
582.. code-block:: yaml
583
584 linux:
585 system:
586 kernel:
587 type: generic
588 lts: trusty
589 headers: true
590
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300591Load kernel modules and add them to ``/etc/modules``:
Tomáš Kukrálba35b212017-02-15 17:59:46 +0100592
593.. code-block:: yaml
594
595 linux:
596 system:
597 kernel:
598 modules:
599 - nf_conntrack
600 - tp_smapi
601 - 8021q
602
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300603Configure or blacklist kernel modules with additional options to
604``/etc/modprobe.d`` following example will add
605``/etc/modprobe.d/nf_conntrack.conf`` file with line
606``options nf_conntrack hashsize=262144``:
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300607
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300608'option' can be a mapping (with 'enabled' and 'value' keys) or a scalar.
609
610Example for 'scalar' option value:
611
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300612.. code-block:: yaml
613
614 linux:
615 system:
616 kernel:
617 module:
618 nf_conntrack:
619 option:
620 hashsize: 262144
621
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300622Example for 'mapping' option value:
623
624.. code-block:: yaml
625
626 linux:
627 system:
628 kernel:
629 module:
630 nf_conntrack:
631 option:
632 hashsize:
633 enabled: true
634 value: 262144
635
636NOTE: 'enabled' key is optional and is True by default.
637
638Blacklist a module:
639
640.. code-block:: yaml
641
642 linux:
643 system:
644 kernel:
645 module:
646 nf_conntrack:
647 blacklist: true
648
649A module can have a number of aliases, wildcards are allowed.
650Define an alias for a module:
651
652.. code-block:: yaml
653
654 linux:
655 system:
656 kernel:
657 module:
658 nf_conntrack:
659 alias:
660 nfct:
661 enabled: true
662 "nf_conn*":
663 enabled: true
664
665NOTE: 'enabled' key is mandatory as there are no other keys exist.
666
667Execute custom command instead of 'insmod' when inserting a module:
668
669.. code-block:: yaml
670
671 linux:
672 system:
673 kernel:
674 module:
675 nf_conntrack:
676 install:
677 enabled: true
678 command: /bin/true
679
680NOTE: 'enabled' key is optional and is True by default.
681
682Execute custom command instead of 'rmmod' when removing a module:
683
684.. code-block:: yaml
685
686 linux:
687 system:
688 kernel:
689 module:
690 nf_conntrack:
691 remove:
692 enabled: true
693 command: /bin/true
694
695NOTE: 'enabled' key is optional and is True by default.
696
697Define module dependencies:
698
699.. code-block:: yaml
700
701 linux:
702 system:
703 kernel:
704 module:
705 nf_conntrack:
706 softdep:
707 pre:
708 1:
709 enabled: true
710 value: a
711 2:
712 enabled: true
713 value: b
714 3:
715 enabled: true
716 value: c
717 post:
718 1:
719 enabled: true
720 value: x
721 2:
722 enabled: true
723 value: y
724 3:
725 enabled: true
726 value: z
727
728NOTE: 'enabled' key is optional and is True by default.
729
730
Filip Pytloun281034a2016-01-04 18:06:22 +0100731Install specific kernel version and ensure all other kernel packages are
732not present. Also install extra modules and headers for this kernel:
733
734.. code-block:: yaml
735
736 linux:
737 system:
738 kernel:
739 type: generic
740 extra: true
741 headers: true
742 version: 4.2.0-22
743
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300744Systcl kernel parameters:
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100745
746.. code-block:: yaml
747
748 linux:
749 system:
750 kernel:
751 sysctl:
752 net.ipv4.tcp_keepalive_intvl: 3
753 net.ipv4.tcp_keepalive_time: 30
754 net.ipv4.tcp_keepalive_probes: 8
755
Michael Polenchukebf55522018-01-25 13:22:39 +0400756Configure kernel boot options:
757
758.. code-block:: yaml
759
760 linux:
761 system:
762 kernel:
763 boot_options:
764 - elevator=deadline
765 - spectre_v2=off
766 - nopti
767
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100768CPU
769~~~
770
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300771Enable cpufreq governor for every cpu:
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100772
773.. code-block:: yaml
774
775 linux:
776 system:
777 cpu:
778 governor: performance
779
Nick Metzf04f5f32018-01-08 15:25:04 +0100780
Jiri Broulik303905d2018-01-11 14:12:48 +0100781CGROUPS
782~~~~~~~
783
784Setup linux cgroups:
785
786.. code-block:: yaml
787
788 linux:
789 system:
790 cgroup:
791 enabled: true
792 group:
793 ceph_group_1:
794 controller:
795 cpu:
796 shares:
797 value: 250
798 cpuacct:
799 usage:
800 value: 0
801 cpuset:
802 cpus:
803 value: 1,2,3
804 memory:
805 limit_in_bytes:
806 value: 2G
807 memsw.limit_in_bytes:
808 value: 3G
809 mapping:
810 subjects:
811 - '@ceph'
812 generic_group_1:
813 controller:
814 cpu:
815 shares:
816 value: 250
817 cpuacct:
818 usage:
819 value: 0
820 mapping:
821 subjects:
822 - '*:firefox'
823 - 'student:cp'
824
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300825Shared libraries
Nick Metzf04f5f32018-01-08 15:25:04 +0100826~~~~~~~~~~~~~~~~
827
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300828Set additional shared library to Linux system library path:
Nick Metzf04f5f32018-01-08 15:25:04 +0100829
830.. code-block:: yaml
831
832 linux:
833 system:
834 ld:
835 library:
836 java:
837 - /usr/lib/jvm/jre-openjdk/lib/amd64/server
838 - /opt/java/jre/lib/amd64/server
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200839
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200840Certificates
841~~~~~~~~~~~~
842
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300843Add certificate authority into system trusted CA bundle:
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200844
845.. code-block:: yaml
846
847 linux:
848 system:
849 ca_certificates:
850 mycert: |
851 -----BEGIN CERTIFICATE-----
852 MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
853 A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
854 cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
855 MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
856 BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
857 YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
858 ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
859 BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
860 I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
861 CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
862 lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
863 AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
864 -----END CERTIFICATE-----
865
Filip Pytloun361096c2017-08-23 10:57:20 +0200866Sysfs
867~~~~~
868
869Install sysfsutils and set sysfs attributes:
870
871.. code-block:: yaml
872
873 linux:
874 system:
875 sysfs:
876 scheduler:
877 block/sda/queue/scheduler: deadline
878 power:
879 mode:
880 power/state: 0660
881 owner:
882 power/state: "root:power"
883 devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
884
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200885Optional: You can also use list that will ensure order of items.
886
887.. code-block:: yaml
888
889 linux:
890 system:
891 sysfs:
892 scheduler:
893 block/sda/queue/scheduler: deadline
894 power:
895 - mode:
896 power/state: 0660
897 - owner:
898 power/state: "root:power"
899 - devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
900
Martin Polreich148e1b82018-09-13 15:54:25 +0200901Sysfs definition with disabled automatic write. Attributes are saved
902to configuration, but are not applied during the run.
903Thay will be applied automatically after the reboot.
904
905
906.. code-block:: yaml
907
908 linux:
909 system:
910 sysfs:
911 enable_apply: false
912 scheduler:
913 block/sda/queue/scheduler: deadline
914
915.. note:: The `enable_apply` parameter defaults to `True` if not defined.
916
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100917Huge Pages
918~~~~~~~~~~~~
919
920Huge Pages give a performance boost to applications that intensively deal
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300921with memory allocation/deallocation by decreasing memory fragmentation:
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100922
923.. code-block:: yaml
924
925 linux:
926 system:
927 kernel:
928 hugepages:
929 small:
930 size: 2M
931 count: 107520
932 mount_point: /mnt/hugepages_2MB
Michael Polenchukd9369fe2018-05-08 17:53:08 +0400933 mount: false/true # default is true (mount immediately) / false (just save in the fstab)
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100934 large:
935 default: true # default automatically mounted
936 size: 1G
937 count: 210
938 mount_point: /mnt/hugepages_1GB
939
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300940.. note:: Not recommended to use both pagesizes concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100941
Jakub Pavlik5398d872017-02-13 22:30:47 +0100942Intel SR-IOV
943~~~~~~~~~~~~
944
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300945PCI-SIG Single Root I/O Virtualization and Sharing (SR-IOV)
946specification defines a standardized mechanism to virtualize
947PCIe devices. The mechanism can virtualize a single PCIe
948Ethernet controller to appear as multiple PCIe devices:
Jakub Pavlik5398d872017-02-13 22:30:47 +0100949
950.. code-block:: yaml
951
952 linux:
953 system:
954 kernel:
955 sriov: True
956 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
957 rc:
958 local: |
959 #!/bin/sh -e
960 # Enable 7 VF on eth1
961 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
962 exit 0
963
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100964Isolate CPU options
965~~~~~~~~~~~~~~~~~~~
966
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300967Remove the specified CPUs, as defined by the cpu_number values, from
968the general kernel SMP balancing and scheduler algroithms. The only
969way to move a process onto or off an *isolated* CPU is via the CPU
970affinity syscalls. ``cpu_number begins`` at ``0``, so the
971maximum value is ``1`` less than the number of CPUs on the system.:
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100972
973.. code-block:: yaml
974
975 linux:
976 system:
977 kernel:
978 isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100979
Filip Pytlounf5383a42015-10-06 16:28:32 +0200980Repositories
981~~~~~~~~~~~~
982
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300983RedHat-based Linux with additional OpenStack repo:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200984
985.. code-block:: yaml
986
987 linux:
988 system:
989 ...
990 repo:
991 rdo-icehouse:
992 enabled: true
993 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
994 pgpcheck: 0
995
996Ensure system repository to use czech Debian mirror (``default: true``)
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300997Also pin it's packages with priority ``900``:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200998
999.. code-block:: yaml
1000
1001 linux:
1002 system:
1003 repo:
1004 debian:
1005 default: true
1006 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
1007 # Import signing key from URL if needed
1008 key_url: "http://dummy.com/public.gpg"
1009 pin:
1010 - pin: 'origin "ftp.cz.debian.org"'
1011 priority: 900
1012 package: '*'
1013
azvyagintseva3a73d02018-12-06 14:49:58 +02001014Sometimes better to use one pining rule file, to decrease mistaken
1015ordering. You can use those option ``system:apt:preferences``, which would add opts into
1016``/etc/apt/preferences`` file:
1017
1018.. code-block:: yaml
1019
1020 parameters:
1021 linux:
1022 system:
1023 apt:
1024 preferences:
1025 enabled: true
1026 rules:
1027 100:
1028 enabled: true
1029 name: 'some origin pin'
1030 pin: 'release o=Debian'
1031 priority: 1100
1032 package: '*'
1033
1034
azvyagintsev4494a472018-09-14 19:19:23 +03001035If you need to add multiple pin rules for one repo, please use new,ordered definition format
1036('pinning' definition will be in priotity to use):
1037
1038.. code-block:: yaml
1039
1040 linux:
1041 system:
1042 repo:
1043 mcp_saltstack:
1044 source: "deb [arch=amd64] http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/ xenial main"
1045 architectures: amd64
1046 clean_file: true
1047 pinning:
1048 10:
1049 enabled: true
1050 pin: 'release o=SaltStack'
1051 priority: 50
1052 package: 'libsodium18'
1053 20:
1054 enabled: true
1055 pin: 'release o=SaltStack'
1056 priority: 1100
1057 package: '*'
1058
1059
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001060.. note:: For old Ubuntu releases (<xenial)
azvyagintsevff089d22018-07-27 16:52:34 +02001061 extra packages for apt transport, like ``apt-transport-https``
1062 may be required to be installed manually.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001063 (Chicken-eggs issue: we need to install packages to
azvyagintsevff089d22018-07-27 16:52:34 +02001064 reach repo from where they should be installed)
1065 Otherwise, you still can try 'fortune' and install prereq.packages before
1066 any repo configuration, using list of requires in map.jinja.
1067
1068
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001069Disabling any prerequisite packages installation:
1070
azvyagintsevff089d22018-07-27 16:52:34 +02001071You can simply drop any package pre-installation (before system.linux.repo
1072will be processed) via cluster lvl:
1073
1074.. code-block:: yaml
1075
1076 linux:
1077 system:
1078 pkgs: ~
1079
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001080Package manager proxy global setup:
Petr Michalec10462bb2017-03-23 19:18:08 +01001081
1082.. code-block:: yaml
1083
1084 linux:
1085 system:
1086 ...
1087 repo:
1088 apt-mk:
1089 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1090 ...
1091 proxy:
1092 pkg:
1093 enabled: true
1094 ftp: ftp://ftp-proxy-for-apt.host.local:2121
1095 ...
1096 # NOTE: Global defaults for any other componet that configure proxy on the system.
1097 # If your environment has just one simple proxy, set it on linux:system:proxy.
1098 #
1099 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
1100 # as for https and http
1101 ftp: ftp://proxy.host.local:2121
1102 http: http://proxy.host.local:3142
1103 https: https://proxy.host.local:3143
1104
1105Package manager proxy setup per repository:
1106
1107.. code-block:: yaml
1108
1109 linux:
1110 system:
1111 ...
1112 repo:
1113 debian:
1114 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1115 ...
1116 apt-mk:
1117 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1118 # per repository proxy
1119 proxy:
1120 enabled: true
1121 http: http://maas-01:8080
1122 https: http://maas-01:8080
1123 ...
1124 proxy:
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001125 # package manager fallback defaults
Petr Michalec10462bb2017-03-23 19:18:08 +01001126 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
1127 pkg:
1128 enabled: true
1129 ftp: ftp://proxy.host.local:2121
1130 #http: http://proxy.host.local:3142
1131 #https: https://proxy.host.local:3143
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001132 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001133 # global system fallback system defaults
1134 ftp: ftp://proxy.host.local:2121
1135 http: http://proxy.host.local:3142
1136 https: https://proxy.host.local:3143
1137
Jiri Broulik34a29b42017-04-25 14:42:54 +02001138Remove all repositories:
1139
1140.. code-block:: yaml
1141
1142 linux:
1143 system:
1144 purge_repos: true
1145
azvyagintsevff089d22018-07-27 16:52:34 +02001146Refresh repositories metada, after configuration:
1147
1148.. code-block:: yaml
1149
1150 linux:
1151 system:
1152 refresh_repos_meta: true
1153
Filip Pytlounc512e6c2017-11-22 14:28:10 +01001154Setup custom apt config options:
1155
1156.. code-block:: yaml
1157
1158 linux:
1159 system:
1160 apt:
1161 config:
1162 compression-workaround:
1163 "Acquire::CompressionTypes::Order": "gz"
1164 docker-clean:
1165 "DPkg::Post-Invoke":
1166 - "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"
1167 "APT::Update::Post-Invoke":
1168 - "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 +02001169
Petr Michalec10462bb2017-03-23 19:18:08 +01001170RC
1171~~
1172
Jakub Pavlik78859382016-01-21 11:26:39 +01001173rc.local example
1174
1175.. code-block:: yaml
1176
1177 linux:
1178 system:
1179 rc:
1180 local: |
1181 #!/bin/sh -e
1182 #
1183 # rc.local
1184 #
1185 # This script is executed at the end of each multiuser runlevel.
1186 # Make sure that the script will "exit 0" on success or any other
1187 # value on error.
1188 #
1189 # In order to enable or disable this script just change the execution
1190 # bits.
1191 #
1192 # By default this script does nothing.
1193 exit 0
1194
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001195Prompt
1196~~~~~~
1197
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001198Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``.
1199Every user can have different prompt:
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001200
1201.. code-block:: yaml
1202
1203 linux:
1204 system:
1205 prompt:
1206 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\\]
1207 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
1208
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001209On Debian systems, to set prompt system-wide, it's necessary to
1210remove setting PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc``,
1211which comes from ``/etc/skel/.bashrc``. This formula will do
1212this automatically, but will not touch existing user's
1213``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +01001214
Filip Pytlouneef11c12016-03-25 11:00:23 +01001215Bash
1216~~~~
1217
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001218Fix bash configuration to preserve history across sessions
1219like ZSH does by default:
Filip Pytlouneef11c12016-03-25 11:00:23 +01001220
1221.. code-block:: yaml
1222
1223 linux:
1224 system:
1225 bash:
1226 preserve_history: true
1227
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001228Login banner message
1229~~~~~~~~~~~~~~~~~~~~
1230
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001231``/etc/issue`` is a text file which contains a message or system
1232identification to be printed before the login prompt. It may contain
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001233various @char and \char sequences, if supported by the getty-type
1234program employed on the system.
1235
1236Setting logon banner message is easy:
1237
1238.. code-block:: yaml
1239
1240 liunx:
1241 system:
1242 banner:
1243 enabled: true
1244 contents: |
1245 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1246
1247 You must have explicit, authorized permission to access or configure this
1248 device. Unauthorized attempts and actions to access or use this system may
1249 result in civil and/or criminal penalties.
1250 All activities performed on this system are logged and monitored.
1251
Filip Pytloune874dfb2016-01-22 16:57:34 +01001252Message of the day
1253~~~~~~~~~~~~~~~~~~
1254
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001255``pam_motd`` from package ``libpam-modules`` is used for dynamic
1256messages of the day. Setting custom ``motd`` will clean up existing ones.
Filip Pytloune874dfb2016-01-22 16:57:34 +01001257
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001258Setting static ``motd`` will replace existing ``/etc/motd`` and remove
1259scripts from ``/etc/update-motd.d``.
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001260
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001261Setting static ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001262
1263.. code-block:: yaml
1264
1265 linux:
1266 system:
1267 motd: |
1268 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1269
1270 You must have explicit, authorized permission to access or configure this
1271 device. Unauthorized attempts and actions to access or use this system may
1272 result in civil and/or criminal penalties.
1273 All activities performed on this system are logged and monitored.
1274
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001275Setting dynamic ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001276
Filip Pytloune874dfb2016-01-22 16:57:34 +01001277.. code-block:: yaml
1278
1279 linux:
1280 system:
1281 motd:
1282 - release: |
1283 #!/bin/sh
1284 [ -r /etc/lsb-release ] && . /etc/lsb-release
1285
1286 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
1287 # Fall back to using the very slow lsb_release utility
1288 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
1289 fi
1290
1291 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
1292 - warning: |
1293 #!/bin/sh
1294 printf "This is [company name] network.\n"
1295 printf "Unauthorized access strictly prohibited.\n"
1296
Marek Celoud713e9072017-05-18 15:20:25 +02001297Services
1298~~~~~~~~
1299
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001300Stop and disable the ``linux`` service:
Marek Celoud713e9072017-05-18 15:20:25 +02001301
1302.. code-block:: yaml
1303
1304 linux:
1305 system:
1306 service:
1307 apt-daily.timer:
1308 status: dead
1309
Dzmitry Stremkouski70d09782018-11-30 16:04:59 +01001310Override systemd service unit:
1311
1312.. code-block:: yaml
1313
1314 parameters:
1315
1316 linux:
1317 system:
1318 service:
1319 tgt:
1320 name: tgt
1321 status: running
1322 enabled: True
1323 override:
1324 50:
1325 target: tgt.service.d
1326 name: bind
1327 content: |
1328 [Service]
1329 ExecStart=
1330 ExecStart=/usr/sbin/tgtd -f --iscsi portal=${_param:single_address}:3260
1331
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001332Possible statuses are ``dead`` (disable service by default), ``running``
1333(enable service by default), ``enabled``, ``disabled``:
Marek Celoud713e9072017-05-18 15:20:25 +02001334
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001335Linux with the ``atop`` service:
Serhiy Ovsianikov67bd56a2017-08-11 15:56:01 +03001336
1337.. code-block:: yaml
1338
1339 linux:
1340 system:
1341 atop:
1342 enabled: true
1343 interval: 20
1344 logpath: "/var/log/atop"
1345 outfile: "/var/log/atop/daily.log"
1346
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001347Linux with the ``mcelog`` service:
Oleksii Chupryn144432b2018-05-22 10:34:48 +03001348
1349.. code-block:: yaml
1350
1351 linux:
1352 system:
1353 mcelog:
1354 enabled: true
1355 logging:
1356 syslog: true
1357 syslog_error: true
1358
Filip Pytloun2f70b492016-02-19 15:55:25 +01001359RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +01001360^^^^^^^^^^^^^
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001361Currently, ``update-motd`` is not available
1362for RHEL. So there is no native support for dynamic ``motd``.
1363You can still set a static one, with a different pillar structure:
Filip Pytloun2f70b492016-02-19 15:55:25 +01001364
1365.. code-block:: yaml
1366
1367 linux:
1368 system:
1369 motd: |
1370 This is [company name] network.
1371 Unauthorized access strictly prohibited.
1372
Filip Pytloun8296bb92016-02-19 18:42:09 +01001373Haveged
1374~~~~~~~
1375
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001376If you are running headless server and are low on entropy,
1377you may set up Haveged:
Filip Pytloun8296bb92016-02-19 18:42:09 +01001378
1379.. code-block:: yaml
1380
1381 linux:
1382 system:
1383 haveged:
1384 enabled: true
1385
Filip Pytlounf5383a42015-10-06 16:28:32 +02001386Linux network
1387-------------
1388
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001389Linux with network manager:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001390
1391.. code-block:: yaml
1392
1393 linux:
1394 network:
1395 enabled: true
1396 network_manager: true
1397
Dzmitry Stremkouski00cdbe62018-10-31 16:41:54 +01001398Execute linux.network.interface state without ifupdown activity:
1399
1400.. code-block:: bash
1401
1402 salt-call linux.network.interface pillar='{"linux":{"network":{"noifupdown":True}}}'
1403
1404
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001405Linux with default static network interfaces, default gateway
1406interface and DNS servers:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001407
1408.. code-block:: yaml
1409
1410 linux:
1411 network:
1412 enabled: true
1413 interface:
1414 eth0:
1415 enabled: true
1416 type: eth
1417 address: 192.168.0.102
1418 netmask: 255.255.255.0
1419 gateway: 192.168.0.1
1420 name_servers:
1421 - 8.8.8.8
1422 - 8.8.4.4
1423 mtu: 1500
1424
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001425Linux with bonded interfaces and disabled ``NetworkManager``:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001426
1427.. code-block:: yaml
1428
1429 linux:
1430 network:
1431 enabled: true
1432 interface:
1433 eth0:
1434 type: eth
1435 ...
1436 eth1:
1437 type: eth
1438 ...
1439 bond0:
1440 enabled: true
1441 type: bond
1442 address: 192.168.0.102
1443 netmask: 255.255.255.0
1444 mtu: 1500
1445 use_in:
1446 - interface: ${linux:interface:eth0}
1447 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +01001448 network_manager:
1449 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001450
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001451Linux with VLAN ``interface_params``:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001452
1453.. code-block:: yaml
1454
1455 linux:
1456 network:
1457 enabled: true
1458 interface:
1459 vlan69:
1460 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +01001461 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001462 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001463
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001464Linux with wireless interface parameters:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001465
1466.. code-block:: yaml
1467
1468 linux:
1469 network:
1470 enabled: true
1471 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001472 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001473 interface:
1474 wlan0:
1475 type: eth
1476 wireless:
1477 essid: example
1478 key: example_key
1479 security: wpa
1480 priority: 1
1481
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001482Linux networks with routes defined:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001483
1484.. code-block:: yaml
1485
1486 linux:
1487 network:
1488 enabled: true
1489 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001490 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001491 interface:
1492 eth0:
1493 type: eth
1494 route:
1495 default:
1496 address: 192.168.0.123
1497 netmask: 255.255.255.0
1498 gateway: 192.168.0.1
1499
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001500Native Linux Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001501
1502.. code-block:: yaml
1503
1504 linux:
1505 network:
1506 interface:
1507 eth1:
1508 enabled: true
1509 type: eth
1510 proto: manual
1511 up_cmds:
1512 - ip address add 0/0 dev $IFACE
1513 - ip link set $IFACE up
1514 down_cmds:
1515 - ip link set $IFACE down
1516 br-ex:
1517 enabled: true
1518 type: bridge
1519 address: ${linux:network:host:public_local:address}
1520 netmask: 255.255.255.0
1521 use_interfaces:
1522 - eth1
1523
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001524Open vSwitch Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001525
1526.. code-block:: yaml
1527
1528 linux:
1529 network:
1530 bridge: openvswitch
1531 interface:
1532 eth1:
1533 enabled: true
1534 type: eth
1535 proto: manual
1536 up_cmds:
1537 - ip address add 0/0 dev $IFACE
1538 - ip link set $IFACE up
1539 down_cmds:
1540 - ip link set $IFACE down
1541 br-ex:
1542 enabled: true
1543 type: bridge
1544 address: ${linux:network:host:public_local:address}
1545 netmask: 255.255.255.0
1546 use_interfaces:
1547 - eth1
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001548 br-prv:
1549 enabled: true
1550 type: ovs_bridge
1551 mtu: 65000
1552 br-ens7:
1553 enabled: true
1554 name: br-ens7
1555 type: ovs_bridge
1556 proto: manual
1557 mtu: 9000
1558 use_interfaces:
1559 - ens7
1560 patch-br-ens7-br-prv:
1561 enabled: true
1562 name: ens7-prv
1563 ovs_type: ovs_port
1564 type: ovs_port
1565 bridge: br-ens7
1566 port_type: patch
1567 peer: prv-ens7
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001568 tag: 109 # [] to unset a tag
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001569 mtu: 65000
1570 patch-br-prv-br-ens7:
1571 enabled: true
1572 name: prv-ens7
1573 bridge: br-prv
1574 ovs_type: ovs_port
1575 type: ovs_port
1576 port_type: patch
1577 peer: ens7-prv
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001578 tag: 109
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001579 mtu: 65000
1580 ens7:
1581 enabled: true
1582 name: ens7
1583 proto: manual
1584 ovs_port_type: OVSPort
1585 type: ovs_port
1586 ovs_bridge: br-ens7
1587 bridge: br-ens7
Filip Pytlounf5383a42015-10-06 16:28:32 +02001588
Petr Jediný8f8ae542017-07-13 16:19:12 +02001589Debian manual proto interfaces
1590
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001591When you are changing interface proto from static in up state
1592to manual, you may need to flush ip addresses. For example,
1593if you want to use the interface and the ip on the bridge.
1594This can be done by setting the ``ipflush_onchange`` to true.
Petr Jediný8f8ae542017-07-13 16:19:12 +02001595
1596.. code-block:: yaml
1597
1598 linux:
1599 network:
1600 interface:
1601 eth1:
1602 enabled: true
1603 type: eth
1604 proto: manual
1605 mtu: 9100
1606 ipflush_onchange: true
1607
Jiri Broulik1a191e32018-01-15 15:54:21 +01001608Debian static proto interfaces
1609
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001610When you are changing interface proto from dhcp in up state to
1611static, you may need to flush ip addresses and restart interface
1612to assign ip address from a managed file. For example, if you wantto
1613use the interface and the ip on the bridge. This can be done by
1614setting the ``ipflush_onchange`` with combination ``restart_on_ipflush``
1615param set to true.
Jiri Broulik1a191e32018-01-15 15:54:21 +01001616
1617.. code-block:: yaml
1618
1619 linux:
1620 network:
1621 interface:
1622 eth1:
1623 enabled: true
1624 type: eth
1625 proto: static
1626 address: 10.1.0.22
1627 netmask: 255.255.255.0
1628 ipflush_onchange: true
1629 restart_on_ipflush: true
Petr Jediný8f8ae542017-07-13 16:19:12 +02001630
Petr Jedinýd577cb52017-06-28 20:17:49 +02001631Concatinating and removing interface files
1632
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001633Debian based distributions have ``/etc/network/interfaces.d/``
1634directory, where you can store configuration of network
1635interfaces in separate files. You can concatinate the files
1636to the defined destination when needed, this operation removes
1637the file from the ``/etc/network/interfaces.d/``. If you just need
1638to remove iface files, you can use the ``remove_iface_files`` key.
Petr Jedinýd577cb52017-06-28 20:17:49 +02001639
1640.. code-block:: yaml
1641
1642 linux:
1643 network:
1644 concat_iface_files:
1645 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
1646 dst: '/etc/network/interfaces'
1647 remove_iface_files:
1648 - '/etc/network/interfaces.d/90-custom.cfg'
1649
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001650Configure DHCP client
Petr Jedinýd577cb52017-06-28 20:17:49 +02001651
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001652None of the keys is mandatory, include only those you really need.
1653For full list of available options under send, supersede, prepend,
1654append refer to dhcp-options(5).
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001655
1656.. code-block:: yaml
1657
1658 linux:
1659 network:
1660 dhclient:
1661 enabled: true
1662 backoff_cutoff: 15
1663 initial_interval: 10
1664 reboot: 10
1665 retry: 60
1666 select_timeout: 0
1667 timeout: 120
1668 send:
1669 - option: host-name
1670 declaration: "= gethostname()"
1671 supersede:
1672 - option: host-name
1673 declaration: "spaceship"
1674 - option: domain-name
1675 declaration: "domain.home"
1676 #- option: arp-cache-timeout
1677 # declaration: 20
1678 prepend:
1679 - option: domain-name-servers
1680 declaration:
1681 - 8.8.8.8
1682 - 8.8.4.4
1683 - option: domain-search
1684 declaration:
1685 - example.com
1686 - eng.example.com
1687 #append:
1688 #- option: domain-name-servers
1689 # declaration: 127.0.0.1
1690 # ip or subnet to reject dhcp offer from
1691 reject:
1692 - 192.33.137.209
1693 - 10.0.2.0/24
1694 request:
1695 - subnet-mask
1696 - broadcast-address
1697 - time-offset
1698 - routers
1699 - domain-name
1700 - domain-name-servers
1701 - domain-search
1702 - host-name
1703 - dhcp6.name-servers
1704 - dhcp6.domain-search
1705 - dhcp6.fqdn
1706 - dhcp6.sntp-servers
1707 - netbios-name-servers
1708 - netbios-scope
1709 - interface-mtu
1710 - rfc3442-classless-static-routes
1711 - ntp-servers
1712 require:
1713 - subnet-mask
1714 - domain-name-servers
1715 # if per interface configuration required add below
1716 interface:
1717 ens2:
1718 initial_interval: 11
1719 reject:
1720 - 192.33.137.210
1721 ens3:
1722 initial_interval: 12
1723 reject:
1724 - 192.33.137.211
1725
Petr Michaleceb14b552017-06-01 10:27:05 +02001726Linux network systemd settings:
1727
1728.. code-block:: yaml
1729
1730 linux:
1731 network:
1732 ...
1733 systemd:
1734 link:
1735 10-iface-dmz:
1736 Match:
1737 MACAddress: c8:5b:67:fa:1a:af
1738 OriginalName: eth0
1739 Link:
1740 Name: dmz0
1741 netdev:
1742 20-bridge-dmz:
1743 match:
1744 name: dmz0
1745 network:
1746 mescription: bridge
1747 bridge: br-dmz0
1748 network:
1749 # works with lowercase, keys are by default capitalized
1750 40-dhcp:
1751 match:
1752 name: '*'
1753 network:
1754 DHCP: yes
1755
Petr Michalec10462bb2017-03-23 19:18:08 +01001756Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +01001757
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001758Use ``/etc/environment`` for static system wide variable assignment
1759after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001760
1761.. code-block:: yaml
1762
1763 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +01001764 system:
1765 env:
1766 BOB_VARIABLE: Alice
1767 ...
1768 BOB_PATH:
1769 - /srv/alice/bin
1770 - /srv/bob/bin
1771 ...
1772 ftp_proxy: none
1773 http_proxy: http://global-http-proxy.host.local:8080
1774 https_proxy: ${linux:system:proxy:https}
1775 no_proxy:
1776 - 192.168.0.80
1777 - 192.168.1.80
1778 - .domain.com
1779 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001780 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001781 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001782 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001783 ftp: ftp://proxy.host.local:2121
1784 http: http://proxy.host.local:3142
1785 https: https://proxy.host.local:3143
1786 noproxy:
1787 - .domain.com
1788 - .local
1789
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001790Configure the ``profile.d`` scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001791
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001792The ``profile.d`` scripts are being sourced during ``.sh`` execution
1793and support variable expansion in opposite to /etc/environment global
1794settings in ``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001795
1796.. code-block:: yaml
1797
1798 linux:
1799 system:
1800 profile:
1801 locales: |
1802 export LANG=C
1803 export LC_ALL=C
1804 ...
1805 vi_flavors.sh: |
1806 export PAGER=view
1807 export EDITOR=vim
1808 alias vi=vim
1809 shell_locales.sh: |
1810 export LANG=en_US
1811 export LC_ALL=en_US.UTF-8
1812 shell_proxies.sh: |
1813 export FTP_PROXY=ftp://127.0.3.3:2121
1814 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001815
Dmitry Teselkina0d31d12018-09-04 14:43:09 +03001816
1817Configure login.defs parameters
1818-------------------------------
1819
1820.. code-block:: yaml
1821
1822 linux:
1823 system:
1824 login_defs:
1825 <opt_name>:
1826 enabled: true
1827 value: <opt_value>
1828
1829<opt_name> is a configurational option defined in 'man login.defs'.
1830<opt_name> is case sensitive, should be UPPERCASE only!
1831
1832
Filip Pytlounf5383a42015-10-06 16:28:32 +02001833Linux with hosts
1834
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001835Parameter ``purge_hosts`` will enforce whole ``/etc/hosts file``,
1836removing entries that are not defined in model except defaults
1837for both IPv4 and IPv6 localhost and hostname as well as FQDN.
Ales Komarek417e8c52017-08-25 15:10:29 +02001838
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001839We recommend using this option to verify that ``/etc/hosts``
1840is always in a clean state. However it is not enabled by default
1841for security reasons.
Filip Pytloun86506fe2017-01-26 14:36:16 +01001842
Filip Pytlounf5383a42015-10-06 16:28:32 +02001843.. code-block:: yaml
1844
1845 linux:
1846 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001847 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001848 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001849 # No need to define this one if purge_hosts is true
1850 hostname:
1851 address: 127.0.1.1
1852 names:
1853 - ${linux:network:fqdn}
1854 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001855 node1:
1856 address: 192.168.10.200
1857 names:
1858 - node2.domain.com
1859 - service2.domain.com
1860 node2:
1861 address: 192.168.10.201
1862 names:
1863 - node2.domain.com
1864 - service2.domain.com
1865
Ales Komarek417e8c52017-08-25 15:10:29 +02001866Linux with hosts collected from mine
1867
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001868All DNS records defined within infrastrucuture
1869are passed to the local hosts records or any DNS server. Only
1870hosts with the ``grain`` parameter set to ``true`` will be propagated
1871to the mine.
Ales Komarek417e8c52017-08-25 15:10:29 +02001872
1873.. code-block:: yaml
1874
1875 linux:
1876 network:
1877 purge_hosts: true
1878 mine_dns_records: true
1879 host:
1880 node1:
1881 address: 192.168.10.200
1882 grain: true
1883 names:
1884 - node2.domain.com
1885 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01001886
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001887Set up ``resolvconf's basic resolver info``, e.g. nameservers, search/domain and options:
Filip Pytlounde9bea52016-01-11 15:39:10 +01001888
1889.. code-block:: yaml
1890
1891 linux:
1892 network:
1893 resolv:
1894 dns:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001895 - 8.8.4.4
1896 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01001897 domain: my.example.com
1898 search:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001899 - my.example.com
1900 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01001901 options:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001902 - ndots:5
1903 - timeout:2
1904 - attempts:2
Filip Pytlounde9bea52016-01-11 15:39:10 +01001905
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001906Set up custom TX queue length for tap interfaces:
Andrii Petrenko735761d2017-03-21 17:17:35 -07001907
1908.. code-block:: yaml
1909
1910 linux:
1911 network:
1912 tap_custom_txqueuelen: 10000
1913
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001914DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001915
1916**DPDK OVS NIC**
1917
1918.. code-block:: yaml
1919
1920 linux:
1921 network:
1922 bridge: openvswitch
1923 dpdk:
1924 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001925 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001926 openvswitch:
1927 pmd_cpu_mask: "0x6"
1928 dpdk_socket_mem: "1024,1024"
1929 dpdk_lcore_mask: "0x400"
1930 memory_channels: 2
1931 interface:
1932 dpkd0:
1933 name: ${_param:dpdk_nic}
1934 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001935 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001936 enabled: true
1937 type: dpdk_ovs_port
1938 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001939 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001940 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01001941 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001942 br-prv:
1943 enabled: true
1944 type: dpdk_ovs_bridge
Michael Polenchukd3378db2018-12-29 16:46:50 +04001945 br-floating:
1946 enabled: true
1947 type: ovs_bridge
1948 name_servers:
1949 - 1.1.1.1
1950 - 9.9.9.9
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001951
1952**DPDK OVS Bond**
1953
1954.. code-block:: yaml
1955
1956 linux:
1957 network:
1958 bridge: openvswitch
1959 dpdk:
1960 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001961 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001962 openvswitch:
1963 pmd_cpu_mask: "0x6"
1964 dpdk_socket_mem: "1024,1024"
1965 dpdk_lcore_mask: "0x400"
1966 memory_channels: 2
1967 interface:
1968 dpdk_second_nic:
1969 name: ${_param:primary_second_nic}
1970 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001971 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001972 bond: dpdkbond0
1973 enabled: true
1974 type: dpdk_ovs_port
1975 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001976 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001977 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001978 dpdk_first_nic:
1979 name: ${_param:primary_first_nic}
1980 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001981 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001982 bond: dpdkbond0
1983 enabled: true
1984 type: dpdk_ovs_port
1985 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001986 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001987 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001988 dpdkbond0:
1989 enabled: true
1990 bridge: br-prv
1991 type: dpdk_ovs_bond
1992 mode: active-backup
1993 br-prv:
1994 enabled: true
1995 type: dpdk_ovs_bridge
1996
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01001997**DPDK OVS LACP Bond with vlan tag**
1998
1999.. code-block:: yaml
2000
2001 linux:
2002 network:
2003 bridge: openvswitch
2004 dpdk:
2005 enabled: true
2006 driver: uio
2007 openvswitch:
2008 pmd_cpu_mask: "0x6"
2009 dpdk_socket_mem: "1024,1024"
2010 dpdk_lcore_mask: "0x400"
2011 memory_channels: "2"
2012 interface:
2013 eth3:
2014 enabled: true
2015 type: eth
2016 proto: manual
2017 name: ${_param:tenant_first_nic}
2018 eth4:
2019 enabled: true
2020 type: eth
2021 proto: manual
2022 name: ${_param:tenant_second_nic}
2023 dpdk0:
2024 name: ${_param:tenant_first_nic}
2025 pci: "0000:81:00.0"
2026 driver: igb_uio
2027 bond: bond1
2028 enabled: true
2029 type: dpdk_ovs_port
2030 n_rxq: 2
2031 dpdk1:
2032 name: ${_param:tenant_second_nic}
2033 pci: "0000:81:00.1"
2034 driver: igb_uio
2035 bond: bond1
2036 enabled: true
2037 type: dpdk_ovs_port
2038 n_rxq: 2
2039 bond1:
2040 enabled: true
2041 bridge: br-prv
2042 type: dpdk_ovs_bond
2043 mode: balance-slb
2044 br-prv:
2045 enabled: true
2046 type: dpdk_ovs_bridge
2047 tag: ${_param:tenant_vlan}
2048 address: ${_param:tenant_address}
2049 netmask: ${_param:tenant_network_netmask}
2050
Jakub Pavlikaa759062017-03-13 15:57:26 +01002051**DPDK OVS bridge for VXLAN**
2052
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002053If VXLAN is used as tenant segmentation, IP address must
2054be set on ``br-prv``.
Jakub Pavlikaa759062017-03-13 15:57:26 +01002055
2056.. code-block:: yaml
2057
2058 linux:
2059 network:
2060 ...
2061 interface:
2062 br-prv:
2063 enabled: true
2064 type: dpdk_ovs_bridge
2065 address: 192.168.50.0
2066 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04002067 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01002068 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002069
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02002070**DPDK OVS bridge with Linux network interface**
2071
2072.. code-block:: yaml
2073
2074 linux:
2075 network:
2076 ...
2077 interface:
2078 eth0:
2079 type: eth
2080 ovs_bridge: br-prv
2081 ...
2082 br-prv:
2083 enabled: true
2084 type: dpdk_ovs_bridge
2085 ...
2086
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002087Linux storage
2088-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02002089
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002090Linux with mounted Samba:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002091
2092.. code-block:: yaml
2093
2094 linux:
2095 storage:
2096 enabled: true
2097 mount:
2098 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01002099 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02002100 - path: /media/myuser/public/
2101 - device: //192.168.0.1/storage
2102 - file_system: cifs
2103 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
2104
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002105NFS mount:
Jiri Broulikb017f932017-03-31 13:55:36 +02002106
2107.. code-block:: yaml
2108
2109 linux:
2110 storage:
2111 enabled: true
2112 mount:
2113 nfs_glance:
2114 enabled: true
2115 path: /var/lib/glance/images
2116 device: 172.16.10.110:/var/nfs/glance
2117 file_system: nfs
2118 opts: rw,sync
2119
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002120File swap configuration:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002121
2122.. code-block:: yaml
2123
2124 linux:
2125 storage:
2126 enabled: true
2127 swap:
2128 file:
2129 enabled: true
2130 engine: file
2131 device: /swapfile
2132 size: 1024
2133
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002134Partition swap configuration:
Lachlan Evenson30676512016-01-22 15:43:28 -08002135
2136.. code-block:: yaml
2137
2138 linux:
2139 storage:
2140 enabled: true
2141 swap:
2142 partition:
2143 enabled: true
2144 engine: partition
2145 device: /dev/vg0/swap
2146
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002147LVM group ``vg1`` with one device and ``data`` volume mounted
2148into ``/mnt/data``.
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002149
2150.. code-block:: yaml
2151
2152 parameters:
2153 linux:
2154 storage:
2155 mount:
2156 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01002157 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002158 device: /dev/vg1/data
2159 file_system: ext4
2160 path: /mnt/data
2161 lvm:
2162 vg1:
2163 enabled: true
2164 devices:
2165 - /dev/sdb
2166 volume:
2167 data:
2168 size: 40G
2169 mount: ${linux:storage:mount:data}
root40bb5e72019-01-11 08:55:32 +00002170 # When set they will take precedence over filters aget from volume groups.
2171 lvm_filters:
2172 10:
2173 enabled: True
2174 value: "a|loop|"
2175 20:
2176 enabled: True
2177 value: "r|/dev/hdc|"
2178 30:
2179 enabled: True
2180 value: "a|/dev/ide|"
2181 40:
2182 enabled: True
2183 value: "r|.*|"
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002184
Jakub Pavlik4f742142017-08-08 15:05:50 +02002185Create partitions on disk. Specify size in MB. It expects empty
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002186disk without any existing partitions.
2187Set ``startsector=1`` if you want to start partitions from ``2048``.
Jakub Pavlik4f742142017-08-08 15:05:50 +02002188
2189.. code-block:: yaml
2190
2191 linux:
2192 storage:
2193 disk:
2194 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01002195 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02002196 name: /dev/loop1
2197 type: gpt
2198 partitions:
2199 - size: 200 #size in MB
2200 type: fat32
2201 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02002202 mkfs: True
2203 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02002204 /dev/vda1:
2205 partitions:
2206 - size: 5
2207 type: ext2
2208 - size: 10
2209 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02002210
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002211Multipath with Fujitsu Eternus DXL:
Ales Komareka634f4b2016-10-02 13:11:04 +02002212
2213.. code-block:: yaml
2214
2215 parameters:
2216 linux:
2217 storage:
2218 multipath:
2219 enabled: true
2220 blacklist_devices:
2221 - /dev/sda
2222 - /dev/sdb
2223 backends:
2224 - fujitsu_eternus_dxl
2225
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002226Multipath with Hitachi VSP 1000:
Ales Komareka634f4b2016-10-02 13:11:04 +02002227
2228.. code-block:: yaml
2229
2230 parameters:
2231 linux:
2232 storage:
2233 multipath:
2234 enabled: true
2235 blacklist_devices:
2236 - /dev/sda
2237 - /dev/sdb
2238 backends:
2239 - hitachi_vsp1000
2240
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002241Multipath with IBM Storwize:
Ales Komareka634f4b2016-10-02 13:11:04 +02002242
2243.. code-block:: yaml
2244
2245 parameters:
2246 linux:
2247 storage:
2248 multipath:
2249 enabled: true
2250 blacklist_devices:
2251 - /dev/sda
2252 - /dev/sdb
2253 backends:
2254 - ibm_storwize
2255
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002256Multipath with multiple backends:
Ales Komareka634f4b2016-10-02 13:11:04 +02002257
2258.. code-block:: yaml
2259
2260 parameters:
2261 linux:
2262 storage:
2263 multipath:
2264 enabled: true
2265 blacklist_devices:
2266 - /dev/sda
2267 - /dev/sdb
2268 - /dev/sdc
2269 - /dev/sdd
2270 backends:
2271 - ibm_storwize
2272 - fujitsu_eternus_dxl
2273 - hitachi_vsp1000
2274
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002275PAM LDAP integration:
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002276
2277.. code-block:: yaml
2278
2279 parameters:
2280 linux:
2281 system:
2282 auth:
2283 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02002284 mkhomedir:
2285 enabled: true
2286 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002287 ldap:
2288 enabled: true
2289 binddn: cn=bind,ou=service_users,dc=example,dc=com
2290 bindpw: secret
2291 uri: ldap://127.0.0.1
2292 base: ou=users,dc=example,dc=com
2293 ldap_version: 3
2294 pagesize: 65536
2295 referrals: off
2296 filter:
2297 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2298 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2299 group: (&(objectClass=group)(gidNumber=*))
2300
Gleb Galkin93b9ae92018-10-18 13:57:30 +03002301PAM duo 2FA integration
2302
2303.. code-block:: yaml
2304
2305 parameters:
2306 linux:
2307 system:
2308 auth:
2309 enabled: true
2310 duo:
2311 enabled: true
2312 duo_host: localhost
2313 duo_ikey: DUO-INTEGRATION-KEY
2314 duo_skey: DUO-SECRET-KEY
2315
2316duo package version may be specified (optional)
2317
2318.. code-block:: yaml
2319
2320 linux:
2321 system:
2322 package:
2323 duo-unix:
2324 version: 1.10.1-0
2325
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002326Disabled multipath (the default setup):
Ales Komareka634f4b2016-10-02 13:11:04 +02002327
2328.. code-block:: yaml
2329
2330 parameters:
2331 linux:
2332 storage:
2333 multipath:
2334 enabled: false
2335
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002336Linux with local loopback device:
Simon Pasquier375001e2017-01-26 13:22:33 +01002337
2338.. code-block:: yaml
2339
2340 linux:
2341 storage:
2342 loopback:
2343 disk1:
2344 file: /srv/disk1
2345 size: 50G
2346
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002347External config generation
2348--------------------------
2349
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002350You are able to use config support metadata between formulas
2351and only generate configuration files for external use, for example, Docker, and so on.
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002352
2353.. code-block:: yaml
2354
2355 parameters:
2356 linux:
2357 system:
2358 config:
2359 pillar:
2360 jenkins:
2361 master:
2362 home: /srv/volumes/jenkins
2363 approved_scripts:
2364 - method java.net.URL openConnection
2365 credentials:
2366 - type: username_password
2367 scope: global
2368 id: test
2369 desc: Testing credentials
2370 username: test
2371 password: test
2372
Vladimir Ereminccf28842017-04-10 23:52:10 +03002373Netconsole Remote Kernel Logging
2374--------------------------------
2375
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002376Netconsole logger can be configured for the configfs-enabled kernels
2377(``CONFIG_NETCONSOLE_DYNAMIC`` must be enabled). The configuration
2378applies both in runtime (if network is already configured),
2379and on-boot after an interface initialization.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002380
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002381.. note::
2382
2383 * Receiver can be located only on the same L3 domain
2384 (or you need to configure gateway MAC manually).
2385 * The Receiver MAC is detected only on configuration time.
2386 * Using broadcast MAC is not recommended.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002387
2388.. code-block:: yaml
2389
2390 parameters:
2391 linux:
2392 system:
2393 netconsole:
2394 enabled: true
2395 port: 514 (optional)
2396 loglevel: debug (optional)
2397 target:
2398 192.168.0.1:
2399 interface: bond0
2400 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02002401
Dzmitry Stremkouskid1a268b2018-10-03 16:36:04 +02002402Check network params on the environment
2403---------------------------------------
2404
2405Grab nics and nics states
2406
2407.. code-block:: bash
2408
2409 salt osd001\* net_checks.get_nics
2410
2411**Example of system output:**
2412
2413.. code-block:: bash
2414
2415 osd001.domain.com:
2416 |_
2417 - bond0
2418 - None
2419 - 1e:c8:64:42:23:b9
2420 - 0
2421 - 1500
2422 |_
2423 - bond1
2424 - None
2425 - 3c:fd:fe:27:3b:00
2426 - 1
2427 - 9100
2428 |_
2429 - fourty1
2430 - None
2431 - 3c:fd:fe:27:3b:00
2432 - 1
2433 - 9100
2434 |_
2435 - fourty2
2436 - None
2437 - 3c:fd:fe:27:3b:02
2438 - 1
2439 - 9100
2440
2441Grab 10G nics PCI addresses for hugepages setup
2442
2443.. code-block:: bash
2444
2445 salt cmp001\* net_checks.get_ten_pci
2446
2447**Example of system output:**
2448
2449.. code-block:: bash
2450
2451 cmp001.domain.com:
2452 |_
2453 - ten1
2454 - 0000:19:00.0
2455 |_
2456 - ten2
2457 - 0000:19:00.1
2458 |_
2459 - ten3
2460 - 0000:19:00.2
2461 |_
2462 - ten4
2463 - 0000:19:00.3
2464
2465Grab ip address for an interface
2466
2467.. code-block:: bash
2468
2469 salt cmp001\* net_checks.get_ip iface=one4
2470
2471**Example of system output:**
2472
2473.. code-block:: bash
2474
2475 cmp001.domain.com:
2476 10.200.177.101
2477
2478Grab ip addresses map
2479
2480.. code-block:: bash
2481
2482 salt-call net_checks.nodes_addresses
2483
2484**Example of system output:**
2485
2486.. code-block:: bash
2487
2488 local:
2489 |_
2490 - cid01.domain.com
2491 |_
2492 |_
2493 - pxe
2494 - 10.200.177.91
2495 |_
2496 - control
2497 - 10.200.178.91
2498 |_
2499 - cmn02.domain.com
2500 |_
2501 |_
2502 - storage_access
2503 - 10.200.181.67
2504 |_
2505 - pxe
2506 - 10.200.177.67
2507 |_
2508 - control
2509 - 10.200.178.67
2510 |_
2511 - cmp010.domain.com
2512 |_
2513 |_
2514 - pxe
2515 - 10.200.177.110
2516 |_
2517 - storage_access
2518 - 10.200.181.110
2519 |_
2520 - control
2521 - 10.200.178.110
2522 |_
2523 - vxlan
2524 - 10.200.179.110
2525
2526Verify full mesh connectivity
2527
2528.. code-block:: bash
2529
2530 salt-call net_checks.ping_check
2531
2532**Example of positive system output:**
2533
2534.. code-block:: bash
2535
2536 ['PASSED']
2537 [INFO ] ['PASSED']
2538 local:
2539 True
2540
2541**Example of system output in case of failure:**
2542
2543.. code-block:: bash
2544
2545 FAILED
2546 [ERROR ] FAILED
2547 ['control: 10.0.1.92 -> 10.0.1.224: Failed']
2548 ['control: 10.0.1.93 -> 10.0.1.224: Failed']
2549 ['control: 10.0.1.51 -> 10.0.1.224: Failed']
2550 ['control: 10.0.1.102 -> 10.0.1.224: Failed']
2551 ['control: 10.0.1.13 -> 10.0.1.224: Failed']
2552 ['control: 10.0.1.81 -> 10.0.1.224: Failed']
2553 local:
2554 False
2555
2556For this feature to work, please mark addresses with some role.
2557Otherwise 'default' role is assumed and mesh would consist of all
2558addresses on the environment.
2559
2560Mesh mark is needed only for interfaces which are enabled and have
2561ip address assigned.
2562
2563Checking dhcp pxe network meaningless, as it is used for salt
2564master vs minion communications, therefore treated as checked.
2565
2566.. code-block:: yaml
2567
2568 parameters:
2569 linux:
2570 network:
2571 interface:
2572 ens3:
2573 enabled: true
2574 type: eth
2575 proto: static
2576 address: ${_param:deploy_address}
2577 netmask: ${_param:deploy_network_netmask}
2578 gateway: ${_param:deploy_network_gateway}
2579 mesh: pxe
2580
2581Check pillars for ip address duplicates
2582
2583.. code-block:: bash
2584
2585 salt-call net_checks.verify_addresses
2586
2587**Example of positive system output:**
2588
2589.. code-block:: bash
2590
2591 ['PASSED']
2592 [INFO ] ['PASSED']
2593 local:
2594 True
2595
2596**Example of system output in case of failure:**
2597
2598.. code-block:: bash
2599
2600 FAILED. Duplicates found
2601 [ERROR ] FAILED. Duplicates found
2602 ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2603 [ERROR ] ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2604 local:
2605 False
2606
2607Generate csv report for the env
2608
2609.. code-block:: bash
2610
2611 salt -C 'kvm* or cmp* or osd*' net_checks.get_nics_csv \
2612 | grep '^\ ' | sed 's/\ *//g' | grep -Ev ^server \
2613 | sed '1 i\server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr'
2614
2615**Example of system output:**
2616
2617.. code-block:: bash
2618
2619 server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr
2620 cmp010.domain.com,bond0,None,b4:96:91:10:5b:3a,1,1500,,,,
2621 cmp010.domain.com,bond0.21,10.200.178.110,b4:96:91:10:5b:3a,1,1500,,,,
2622 cmp010.domain.com,bond0.22,10.200.179.110,b4:96:91:10:5b:3a,1,1500,,,,
2623 cmp010.domain.com,bond1,None,3c:fd:fe:34:ad:22,0,1500,,,,
2624 cmp010.domain.com,bond1.24,10.200.181.110,3c:fd:fe:34:ad:22,0,1500,,,,
2625 cmp010.domain.com,fourty5,None,3c:fd:fe:34:ad:20,0,9000,,,,
2626 cmp010.domain.com,fourty6,None,3c:fd:fe:34:ad:22,0,9000,,,,
2627 cmp010.domain.com,one1,None,b4:96:91:10:5b:38,0,1500,,,,
2628 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
2629 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
2630 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
2631 cmp011.domain.com,bond0,None,b4:96:91:13:6c:aa,1,1500,,,,
2632 cmp011.domain.com,bond0.21,10.200.178.111,b4:96:91:13:6c:aa,1,1500,,,,
2633 cmp011.domain.com,bond0.22,10.200.179.111,b4:96:91:13:6c:aa,1,1500,,,,
2634 ...
2635
Filip Pytlounf5383a42015-10-06 16:28:32 +02002636Usage
2637=====
2638
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002639Set MTU of the eth0 network interface to 1400:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002640
2641.. code-block:: bash
2642
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002643 ip link set dev eth0 mtu 1400
Filip Pytlounf5383a42015-10-06 16:28:32 +02002644
2645Read more
2646=========
2647
2648* https://www.archlinux.org/
2649* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu