blob: 3832eac106e19d7b5d0db98f7ebb519fa05d5611 [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
Michael Polenchuk6e3042b2019-04-22 15:20:03 +04001965Auto repair/re-attach libvirt's vnet interfaces:
1966
1967.. code-block:: yaml
1968
1969 linux:
1970 network:
1971 libvirt_vnet_repair: true
1972
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001973DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001974
1975**DPDK OVS NIC**
1976
1977.. code-block:: yaml
1978
1979 linux:
1980 network:
1981 bridge: openvswitch
1982 dpdk:
1983 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001984 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001985 openvswitch:
1986 pmd_cpu_mask: "0x6"
1987 dpdk_socket_mem: "1024,1024"
1988 dpdk_lcore_mask: "0x400"
1989 memory_channels: 2
1990 interface:
1991 dpkd0:
1992 name: ${_param:dpdk_nic}
1993 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001994 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001995 enabled: true
1996 type: dpdk_ovs_port
1997 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001998 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001999 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01002000 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002001 br-prv:
2002 enabled: true
2003 type: dpdk_ovs_bridge
Michael Polenchukd3378db2018-12-29 16:46:50 +04002004 br-floating:
2005 enabled: true
2006 type: ovs_bridge
2007 name_servers:
2008 - 1.1.1.1
2009 - 9.9.9.9
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002010
2011**DPDK OVS Bond**
2012
2013.. code-block:: yaml
2014
2015 linux:
2016 network:
2017 bridge: openvswitch
2018 dpdk:
2019 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04002020 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002021 openvswitch:
2022 pmd_cpu_mask: "0x6"
2023 dpdk_socket_mem: "1024,1024"
2024 dpdk_lcore_mask: "0x400"
2025 memory_channels: 2
2026 interface:
2027 dpdk_second_nic:
2028 name: ${_param:primary_second_nic}
2029 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002030 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002031 bond: dpdkbond0
2032 enabled: true
2033 type: dpdk_ovs_port
2034 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002035 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002036 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002037 dpdk_first_nic:
2038 name: ${_param:primary_first_nic}
2039 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002040 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002041 bond: dpdkbond0
2042 enabled: true
2043 type: dpdk_ovs_port
2044 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002045 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002046 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002047 dpdkbond0:
2048 enabled: true
2049 bridge: br-prv
2050 type: dpdk_ovs_bond
2051 mode: active-backup
2052 br-prv:
2053 enabled: true
2054 type: dpdk_ovs_bridge
2055
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01002056**DPDK OVS LACP Bond with vlan tag**
2057
2058.. code-block:: yaml
2059
2060 linux:
2061 network:
2062 bridge: openvswitch
2063 dpdk:
2064 enabled: true
2065 driver: uio
2066 openvswitch:
2067 pmd_cpu_mask: "0x6"
2068 dpdk_socket_mem: "1024,1024"
2069 dpdk_lcore_mask: "0x400"
2070 memory_channels: "2"
2071 interface:
2072 eth3:
2073 enabled: true
2074 type: eth
2075 proto: manual
2076 name: ${_param:tenant_first_nic}
2077 eth4:
2078 enabled: true
2079 type: eth
2080 proto: manual
2081 name: ${_param:tenant_second_nic}
2082 dpdk0:
2083 name: ${_param:tenant_first_nic}
2084 pci: "0000:81:00.0"
2085 driver: igb_uio
2086 bond: bond1
2087 enabled: true
2088 type: dpdk_ovs_port
2089 n_rxq: 2
2090 dpdk1:
2091 name: ${_param:tenant_second_nic}
2092 pci: "0000:81:00.1"
2093 driver: igb_uio
2094 bond: bond1
2095 enabled: true
2096 type: dpdk_ovs_port
2097 n_rxq: 2
2098 bond1:
2099 enabled: true
2100 bridge: br-prv
2101 type: dpdk_ovs_bond
2102 mode: balance-slb
2103 br-prv:
2104 enabled: true
2105 type: dpdk_ovs_bridge
2106 tag: ${_param:tenant_vlan}
2107 address: ${_param:tenant_address}
2108 netmask: ${_param:tenant_network_netmask}
2109
Jakub Pavlikaa759062017-03-13 15:57:26 +01002110**DPDK OVS bridge for VXLAN**
2111
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002112If VXLAN is used as tenant segmentation, IP address must
2113be set on ``br-prv``.
Jakub Pavlikaa759062017-03-13 15:57:26 +01002114
2115.. code-block:: yaml
2116
2117 linux:
2118 network:
2119 ...
2120 interface:
2121 br-prv:
2122 enabled: true
2123 type: dpdk_ovs_bridge
2124 address: 192.168.50.0
2125 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04002126 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01002127 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002128
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02002129**DPDK OVS bridge with Linux network interface**
2130
2131.. code-block:: yaml
2132
2133 linux:
2134 network:
2135 ...
2136 interface:
2137 eth0:
2138 type: eth
2139 ovs_bridge: br-prv
2140 ...
2141 br-prv:
2142 enabled: true
2143 type: dpdk_ovs_bridge
2144 ...
2145
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002146Linux storage
2147-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02002148
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002149Linux with mounted Samba:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002150
2151.. code-block:: yaml
2152
2153 linux:
2154 storage:
2155 enabled: true
2156 mount:
2157 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01002158 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02002159 - path: /media/myuser/public/
2160 - device: //192.168.0.1/storage
2161 - file_system: cifs
2162 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
2163
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002164NFS mount:
Jiri Broulikb017f932017-03-31 13:55:36 +02002165
2166.. code-block:: yaml
2167
2168 linux:
2169 storage:
2170 enabled: true
2171 mount:
2172 nfs_glance:
2173 enabled: true
2174 path: /var/lib/glance/images
2175 device: 172.16.10.110:/var/nfs/glance
2176 file_system: nfs
2177 opts: rw,sync
2178
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002179File swap configuration:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002180
2181.. code-block:: yaml
2182
2183 linux:
2184 storage:
2185 enabled: true
2186 swap:
2187 file:
2188 enabled: true
2189 engine: file
2190 device: /swapfile
2191 size: 1024
2192
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002193Partition swap configuration:
Lachlan Evenson30676512016-01-22 15:43:28 -08002194
2195.. code-block:: yaml
2196
2197 linux:
2198 storage:
2199 enabled: true
2200 swap:
2201 partition:
2202 enabled: true
2203 engine: partition
2204 device: /dev/vg0/swap
2205
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002206LVM group ``vg1`` with one device and ``data`` volume mounted
2207into ``/mnt/data``.
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002208
2209.. code-block:: yaml
2210
2211 parameters:
2212 linux:
2213 storage:
2214 mount:
2215 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01002216 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002217 device: /dev/vg1/data
2218 file_system: ext4
2219 path: /mnt/data
2220 lvm:
2221 vg1:
2222 enabled: true
2223 devices:
2224 - /dev/sdb
2225 volume:
2226 data:
2227 size: 40G
2228 mount: ${linux:storage:mount:data}
root40bb5e72019-01-11 08:55:32 +00002229 # When set they will take precedence over filters aget from volume groups.
2230 lvm_filters:
2231 10:
2232 enabled: True
2233 value: "a|loop|"
2234 20:
2235 enabled: True
2236 value: "r|/dev/hdc|"
2237 30:
2238 enabled: True
2239 value: "a|/dev/ide|"
2240 40:
2241 enabled: True
2242 value: "r|.*|"
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002243
Jakub Pavlik4f742142017-08-08 15:05:50 +02002244Create partitions on disk. Specify size in MB. It expects empty
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002245disk without any existing partitions.
2246Set ``startsector=1`` if you want to start partitions from ``2048``.
Jakub Pavlik4f742142017-08-08 15:05:50 +02002247
2248.. code-block:: yaml
2249
2250 linux:
2251 storage:
2252 disk:
2253 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01002254 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02002255 name: /dev/loop1
2256 type: gpt
2257 partitions:
2258 - size: 200 #size in MB
2259 type: fat32
2260 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02002261 mkfs: True
2262 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02002263 /dev/vda1:
2264 partitions:
2265 - size: 5
2266 type: ext2
2267 - size: 10
2268 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02002269
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002270Multipath with Fujitsu Eternus DXL:
Ales Komareka634f4b2016-10-02 13:11:04 +02002271
2272.. code-block:: yaml
2273
2274 parameters:
2275 linux:
2276 storage:
2277 multipath:
2278 enabled: true
2279 blacklist_devices:
2280 - /dev/sda
2281 - /dev/sdb
2282 backends:
2283 - fujitsu_eternus_dxl
2284
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002285Multipath with Hitachi VSP 1000:
Ales Komareka634f4b2016-10-02 13:11:04 +02002286
2287.. code-block:: yaml
2288
2289 parameters:
2290 linux:
2291 storage:
2292 multipath:
2293 enabled: true
2294 blacklist_devices:
2295 - /dev/sda
2296 - /dev/sdb
2297 backends:
2298 - hitachi_vsp1000
2299
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002300Multipath with IBM Storwize:
Ales Komareka634f4b2016-10-02 13:11:04 +02002301
2302.. code-block:: yaml
2303
2304 parameters:
2305 linux:
2306 storage:
2307 multipath:
2308 enabled: true
2309 blacklist_devices:
2310 - /dev/sda
2311 - /dev/sdb
2312 backends:
2313 - ibm_storwize
2314
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002315Multipath with multiple backends:
Ales Komareka634f4b2016-10-02 13:11:04 +02002316
2317.. code-block:: yaml
2318
2319 parameters:
2320 linux:
2321 storage:
2322 multipath:
2323 enabled: true
2324 blacklist_devices:
2325 - /dev/sda
2326 - /dev/sdb
2327 - /dev/sdc
2328 - /dev/sdd
2329 backends:
2330 - ibm_storwize
2331 - fujitsu_eternus_dxl
2332 - hitachi_vsp1000
2333
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002334PAM LDAP integration:
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002335
2336.. code-block:: yaml
2337
2338 parameters:
2339 linux:
2340 system:
2341 auth:
2342 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02002343 mkhomedir:
2344 enabled: true
2345 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002346 ldap:
2347 enabled: true
2348 binddn: cn=bind,ou=service_users,dc=example,dc=com
2349 bindpw: secret
2350 uri: ldap://127.0.0.1
2351 base: ou=users,dc=example,dc=com
2352 ldap_version: 3
2353 pagesize: 65536
2354 referrals: off
2355 filter:
2356 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2357 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2358 group: (&(objectClass=group)(gidNumber=*))
2359
Gleb Galkin93b9ae92018-10-18 13:57:30 +03002360PAM duo 2FA integration
2361
2362.. code-block:: yaml
2363
2364 parameters:
2365 linux:
2366 system:
2367 auth:
2368 enabled: true
2369 duo:
2370 enabled: true
2371 duo_host: localhost
2372 duo_ikey: DUO-INTEGRATION-KEY
2373 duo_skey: DUO-SECRET-KEY
2374
2375duo package version may be specified (optional)
2376
2377.. code-block:: yaml
2378
2379 linux:
2380 system:
2381 package:
2382 duo-unix:
2383 version: 1.10.1-0
2384
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002385Disabled multipath (the default setup):
Ales Komareka634f4b2016-10-02 13:11:04 +02002386
2387.. code-block:: yaml
2388
2389 parameters:
2390 linux:
2391 storage:
2392 multipath:
2393 enabled: false
2394
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002395Linux with local loopback device:
Simon Pasquier375001e2017-01-26 13:22:33 +01002396
2397.. code-block:: yaml
2398
2399 linux:
2400 storage:
2401 loopback:
2402 disk1:
2403 file: /srv/disk1
2404 size: 50G
2405
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002406External config generation
2407--------------------------
2408
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002409You are able to use config support metadata between formulas
2410and only generate configuration files for external use, for example, Docker, and so on.
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002411
2412.. code-block:: yaml
2413
2414 parameters:
2415 linux:
2416 system:
2417 config:
2418 pillar:
2419 jenkins:
2420 master:
2421 home: /srv/volumes/jenkins
2422 approved_scripts:
2423 - method java.net.URL openConnection
2424 credentials:
2425 - type: username_password
2426 scope: global
2427 id: test
2428 desc: Testing credentials
2429 username: test
2430 password: test
2431
Vladimir Ereminccf28842017-04-10 23:52:10 +03002432Netconsole Remote Kernel Logging
2433--------------------------------
2434
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002435Netconsole logger can be configured for the configfs-enabled kernels
2436(``CONFIG_NETCONSOLE_DYNAMIC`` must be enabled). The configuration
2437applies both in runtime (if network is already configured),
2438and on-boot after an interface initialization.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002439
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002440.. note::
2441
2442 * Receiver can be located only on the same L3 domain
2443 (or you need to configure gateway MAC manually).
2444 * The Receiver MAC is detected only on configuration time.
2445 * Using broadcast MAC is not recommended.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002446
2447.. code-block:: yaml
2448
2449 parameters:
2450 linux:
2451 system:
2452 netconsole:
2453 enabled: true
2454 port: 514 (optional)
2455 loglevel: debug (optional)
2456 target:
2457 192.168.0.1:
2458 interface: bond0
2459 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02002460
Dzmitry Stremkouskid1a268b2018-10-03 16:36:04 +02002461Check network params on the environment
2462---------------------------------------
2463
2464Grab nics and nics states
2465
2466.. code-block:: bash
2467
2468 salt osd001\* net_checks.get_nics
2469
2470**Example of system output:**
2471
2472.. code-block:: bash
2473
2474 osd001.domain.com:
2475 |_
2476 - bond0
2477 - None
2478 - 1e:c8:64:42:23:b9
2479 - 0
2480 - 1500
2481 |_
2482 - bond1
2483 - None
2484 - 3c:fd:fe:27:3b:00
2485 - 1
2486 - 9100
2487 |_
2488 - fourty1
2489 - None
2490 - 3c:fd:fe:27:3b:00
2491 - 1
2492 - 9100
2493 |_
2494 - fourty2
2495 - None
2496 - 3c:fd:fe:27:3b:02
2497 - 1
2498 - 9100
2499
2500Grab 10G nics PCI addresses for hugepages setup
2501
2502.. code-block:: bash
2503
2504 salt cmp001\* net_checks.get_ten_pci
2505
2506**Example of system output:**
2507
2508.. code-block:: bash
2509
2510 cmp001.domain.com:
2511 |_
2512 - ten1
2513 - 0000:19:00.0
2514 |_
2515 - ten2
2516 - 0000:19:00.1
2517 |_
2518 - ten3
2519 - 0000:19:00.2
2520 |_
2521 - ten4
2522 - 0000:19:00.3
2523
2524Grab ip address for an interface
2525
2526.. code-block:: bash
2527
2528 salt cmp001\* net_checks.get_ip iface=one4
2529
2530**Example of system output:**
2531
2532.. code-block:: bash
2533
2534 cmp001.domain.com:
2535 10.200.177.101
2536
2537Grab ip addresses map
2538
2539.. code-block:: bash
2540
2541 salt-call net_checks.nodes_addresses
2542
2543**Example of system output:**
2544
2545.. code-block:: bash
2546
2547 local:
2548 |_
2549 - cid01.domain.com
2550 |_
2551 |_
2552 - pxe
2553 - 10.200.177.91
2554 |_
2555 - control
2556 - 10.200.178.91
2557 |_
2558 - cmn02.domain.com
2559 |_
2560 |_
2561 - storage_access
2562 - 10.200.181.67
2563 |_
2564 - pxe
2565 - 10.200.177.67
2566 |_
2567 - control
2568 - 10.200.178.67
2569 |_
2570 - cmp010.domain.com
2571 |_
2572 |_
2573 - pxe
2574 - 10.200.177.110
2575 |_
2576 - storage_access
2577 - 10.200.181.110
2578 |_
2579 - control
2580 - 10.200.178.110
2581 |_
2582 - vxlan
2583 - 10.200.179.110
2584
2585Verify full mesh connectivity
2586
2587.. code-block:: bash
2588
2589 salt-call net_checks.ping_check
2590
2591**Example of positive system output:**
2592
2593.. code-block:: bash
2594
2595 ['PASSED']
2596 [INFO ] ['PASSED']
2597 local:
2598 True
2599
2600**Example of system output in case of failure:**
2601
2602.. code-block:: bash
2603
2604 FAILED
2605 [ERROR ] FAILED
2606 ['control: 10.0.1.92 -> 10.0.1.224: Failed']
2607 ['control: 10.0.1.93 -> 10.0.1.224: Failed']
2608 ['control: 10.0.1.51 -> 10.0.1.224: Failed']
2609 ['control: 10.0.1.102 -> 10.0.1.224: Failed']
2610 ['control: 10.0.1.13 -> 10.0.1.224: Failed']
2611 ['control: 10.0.1.81 -> 10.0.1.224: Failed']
2612 local:
2613 False
2614
2615For this feature to work, please mark addresses with some role.
2616Otherwise 'default' role is assumed and mesh would consist of all
2617addresses on the environment.
2618
2619Mesh mark is needed only for interfaces which are enabled and have
2620ip address assigned.
2621
2622Checking dhcp pxe network meaningless, as it is used for salt
2623master vs minion communications, therefore treated as checked.
2624
2625.. code-block:: yaml
2626
2627 parameters:
2628 linux:
2629 network:
2630 interface:
2631 ens3:
2632 enabled: true
2633 type: eth
2634 proto: static
2635 address: ${_param:deploy_address}
2636 netmask: ${_param:deploy_network_netmask}
2637 gateway: ${_param:deploy_network_gateway}
2638 mesh: pxe
2639
2640Check pillars for ip address duplicates
2641
2642.. code-block:: bash
2643
2644 salt-call net_checks.verify_addresses
2645
2646**Example of positive system output:**
2647
2648.. code-block:: bash
2649
2650 ['PASSED']
2651 [INFO ] ['PASSED']
2652 local:
2653 True
2654
2655**Example of system output in case of failure:**
2656
2657.. code-block:: bash
2658
2659 FAILED. Duplicates found
2660 [ERROR ] FAILED. Duplicates found
2661 ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2662 [ERROR ] ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2663 local:
2664 False
2665
2666Generate csv report for the env
2667
2668.. code-block:: bash
2669
2670 salt -C 'kvm* or cmp* or osd*' net_checks.get_nics_csv \
2671 | grep '^\ ' | sed 's/\ *//g' | grep -Ev ^server \
2672 | sed '1 i\server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr'
2673
2674**Example of system output:**
2675
2676.. code-block:: bash
2677
2678 server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr
2679 cmp010.domain.com,bond0,None,b4:96:91:10:5b:3a,1,1500,,,,
2680 cmp010.domain.com,bond0.21,10.200.178.110,b4:96:91:10:5b:3a,1,1500,,,,
2681 cmp010.domain.com,bond0.22,10.200.179.110,b4:96:91:10:5b:3a,1,1500,,,,
2682 cmp010.domain.com,bond1,None,3c:fd:fe:34:ad:22,0,1500,,,,
2683 cmp010.domain.com,bond1.24,10.200.181.110,3c:fd:fe:34:ad:22,0,1500,,,,
2684 cmp010.domain.com,fourty5,None,3c:fd:fe:34:ad:20,0,9000,,,,
2685 cmp010.domain.com,fourty6,None,3c:fd:fe:34:ad:22,0,9000,,,,
2686 cmp010.domain.com,one1,None,b4:96:91:10:5b:38,0,1500,,,,
2687 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
2688 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
2689 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
2690 cmp011.domain.com,bond0,None,b4:96:91:13:6c:aa,1,1500,,,,
2691 cmp011.domain.com,bond0.21,10.200.178.111,b4:96:91:13:6c:aa,1,1500,,,,
2692 cmp011.domain.com,bond0.22,10.200.179.111,b4:96:91:13:6c:aa,1,1500,,,,
2693 ...
2694
Filip Pytlounf5383a42015-10-06 16:28:32 +02002695Usage
2696=====
2697
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002698Set MTU of the eth0 network interface to 1400:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002699
2700.. code-block:: bash
2701
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002702 ip link set dev eth0 mtu 1400
Filip Pytlounf5383a42015-10-06 16:28:32 +02002703
2704Read more
2705=========
2706
2707* https://www.archlinux.org/
2708* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu