blob: c32a444086d71e3925afb3068857bd71345d1252 [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
ivcc4730b12019-01-23 07:56:53 +03001500Linux networks with implicit routes definition:
1501
1502- on node 1:
1503
1504.. code-block:: yaml
1505
1506 linux:
1507 network:
1508 enabled: true
1509 router:
1510 ctl:
1511 # router that connects 10.0.1.0/24 and 10.0.2.0/24
1512 addresses:
1513 - 10.0.1.1/24
1514 - 10.0.2.1/24
1515 test:
1516 addresses:
1517 - 10.0.1.2/24
1518 networks:
1519 - 10.100.0.0/16
1520 interface:
1521 ctl:
1522 name: eth0
1523 address: 10.0.1.101
1524 netmask: 255.255.255.0
1525
1526- on node2:
1527
1528.. code-block:: yaml
1529
1530 linux:
1531 network:
1532 enabled: true
1533 router:
1534 ctl:
1535 # equivalent of node1's ctl router with 'implicit_routes = false'
1536 options:
1537 implicit_routes: false
1538 addresses:
1539 - 10.0.1.1/24
1540 - 10.0.2.1/24
1541 networks:
1542 - 10.0.1.0/24
1543 - 10.0.2.0/24
1544 interface:
1545 ctl:
1546 name: eth0
1547 address: 10.0.2.101
1548 netmask: 255.255.255.0
1549
1550
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001551Native Linux Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001552
1553.. code-block:: yaml
1554
1555 linux:
1556 network:
1557 interface:
1558 eth1:
1559 enabled: true
1560 type: eth
1561 proto: manual
1562 up_cmds:
1563 - ip address add 0/0 dev $IFACE
1564 - ip link set $IFACE up
1565 down_cmds:
1566 - ip link set $IFACE down
1567 br-ex:
1568 enabled: true
1569 type: bridge
1570 address: ${linux:network:host:public_local:address}
1571 netmask: 255.255.255.0
1572 use_interfaces:
1573 - eth1
1574
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001575Open vSwitch Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001576
1577.. code-block:: yaml
1578
1579 linux:
1580 network:
1581 bridge: openvswitch
1582 interface:
1583 eth1:
1584 enabled: true
1585 type: eth
1586 proto: manual
1587 up_cmds:
1588 - ip address add 0/0 dev $IFACE
1589 - ip link set $IFACE up
1590 down_cmds:
1591 - ip link set $IFACE down
1592 br-ex:
1593 enabled: true
1594 type: bridge
1595 address: ${linux:network:host:public_local:address}
1596 netmask: 255.255.255.0
1597 use_interfaces:
1598 - eth1
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001599 br-prv:
1600 enabled: true
1601 type: ovs_bridge
1602 mtu: 65000
1603 br-ens7:
1604 enabled: true
1605 name: br-ens7
1606 type: ovs_bridge
1607 proto: manual
1608 mtu: 9000
1609 use_interfaces:
1610 - ens7
1611 patch-br-ens7-br-prv:
1612 enabled: true
1613 name: ens7-prv
1614 ovs_type: ovs_port
1615 type: ovs_port
1616 bridge: br-ens7
1617 port_type: patch
1618 peer: prv-ens7
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001619 tag: 109 # [] to unset a tag
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001620 mtu: 65000
1621 patch-br-prv-br-ens7:
1622 enabled: true
1623 name: prv-ens7
1624 bridge: br-prv
1625 ovs_type: ovs_port
1626 type: ovs_port
1627 port_type: patch
1628 peer: ens7-prv
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001629 tag: 109
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001630 mtu: 65000
1631 ens7:
1632 enabled: true
1633 name: ens7
1634 proto: manual
1635 ovs_port_type: OVSPort
1636 type: ovs_port
1637 ovs_bridge: br-ens7
1638 bridge: br-ens7
Filip Pytlounf5383a42015-10-06 16:28:32 +02001639
Petr Jediný8f8ae542017-07-13 16:19:12 +02001640Debian manual proto interfaces
1641
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001642When you are changing interface proto from static in up state
1643to manual, you may need to flush ip addresses. For example,
1644if you want to use the interface and the ip on the bridge.
1645This can be done by setting the ``ipflush_onchange`` to true.
Petr Jediný8f8ae542017-07-13 16:19:12 +02001646
1647.. code-block:: yaml
1648
1649 linux:
1650 network:
1651 interface:
1652 eth1:
1653 enabled: true
1654 type: eth
1655 proto: manual
1656 mtu: 9100
1657 ipflush_onchange: true
1658
Jiri Broulik1a191e32018-01-15 15:54:21 +01001659Debian static proto interfaces
1660
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001661When you are changing interface proto from dhcp in up state to
1662static, you may need to flush ip addresses and restart interface
1663to assign ip address from a managed file. For example, if you wantto
1664use the interface and the ip on the bridge. This can be done by
1665setting the ``ipflush_onchange`` with combination ``restart_on_ipflush``
1666param set to true.
Jiri Broulik1a191e32018-01-15 15:54:21 +01001667
1668.. code-block:: yaml
1669
1670 linux:
1671 network:
1672 interface:
1673 eth1:
1674 enabled: true
1675 type: eth
1676 proto: static
1677 address: 10.1.0.22
1678 netmask: 255.255.255.0
1679 ipflush_onchange: true
1680 restart_on_ipflush: true
Petr Jediný8f8ae542017-07-13 16:19:12 +02001681
Petr Jedinýd577cb52017-06-28 20:17:49 +02001682Concatinating and removing interface files
1683
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001684Debian based distributions have ``/etc/network/interfaces.d/``
1685directory, where you can store configuration of network
1686interfaces in separate files. You can concatinate the files
1687to the defined destination when needed, this operation removes
1688the file from the ``/etc/network/interfaces.d/``. If you just need
1689to remove iface files, you can use the ``remove_iface_files`` key.
Petr Jedinýd577cb52017-06-28 20:17:49 +02001690
1691.. code-block:: yaml
1692
1693 linux:
1694 network:
1695 concat_iface_files:
1696 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
1697 dst: '/etc/network/interfaces'
1698 remove_iface_files:
1699 - '/etc/network/interfaces.d/90-custom.cfg'
1700
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001701Configure DHCP client
Petr Jedinýd577cb52017-06-28 20:17:49 +02001702
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001703None of the keys is mandatory, include only those you really need.
1704For full list of available options under send, supersede, prepend,
1705append refer to dhcp-options(5).
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001706
1707.. code-block:: yaml
1708
1709 linux:
1710 network:
1711 dhclient:
1712 enabled: true
1713 backoff_cutoff: 15
1714 initial_interval: 10
1715 reboot: 10
1716 retry: 60
1717 select_timeout: 0
1718 timeout: 120
1719 send:
1720 - option: host-name
1721 declaration: "= gethostname()"
1722 supersede:
1723 - option: host-name
1724 declaration: "spaceship"
1725 - option: domain-name
1726 declaration: "domain.home"
1727 #- option: arp-cache-timeout
1728 # declaration: 20
1729 prepend:
1730 - option: domain-name-servers
1731 declaration:
1732 - 8.8.8.8
1733 - 8.8.4.4
1734 - option: domain-search
1735 declaration:
1736 - example.com
1737 - eng.example.com
1738 #append:
1739 #- option: domain-name-servers
1740 # declaration: 127.0.0.1
1741 # ip or subnet to reject dhcp offer from
1742 reject:
1743 - 192.33.137.209
1744 - 10.0.2.0/24
1745 request:
1746 - subnet-mask
1747 - broadcast-address
1748 - time-offset
1749 - routers
1750 - domain-name
1751 - domain-name-servers
1752 - domain-search
1753 - host-name
1754 - dhcp6.name-servers
1755 - dhcp6.domain-search
1756 - dhcp6.fqdn
1757 - dhcp6.sntp-servers
1758 - netbios-name-servers
1759 - netbios-scope
1760 - interface-mtu
1761 - rfc3442-classless-static-routes
1762 - ntp-servers
1763 require:
1764 - subnet-mask
1765 - domain-name-servers
1766 # if per interface configuration required add below
1767 interface:
1768 ens2:
1769 initial_interval: 11
1770 reject:
1771 - 192.33.137.210
1772 ens3:
1773 initial_interval: 12
1774 reject:
1775 - 192.33.137.211
1776
Petr Michaleceb14b552017-06-01 10:27:05 +02001777Linux network systemd settings:
1778
1779.. code-block:: yaml
1780
1781 linux:
1782 network:
1783 ...
1784 systemd:
1785 link:
1786 10-iface-dmz:
1787 Match:
1788 MACAddress: c8:5b:67:fa:1a:af
1789 OriginalName: eth0
1790 Link:
1791 Name: dmz0
1792 netdev:
1793 20-bridge-dmz:
1794 match:
1795 name: dmz0
1796 network:
1797 mescription: bridge
1798 bridge: br-dmz0
1799 network:
1800 # works with lowercase, keys are by default capitalized
1801 40-dhcp:
1802 match:
1803 name: '*'
1804 network:
1805 DHCP: yes
1806
Petr Michalec10462bb2017-03-23 19:18:08 +01001807Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +01001808
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001809Use ``/etc/environment`` for static system wide variable assignment
1810after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001811
1812.. code-block:: yaml
1813
1814 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +01001815 system:
1816 env:
1817 BOB_VARIABLE: Alice
1818 ...
1819 BOB_PATH:
1820 - /srv/alice/bin
1821 - /srv/bob/bin
1822 ...
1823 ftp_proxy: none
1824 http_proxy: http://global-http-proxy.host.local:8080
1825 https_proxy: ${linux:system:proxy:https}
1826 no_proxy:
1827 - 192.168.0.80
1828 - 192.168.1.80
1829 - .domain.com
1830 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001831 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001832 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001833 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001834 ftp: ftp://proxy.host.local:2121
1835 http: http://proxy.host.local:3142
1836 https: https://proxy.host.local:3143
1837 noproxy:
1838 - .domain.com
1839 - .local
1840
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001841Configure the ``profile.d`` scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001842
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001843The ``profile.d`` scripts are being sourced during ``.sh`` execution
1844and support variable expansion in opposite to /etc/environment global
1845settings in ``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001846
1847.. code-block:: yaml
1848
1849 linux:
1850 system:
1851 profile:
1852 locales: |
1853 export LANG=C
1854 export LC_ALL=C
1855 ...
1856 vi_flavors.sh: |
1857 export PAGER=view
1858 export EDITOR=vim
1859 alias vi=vim
1860 shell_locales.sh: |
1861 export LANG=en_US
1862 export LC_ALL=en_US.UTF-8
1863 shell_proxies.sh: |
1864 export FTP_PROXY=ftp://127.0.3.3:2121
1865 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001866
Dmitry Teselkina0d31d12018-09-04 14:43:09 +03001867
1868Configure login.defs parameters
1869-------------------------------
1870
1871.. code-block:: yaml
1872
1873 linux:
1874 system:
1875 login_defs:
1876 <opt_name>:
1877 enabled: true
1878 value: <opt_value>
1879
1880<opt_name> is a configurational option defined in 'man login.defs'.
1881<opt_name> is case sensitive, should be UPPERCASE only!
1882
1883
Filip Pytlounf5383a42015-10-06 16:28:32 +02001884Linux with hosts
1885
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001886Parameter ``purge_hosts`` will enforce whole ``/etc/hosts file``,
1887removing entries that are not defined in model except defaults
1888for both IPv4 and IPv6 localhost and hostname as well as FQDN.
Ales Komarek417e8c52017-08-25 15:10:29 +02001889
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001890We recommend using this option to verify that ``/etc/hosts``
1891is always in a clean state. However it is not enabled by default
1892for security reasons.
Filip Pytloun86506fe2017-01-26 14:36:16 +01001893
Filip Pytlounf5383a42015-10-06 16:28:32 +02001894.. code-block:: yaml
1895
1896 linux:
1897 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001898 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001899 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001900 # No need to define this one if purge_hosts is true
1901 hostname:
1902 address: 127.0.1.1
1903 names:
1904 - ${linux:network:fqdn}
1905 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001906 node1:
1907 address: 192.168.10.200
1908 names:
1909 - node2.domain.com
1910 - service2.domain.com
1911 node2:
1912 address: 192.168.10.201
1913 names:
1914 - node2.domain.com
1915 - service2.domain.com
1916
Ales Komarek417e8c52017-08-25 15:10:29 +02001917Linux with hosts collected from mine
1918
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001919All DNS records defined within infrastrucuture
1920are passed to the local hosts records or any DNS server. Only
1921hosts with the ``grain`` parameter set to ``true`` will be propagated
1922to the mine.
Ales Komarek417e8c52017-08-25 15:10:29 +02001923
1924.. code-block:: yaml
1925
1926 linux:
1927 network:
1928 purge_hosts: true
1929 mine_dns_records: true
1930 host:
1931 node1:
1932 address: 192.168.10.200
1933 grain: true
1934 names:
1935 - node2.domain.com
1936 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01001937
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001938Set up ``resolvconf's basic resolver info``, e.g. nameservers, search/domain and options:
Filip Pytlounde9bea52016-01-11 15:39:10 +01001939
1940.. code-block:: yaml
1941
1942 linux:
1943 network:
1944 resolv:
1945 dns:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001946 - 8.8.4.4
1947 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01001948 domain: my.example.com
1949 search:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001950 - my.example.com
1951 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01001952 options:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001953 - ndots:5
1954 - timeout:2
1955 - attempts:2
Filip Pytlounde9bea52016-01-11 15:39:10 +01001956
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001957Set up custom TX queue length for tap interfaces:
Andrii Petrenko735761d2017-03-21 17:17:35 -07001958
1959.. code-block:: yaml
1960
1961 linux:
1962 network:
1963 tap_custom_txqueuelen: 10000
1964
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001965DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001966
1967**DPDK OVS NIC**
1968
1969.. code-block:: yaml
1970
1971 linux:
1972 network:
1973 bridge: openvswitch
1974 dpdk:
1975 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001976 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001977 openvswitch:
1978 pmd_cpu_mask: "0x6"
1979 dpdk_socket_mem: "1024,1024"
1980 dpdk_lcore_mask: "0x400"
1981 memory_channels: 2
1982 interface:
1983 dpkd0:
1984 name: ${_param:dpdk_nic}
1985 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001986 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001987 enabled: true
1988 type: dpdk_ovs_port
1989 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001990 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001991 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01001992 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001993 br-prv:
1994 enabled: true
1995 type: dpdk_ovs_bridge
Michael Polenchukd3378db2018-12-29 16:46:50 +04001996 br-floating:
1997 enabled: true
1998 type: ovs_bridge
1999 name_servers:
2000 - 1.1.1.1
2001 - 9.9.9.9
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002002
2003**DPDK OVS Bond**
2004
2005.. code-block:: yaml
2006
2007 linux:
2008 network:
2009 bridge: openvswitch
2010 dpdk:
2011 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04002012 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002013 openvswitch:
2014 pmd_cpu_mask: "0x6"
2015 dpdk_socket_mem: "1024,1024"
2016 dpdk_lcore_mask: "0x400"
2017 memory_channels: 2
2018 interface:
2019 dpdk_second_nic:
2020 name: ${_param:primary_second_nic}
2021 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002022 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002023 bond: dpdkbond0
2024 enabled: true
2025 type: dpdk_ovs_port
2026 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002027 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002028 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002029 dpdk_first_nic:
2030 name: ${_param:primary_first_nic}
2031 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002032 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002033 bond: dpdkbond0
2034 enabled: true
2035 type: dpdk_ovs_port
2036 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002037 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002038 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002039 dpdkbond0:
2040 enabled: true
2041 bridge: br-prv
2042 type: dpdk_ovs_bond
2043 mode: active-backup
2044 br-prv:
2045 enabled: true
2046 type: dpdk_ovs_bridge
2047
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01002048**DPDK OVS LACP Bond with vlan tag**
2049
2050.. code-block:: yaml
2051
2052 linux:
2053 network:
2054 bridge: openvswitch
2055 dpdk:
2056 enabled: true
2057 driver: uio
2058 openvswitch:
2059 pmd_cpu_mask: "0x6"
2060 dpdk_socket_mem: "1024,1024"
2061 dpdk_lcore_mask: "0x400"
2062 memory_channels: "2"
2063 interface:
2064 eth3:
2065 enabled: true
2066 type: eth
2067 proto: manual
2068 name: ${_param:tenant_first_nic}
2069 eth4:
2070 enabled: true
2071 type: eth
2072 proto: manual
2073 name: ${_param:tenant_second_nic}
2074 dpdk0:
2075 name: ${_param:tenant_first_nic}
2076 pci: "0000:81:00.0"
2077 driver: igb_uio
2078 bond: bond1
2079 enabled: true
2080 type: dpdk_ovs_port
2081 n_rxq: 2
2082 dpdk1:
2083 name: ${_param:tenant_second_nic}
2084 pci: "0000:81:00.1"
2085 driver: igb_uio
2086 bond: bond1
2087 enabled: true
2088 type: dpdk_ovs_port
2089 n_rxq: 2
2090 bond1:
2091 enabled: true
2092 bridge: br-prv
2093 type: dpdk_ovs_bond
2094 mode: balance-slb
2095 br-prv:
2096 enabled: true
2097 type: dpdk_ovs_bridge
2098 tag: ${_param:tenant_vlan}
2099 address: ${_param:tenant_address}
2100 netmask: ${_param:tenant_network_netmask}
2101
Jakub Pavlikaa759062017-03-13 15:57:26 +01002102**DPDK OVS bridge for VXLAN**
2103
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002104If VXLAN is used as tenant segmentation, IP address must
2105be set on ``br-prv``.
Jakub Pavlikaa759062017-03-13 15:57:26 +01002106
2107.. code-block:: yaml
2108
2109 linux:
2110 network:
2111 ...
2112 interface:
2113 br-prv:
2114 enabled: true
2115 type: dpdk_ovs_bridge
2116 address: 192.168.50.0
2117 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04002118 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01002119 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002120
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02002121**DPDK OVS bridge with Linux network interface**
2122
2123.. code-block:: yaml
2124
2125 linux:
2126 network:
2127 ...
2128 interface:
2129 eth0:
2130 type: eth
2131 ovs_bridge: br-prv
2132 ...
2133 br-prv:
2134 enabled: true
2135 type: dpdk_ovs_bridge
2136 ...
2137
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002138Linux storage
2139-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02002140
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002141Linux with mounted Samba:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002142
2143.. code-block:: yaml
2144
2145 linux:
2146 storage:
2147 enabled: true
2148 mount:
2149 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01002150 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02002151 - path: /media/myuser/public/
2152 - device: //192.168.0.1/storage
2153 - file_system: cifs
2154 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
2155
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002156NFS mount:
Jiri Broulikb017f932017-03-31 13:55:36 +02002157
2158.. code-block:: yaml
2159
2160 linux:
2161 storage:
2162 enabled: true
2163 mount:
2164 nfs_glance:
2165 enabled: true
2166 path: /var/lib/glance/images
2167 device: 172.16.10.110:/var/nfs/glance
2168 file_system: nfs
2169 opts: rw,sync
2170
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002171File swap configuration:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002172
2173.. code-block:: yaml
2174
2175 linux:
2176 storage:
2177 enabled: true
2178 swap:
2179 file:
2180 enabled: true
2181 engine: file
2182 device: /swapfile
2183 size: 1024
2184
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002185Partition swap configuration:
Lachlan Evenson30676512016-01-22 15:43:28 -08002186
2187.. code-block:: yaml
2188
2189 linux:
2190 storage:
2191 enabled: true
2192 swap:
2193 partition:
2194 enabled: true
2195 engine: partition
2196 device: /dev/vg0/swap
2197
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002198LVM group ``vg1`` with one device and ``data`` volume mounted
2199into ``/mnt/data``.
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002200
2201.. code-block:: yaml
2202
2203 parameters:
2204 linux:
2205 storage:
2206 mount:
2207 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01002208 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002209 device: /dev/vg1/data
2210 file_system: ext4
2211 path: /mnt/data
2212 lvm:
2213 vg1:
2214 enabled: true
2215 devices:
2216 - /dev/sdb
2217 volume:
2218 data:
2219 size: 40G
2220 mount: ${linux:storage:mount:data}
root40bb5e72019-01-11 08:55:32 +00002221 # When set they will take precedence over filters aget from volume groups.
2222 lvm_filters:
2223 10:
2224 enabled: True
2225 value: "a|loop|"
2226 20:
2227 enabled: True
2228 value: "r|/dev/hdc|"
2229 30:
2230 enabled: True
2231 value: "a|/dev/ide|"
2232 40:
2233 enabled: True
2234 value: "r|.*|"
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002235
Jakub Pavlik4f742142017-08-08 15:05:50 +02002236Create partitions on disk. Specify size in MB. It expects empty
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002237disk without any existing partitions.
2238Set ``startsector=1`` if you want to start partitions from ``2048``.
Jakub Pavlik4f742142017-08-08 15:05:50 +02002239
2240.. code-block:: yaml
2241
2242 linux:
2243 storage:
2244 disk:
2245 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01002246 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02002247 name: /dev/loop1
2248 type: gpt
2249 partitions:
2250 - size: 200 #size in MB
2251 type: fat32
2252 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02002253 mkfs: True
2254 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02002255 /dev/vda1:
2256 partitions:
2257 - size: 5
2258 type: ext2
2259 - size: 10
2260 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02002261
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002262Multipath with Fujitsu Eternus DXL:
Ales Komareka634f4b2016-10-02 13:11:04 +02002263
2264.. code-block:: yaml
2265
2266 parameters:
2267 linux:
2268 storage:
2269 multipath:
2270 enabled: true
2271 blacklist_devices:
2272 - /dev/sda
2273 - /dev/sdb
2274 backends:
2275 - fujitsu_eternus_dxl
2276
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002277Multipath with Hitachi VSP 1000:
Ales Komareka634f4b2016-10-02 13:11:04 +02002278
2279.. code-block:: yaml
2280
2281 parameters:
2282 linux:
2283 storage:
2284 multipath:
2285 enabled: true
2286 blacklist_devices:
2287 - /dev/sda
2288 - /dev/sdb
2289 backends:
2290 - hitachi_vsp1000
2291
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002292Multipath with IBM Storwize:
Ales Komareka634f4b2016-10-02 13:11:04 +02002293
2294.. code-block:: yaml
2295
2296 parameters:
2297 linux:
2298 storage:
2299 multipath:
2300 enabled: true
2301 blacklist_devices:
2302 - /dev/sda
2303 - /dev/sdb
2304 backends:
2305 - ibm_storwize
2306
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002307Multipath with multiple backends:
Ales Komareka634f4b2016-10-02 13:11:04 +02002308
2309.. code-block:: yaml
2310
2311 parameters:
2312 linux:
2313 storage:
2314 multipath:
2315 enabled: true
2316 blacklist_devices:
2317 - /dev/sda
2318 - /dev/sdb
2319 - /dev/sdc
2320 - /dev/sdd
2321 backends:
2322 - ibm_storwize
2323 - fujitsu_eternus_dxl
2324 - hitachi_vsp1000
2325
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002326PAM LDAP integration:
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002327
2328.. code-block:: yaml
2329
2330 parameters:
2331 linux:
2332 system:
2333 auth:
2334 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02002335 mkhomedir:
2336 enabled: true
2337 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002338 ldap:
2339 enabled: true
2340 binddn: cn=bind,ou=service_users,dc=example,dc=com
2341 bindpw: secret
2342 uri: ldap://127.0.0.1
2343 base: ou=users,dc=example,dc=com
2344 ldap_version: 3
2345 pagesize: 65536
2346 referrals: off
2347 filter:
2348 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2349 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2350 group: (&(objectClass=group)(gidNumber=*))
2351
Gleb Galkin93b9ae92018-10-18 13:57:30 +03002352PAM duo 2FA integration
2353
2354.. code-block:: yaml
2355
2356 parameters:
2357 linux:
2358 system:
2359 auth:
2360 enabled: true
2361 duo:
2362 enabled: true
2363 duo_host: localhost
2364 duo_ikey: DUO-INTEGRATION-KEY
2365 duo_skey: DUO-SECRET-KEY
2366
2367duo package version may be specified (optional)
2368
2369.. code-block:: yaml
2370
2371 linux:
2372 system:
2373 package:
2374 duo-unix:
2375 version: 1.10.1-0
2376
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002377Disabled multipath (the default setup):
Ales Komareka634f4b2016-10-02 13:11:04 +02002378
2379.. code-block:: yaml
2380
2381 parameters:
2382 linux:
2383 storage:
2384 multipath:
2385 enabled: false
2386
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002387Linux with local loopback device:
Simon Pasquier375001e2017-01-26 13:22:33 +01002388
2389.. code-block:: yaml
2390
2391 linux:
2392 storage:
2393 loopback:
2394 disk1:
2395 file: /srv/disk1
2396 size: 50G
2397
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002398External config generation
2399--------------------------
2400
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002401You are able to use config support metadata between formulas
2402and only generate configuration files for external use, for example, Docker, and so on.
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002403
2404.. code-block:: yaml
2405
2406 parameters:
2407 linux:
2408 system:
2409 config:
2410 pillar:
2411 jenkins:
2412 master:
2413 home: /srv/volumes/jenkins
2414 approved_scripts:
2415 - method java.net.URL openConnection
2416 credentials:
2417 - type: username_password
2418 scope: global
2419 id: test
2420 desc: Testing credentials
2421 username: test
2422 password: test
2423
Vladimir Ereminccf28842017-04-10 23:52:10 +03002424Netconsole Remote Kernel Logging
2425--------------------------------
2426
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002427Netconsole logger can be configured for the configfs-enabled kernels
2428(``CONFIG_NETCONSOLE_DYNAMIC`` must be enabled). The configuration
2429applies both in runtime (if network is already configured),
2430and on-boot after an interface initialization.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002431
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002432.. note::
2433
2434 * Receiver can be located only on the same L3 domain
2435 (or you need to configure gateway MAC manually).
2436 * The Receiver MAC is detected only on configuration time.
2437 * Using broadcast MAC is not recommended.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002438
2439.. code-block:: yaml
2440
2441 parameters:
2442 linux:
2443 system:
2444 netconsole:
2445 enabled: true
2446 port: 514 (optional)
2447 loglevel: debug (optional)
2448 target:
2449 192.168.0.1:
2450 interface: bond0
2451 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02002452
Dzmitry Stremkouskid1a268b2018-10-03 16:36:04 +02002453Check network params on the environment
2454---------------------------------------
2455
2456Grab nics and nics states
2457
2458.. code-block:: bash
2459
2460 salt osd001\* net_checks.get_nics
2461
2462**Example of system output:**
2463
2464.. code-block:: bash
2465
2466 osd001.domain.com:
2467 |_
2468 - bond0
2469 - None
2470 - 1e:c8:64:42:23:b9
2471 - 0
2472 - 1500
2473 |_
2474 - bond1
2475 - None
2476 - 3c:fd:fe:27:3b:00
2477 - 1
2478 - 9100
2479 |_
2480 - fourty1
2481 - None
2482 - 3c:fd:fe:27:3b:00
2483 - 1
2484 - 9100
2485 |_
2486 - fourty2
2487 - None
2488 - 3c:fd:fe:27:3b:02
2489 - 1
2490 - 9100
2491
2492Grab 10G nics PCI addresses for hugepages setup
2493
2494.. code-block:: bash
2495
2496 salt cmp001\* net_checks.get_ten_pci
2497
2498**Example of system output:**
2499
2500.. code-block:: bash
2501
2502 cmp001.domain.com:
2503 |_
2504 - ten1
2505 - 0000:19:00.0
2506 |_
2507 - ten2
2508 - 0000:19:00.1
2509 |_
2510 - ten3
2511 - 0000:19:00.2
2512 |_
2513 - ten4
2514 - 0000:19:00.3
2515
2516Grab ip address for an interface
2517
2518.. code-block:: bash
2519
2520 salt cmp001\* net_checks.get_ip iface=one4
2521
2522**Example of system output:**
2523
2524.. code-block:: bash
2525
2526 cmp001.domain.com:
2527 10.200.177.101
2528
2529Grab ip addresses map
2530
2531.. code-block:: bash
2532
2533 salt-call net_checks.nodes_addresses
2534
2535**Example of system output:**
2536
2537.. code-block:: bash
2538
2539 local:
2540 |_
2541 - cid01.domain.com
2542 |_
2543 |_
2544 - pxe
2545 - 10.200.177.91
2546 |_
2547 - control
2548 - 10.200.178.91
2549 |_
2550 - cmn02.domain.com
2551 |_
2552 |_
2553 - storage_access
2554 - 10.200.181.67
2555 |_
2556 - pxe
2557 - 10.200.177.67
2558 |_
2559 - control
2560 - 10.200.178.67
2561 |_
2562 - cmp010.domain.com
2563 |_
2564 |_
2565 - pxe
2566 - 10.200.177.110
2567 |_
2568 - storage_access
2569 - 10.200.181.110
2570 |_
2571 - control
2572 - 10.200.178.110
2573 |_
2574 - vxlan
2575 - 10.200.179.110
2576
2577Verify full mesh connectivity
2578
2579.. code-block:: bash
2580
2581 salt-call net_checks.ping_check
2582
2583**Example of positive system output:**
2584
2585.. code-block:: bash
2586
2587 ['PASSED']
2588 [INFO ] ['PASSED']
2589 local:
2590 True
2591
2592**Example of system output in case of failure:**
2593
2594.. code-block:: bash
2595
2596 FAILED
2597 [ERROR ] FAILED
2598 ['control: 10.0.1.92 -> 10.0.1.224: Failed']
2599 ['control: 10.0.1.93 -> 10.0.1.224: Failed']
2600 ['control: 10.0.1.51 -> 10.0.1.224: Failed']
2601 ['control: 10.0.1.102 -> 10.0.1.224: Failed']
2602 ['control: 10.0.1.13 -> 10.0.1.224: Failed']
2603 ['control: 10.0.1.81 -> 10.0.1.224: Failed']
2604 local:
2605 False
2606
2607For this feature to work, please mark addresses with some role.
2608Otherwise 'default' role is assumed and mesh would consist of all
2609addresses on the environment.
2610
2611Mesh mark is needed only for interfaces which are enabled and have
2612ip address assigned.
2613
2614Checking dhcp pxe network meaningless, as it is used for salt
2615master vs minion communications, therefore treated as checked.
2616
2617.. code-block:: yaml
2618
2619 parameters:
2620 linux:
2621 network:
2622 interface:
2623 ens3:
2624 enabled: true
2625 type: eth
2626 proto: static
2627 address: ${_param:deploy_address}
2628 netmask: ${_param:deploy_network_netmask}
2629 gateway: ${_param:deploy_network_gateway}
2630 mesh: pxe
2631
2632Check pillars for ip address duplicates
2633
2634.. code-block:: bash
2635
2636 salt-call net_checks.verify_addresses
2637
2638**Example of positive system output:**
2639
2640.. code-block:: bash
2641
2642 ['PASSED']
2643 [INFO ] ['PASSED']
2644 local:
2645 True
2646
2647**Example of system output in case of failure:**
2648
2649.. code-block:: bash
2650
2651 FAILED. Duplicates found
2652 [ERROR ] FAILED. Duplicates found
2653 ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2654 [ERROR ] ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2655 local:
2656 False
2657
2658Generate csv report for the env
2659
2660.. code-block:: bash
2661
2662 salt -C 'kvm* or cmp* or osd*' net_checks.get_nics_csv \
2663 | grep '^\ ' | sed 's/\ *//g' | grep -Ev ^server \
2664 | sed '1 i\server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr'
2665
2666**Example of system output:**
2667
2668.. code-block:: bash
2669
2670 server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr
2671 cmp010.domain.com,bond0,None,b4:96:91:10:5b:3a,1,1500,,,,
2672 cmp010.domain.com,bond0.21,10.200.178.110,b4:96:91:10:5b:3a,1,1500,,,,
2673 cmp010.domain.com,bond0.22,10.200.179.110,b4:96:91:10:5b:3a,1,1500,,,,
2674 cmp010.domain.com,bond1,None,3c:fd:fe:34:ad:22,0,1500,,,,
2675 cmp010.domain.com,bond1.24,10.200.181.110,3c:fd:fe:34:ad:22,0,1500,,,,
2676 cmp010.domain.com,fourty5,None,3c:fd:fe:34:ad:20,0,9000,,,,
2677 cmp010.domain.com,fourty6,None,3c:fd:fe:34:ad:22,0,9000,,,,
2678 cmp010.domain.com,one1,None,b4:96:91:10:5b:38,0,1500,,,,
2679 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
2680 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
2681 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
2682 cmp011.domain.com,bond0,None,b4:96:91:13:6c:aa,1,1500,,,,
2683 cmp011.domain.com,bond0.21,10.200.178.111,b4:96:91:13:6c:aa,1,1500,,,,
2684 cmp011.domain.com,bond0.22,10.200.179.111,b4:96:91:13:6c:aa,1,1500,,,,
2685 ...
2686
Filip Pytlounf5383a42015-10-06 16:28:32 +02002687Usage
2688=====
2689
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002690Set MTU of the eth0 network interface to 1400:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002691
2692.. code-block:: bash
2693
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002694 ip link set dev eth0 mtu 1400
Filip Pytlounf5383a42015-10-06 16:28:32 +02002695
2696Read more
2697=========
2698
2699* https://www.archlinux.org/
2700* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu