blob: 7fe17054e937c84d017fb94dfb55b39c8a748a1f [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 Teselkinc7814732019-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 Teselkinc7814732019-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
Filip Pytloun281034a2016-01-04 18:06:22 +0100564Kernel
565~~~~~~
566
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300567Install always up to date LTS kernel and headers from Ubuntu Trusty:
Filip Pytloun281034a2016-01-04 18:06:22 +0100568
569.. code-block:: yaml
570
571 linux:
572 system:
573 kernel:
574 type: generic
575 lts: trusty
576 headers: true
577
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300578Load kernel modules and add them to ``/etc/modules``:
Tomáš Kukrálba35b212017-02-15 17:59:46 +0100579
580.. code-block:: yaml
581
582 linux:
583 system:
584 kernel:
585 modules:
586 - nf_conntrack
587 - tp_smapi
588 - 8021q
589
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300590Configure or blacklist kernel modules with additional options to
591``/etc/modprobe.d`` following example will add
592``/etc/modprobe.d/nf_conntrack.conf`` file with line
593``options nf_conntrack hashsize=262144``:
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300594
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300595'option' can be a mapping (with 'enabled' and 'value' keys) or a scalar.
596
597Example for 'scalar' option value:
598
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300599.. code-block:: yaml
600
601 linux:
602 system:
603 kernel:
604 module:
605 nf_conntrack:
606 option:
607 hashsize: 262144
608
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300609Example for 'mapping' option value:
610
611.. code-block:: yaml
612
613 linux:
614 system:
615 kernel:
616 module:
617 nf_conntrack:
618 option:
619 hashsize:
620 enabled: true
621 value: 262144
622
623NOTE: 'enabled' key is optional and is True by default.
624
625Blacklist a module:
626
627.. code-block:: yaml
628
629 linux:
630 system:
631 kernel:
632 module:
633 nf_conntrack:
634 blacklist: true
635
636A module can have a number of aliases, wildcards are allowed.
637Define an alias for a module:
638
639.. code-block:: yaml
640
641 linux:
642 system:
643 kernel:
644 module:
645 nf_conntrack:
646 alias:
647 nfct:
648 enabled: true
649 "nf_conn*":
650 enabled: true
651
652NOTE: 'enabled' key is mandatory as there are no other keys exist.
653
654Execute custom command instead of 'insmod' when inserting a module:
655
656.. code-block:: yaml
657
658 linux:
659 system:
660 kernel:
661 module:
662 nf_conntrack:
663 install:
664 enabled: true
665 command: /bin/true
666
667NOTE: 'enabled' key is optional and is True by default.
668
669Execute custom command instead of 'rmmod' when removing a module:
670
671.. code-block:: yaml
672
673 linux:
674 system:
675 kernel:
676 module:
677 nf_conntrack:
678 remove:
679 enabled: true
680 command: /bin/true
681
682NOTE: 'enabled' key is optional and is True by default.
683
684Define module dependencies:
685
686.. code-block:: yaml
687
688 linux:
689 system:
690 kernel:
691 module:
692 nf_conntrack:
693 softdep:
694 pre:
695 1:
696 enabled: true
697 value: a
698 2:
699 enabled: true
700 value: b
701 3:
702 enabled: true
703 value: c
704 post:
705 1:
706 enabled: true
707 value: x
708 2:
709 enabled: true
710 value: y
711 3:
712 enabled: true
713 value: z
714
715NOTE: 'enabled' key is optional and is True by default.
716
717
Filip Pytloun281034a2016-01-04 18:06:22 +0100718Install specific kernel version and ensure all other kernel packages are
719not present. Also install extra modules and headers for this kernel:
720
721.. code-block:: yaml
722
723 linux:
724 system:
725 kernel:
726 type: generic
727 extra: true
728 headers: true
729 version: 4.2.0-22
730
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300731Systcl kernel parameters:
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100732
733.. code-block:: yaml
734
735 linux:
736 system:
737 kernel:
738 sysctl:
739 net.ipv4.tcp_keepalive_intvl: 3
740 net.ipv4.tcp_keepalive_time: 30
741 net.ipv4.tcp_keepalive_probes: 8
742
Michael Polenchukebf55522018-01-25 13:22:39 +0400743Configure kernel boot options:
744
745.. code-block:: yaml
746
747 linux:
748 system:
749 kernel:
750 boot_options:
751 - elevator=deadline
752 - spectre_v2=off
753 - nopti
754
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100755CPU
756~~~
757
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300758Enable cpufreq governor for every cpu:
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100759
760.. code-block:: yaml
761
762 linux:
763 system:
764 cpu:
765 governor: performance
766
Nick Metzf04f5f32018-01-08 15:25:04 +0100767
Jiri Broulik303905d2018-01-11 14:12:48 +0100768CGROUPS
769~~~~~~~
770
771Setup linux cgroups:
772
773.. code-block:: yaml
774
775 linux:
776 system:
777 cgroup:
778 enabled: true
779 group:
780 ceph_group_1:
781 controller:
782 cpu:
783 shares:
784 value: 250
785 cpuacct:
786 usage:
787 value: 0
788 cpuset:
789 cpus:
790 value: 1,2,3
791 memory:
792 limit_in_bytes:
793 value: 2G
794 memsw.limit_in_bytes:
795 value: 3G
796 mapping:
797 subjects:
798 - '@ceph'
799 generic_group_1:
800 controller:
801 cpu:
802 shares:
803 value: 250
804 cpuacct:
805 usage:
806 value: 0
807 mapping:
808 subjects:
809 - '*:firefox'
810 - 'student:cp'
811
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300812Shared libraries
Nick Metzf04f5f32018-01-08 15:25:04 +0100813~~~~~~~~~~~~~~~~
814
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300815Set additional shared library to Linux system library path:
Nick Metzf04f5f32018-01-08 15:25:04 +0100816
817.. code-block:: yaml
818
819 linux:
820 system:
821 ld:
822 library:
823 java:
824 - /usr/lib/jvm/jre-openjdk/lib/amd64/server
825 - /opt/java/jre/lib/amd64/server
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200826
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200827Certificates
828~~~~~~~~~~~~
829
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300830Add certificate authority into system trusted CA bundle:
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200831
832.. code-block:: yaml
833
834 linux:
835 system:
836 ca_certificates:
837 mycert: |
838 -----BEGIN CERTIFICATE-----
839 MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
840 A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
841 cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
842 MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
843 BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
844 YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
845 ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
846 BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
847 I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
848 CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
849 lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
850 AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
851 -----END CERTIFICATE-----
852
Filip Pytloun361096c2017-08-23 10:57:20 +0200853Sysfs
854~~~~~
855
856Install sysfsutils and set sysfs attributes:
857
858.. code-block:: yaml
859
860 linux:
861 system:
862 sysfs:
863 scheduler:
864 block/sda/queue/scheduler: deadline
865 power:
866 mode:
867 power/state: 0660
868 owner:
869 power/state: "root:power"
870 devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
871
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200872Optional: You can also use list that will ensure order of items.
873
874.. code-block:: yaml
875
876 linux:
877 system:
878 sysfs:
879 scheduler:
880 block/sda/queue/scheduler: deadline
881 power:
882 - mode:
883 power/state: 0660
884 - owner:
885 power/state: "root:power"
886 - devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
887
Martin Polreich148e1b82018-09-13 15:54:25 +0200888Sysfs definition with disabled automatic write. Attributes are saved
889to configuration, but are not applied during the run.
890Thay will be applied automatically after the reboot.
891
892
893.. code-block:: yaml
894
895 linux:
896 system:
897 sysfs:
898 enable_apply: false
899 scheduler:
900 block/sda/queue/scheduler: deadline
901
902.. note:: The `enable_apply` parameter defaults to `True` if not defined.
903
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100904Huge Pages
905~~~~~~~~~~~~
906
907Huge Pages give a performance boost to applications that intensively deal
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300908with memory allocation/deallocation by decreasing memory fragmentation:
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100909
910.. code-block:: yaml
911
912 linux:
913 system:
914 kernel:
915 hugepages:
916 small:
917 size: 2M
918 count: 107520
919 mount_point: /mnt/hugepages_2MB
Michael Polenchukd9369fe2018-05-08 17:53:08 +0400920 mount: false/true # default is true (mount immediately) / false (just save in the fstab)
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100921 large:
922 default: true # default automatically mounted
923 size: 1G
924 count: 210
925 mount_point: /mnt/hugepages_1GB
926
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300927.. note:: Not recommended to use both pagesizes concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100928
Jakub Pavlik5398d872017-02-13 22:30:47 +0100929Intel SR-IOV
930~~~~~~~~~~~~
931
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300932PCI-SIG Single Root I/O Virtualization and Sharing (SR-IOV)
933specification defines a standardized mechanism to virtualize
934PCIe devices. The mechanism can virtualize a single PCIe
935Ethernet controller to appear as multiple PCIe devices:
Jakub Pavlik5398d872017-02-13 22:30:47 +0100936
937.. code-block:: yaml
938
939 linux:
940 system:
941 kernel:
942 sriov: True
943 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
944 rc:
945 local: |
946 #!/bin/sh -e
947 # Enable 7 VF on eth1
948 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
949 exit 0
950
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100951Isolate CPU options
952~~~~~~~~~~~~~~~~~~~
953
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300954Remove the specified CPUs, as defined by the cpu_number values, from
955the general kernel SMP balancing and scheduler algroithms. The only
956way to move a process onto or off an *isolated* CPU is via the CPU
957affinity syscalls. ``cpu_number begins`` at ``0``, so the
958maximum value is ``1`` less than the number of CPUs on the system.:
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100959
960.. code-block:: yaml
961
962 linux:
963 system:
964 kernel:
965 isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100966
Filip Pytlounf5383a42015-10-06 16:28:32 +0200967Repositories
968~~~~~~~~~~~~
969
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300970RedHat-based Linux with additional OpenStack repo:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200971
972.. code-block:: yaml
973
974 linux:
975 system:
976 ...
977 repo:
978 rdo-icehouse:
979 enabled: true
980 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
981 pgpcheck: 0
982
983Ensure system repository to use czech Debian mirror (``default: true``)
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300984Also pin it's packages with priority ``900``:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200985
986.. code-block:: yaml
987
988 linux:
989 system:
990 repo:
991 debian:
992 default: true
993 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
994 # Import signing key from URL if needed
995 key_url: "http://dummy.com/public.gpg"
996 pin:
997 - pin: 'origin "ftp.cz.debian.org"'
998 priority: 900
999 package: '*'
1000
azvyagintseva3a73d02018-12-06 14:49:58 +02001001Sometimes better to use one pining rule file, to decrease mistaken
1002ordering. You can use those option ``system:apt:preferences``, which would add opts into
1003``/etc/apt/preferences`` file:
1004
1005.. code-block:: yaml
1006
1007 parameters:
1008 linux:
1009 system:
1010 apt:
1011 preferences:
1012 enabled: true
1013 rules:
1014 100:
1015 enabled: true
1016 name: 'some origin pin'
1017 pin: 'release o=Debian'
1018 priority: 1100
1019 package: '*'
1020
1021
azvyagintsev4494a472018-09-14 19:19:23 +03001022If you need to add multiple pin rules for one repo, please use new,ordered definition format
1023('pinning' definition will be in priotity to use):
1024
1025.. code-block:: yaml
1026
1027 linux:
1028 system:
1029 repo:
1030 mcp_saltstack:
1031 source: "deb [arch=amd64] http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/ xenial main"
1032 architectures: amd64
1033 clean_file: true
1034 pinning:
1035 10:
1036 enabled: true
1037 pin: 'release o=SaltStack'
1038 priority: 50
1039 package: 'libsodium18'
1040 20:
1041 enabled: true
1042 pin: 'release o=SaltStack'
1043 priority: 1100
1044 package: '*'
1045
1046
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001047.. note:: For old Ubuntu releases (<xenial)
azvyagintsevff089d22018-07-27 16:52:34 +02001048 extra packages for apt transport, like ``apt-transport-https``
1049 may be required to be installed manually.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001050 (Chicken-eggs issue: we need to install packages to
azvyagintsevff089d22018-07-27 16:52:34 +02001051 reach repo from where they should be installed)
1052 Otherwise, you still can try 'fortune' and install prereq.packages before
1053 any repo configuration, using list of requires in map.jinja.
1054
1055
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001056Disabling any prerequisite packages installation:
1057
azvyagintsevff089d22018-07-27 16:52:34 +02001058You can simply drop any package pre-installation (before system.linux.repo
1059will be processed) via cluster lvl:
1060
1061.. code-block:: yaml
1062
1063 linux:
1064 system:
1065 pkgs: ~
1066
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001067Package manager proxy global setup:
Petr Michalec10462bb2017-03-23 19:18:08 +01001068
1069.. code-block:: yaml
1070
1071 linux:
1072 system:
1073 ...
1074 repo:
1075 apt-mk:
1076 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1077 ...
1078 proxy:
1079 pkg:
1080 enabled: true
1081 ftp: ftp://ftp-proxy-for-apt.host.local:2121
1082 ...
1083 # NOTE: Global defaults for any other componet that configure proxy on the system.
1084 # If your environment has just one simple proxy, set it on linux:system:proxy.
1085 #
1086 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
1087 # as for https and http
1088 ftp: ftp://proxy.host.local:2121
1089 http: http://proxy.host.local:3142
1090 https: https://proxy.host.local:3143
1091
1092Package manager proxy setup per repository:
1093
1094.. code-block:: yaml
1095
1096 linux:
1097 system:
1098 ...
1099 repo:
1100 debian:
1101 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1102 ...
1103 apt-mk:
1104 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1105 # per repository proxy
1106 proxy:
1107 enabled: true
1108 http: http://maas-01:8080
1109 https: http://maas-01:8080
1110 ...
1111 proxy:
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001112 # package manager fallback defaults
Petr Michalec10462bb2017-03-23 19:18:08 +01001113 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
1114 pkg:
1115 enabled: true
1116 ftp: ftp://proxy.host.local:2121
1117 #http: http://proxy.host.local:3142
1118 #https: https://proxy.host.local:3143
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001119 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001120 # global system fallback system defaults
1121 ftp: ftp://proxy.host.local:2121
1122 http: http://proxy.host.local:3142
1123 https: https://proxy.host.local:3143
1124
Ivan Berezovskiycfd58a22019-06-25 20:15:51 +04001125
1126Add secured apt repository:
1127
1128.. code-block:: yaml
1129
1130 linux:
1131 system:
1132 ...
1133 repo:
1134 test:
1135 secure: true
1136 url: example.org/ubuntu
1137 arch: deb
1138 protocol: http
1139 user: foo
1140 password: bar
1141 distribution: stable
1142 component: main
1143
1144Add multiply secured apt repositories with same credentials:
1145
1146.. code-block:: yaml
1147
1148 linux:
1149 system:
1150 ...
1151 common_repo_secured:
1152 arch: deb
1153 protocol: http
1154 user: foo
1155 password: bar
1156 distribution: stable
1157 component: main
1158 repo:
1159 test1:
1160 secure: true
1161 url: example1.org/ubuntu
1162 test2:
1163 secure: true
1164 url: example2.org/ubuntu
1165
Jiri Broulik34a29b42017-04-25 14:42:54 +02001166Remove all repositories:
1167
1168.. code-block:: yaml
1169
1170 linux:
1171 system:
1172 purge_repos: true
1173
azvyagintsevff089d22018-07-27 16:52:34 +02001174Refresh repositories metada, after configuration:
1175
1176.. code-block:: yaml
1177
1178 linux:
1179 system:
1180 refresh_repos_meta: true
1181
Filip Pytlounc512e6c2017-11-22 14:28:10 +01001182Setup custom apt config options:
1183
1184.. code-block:: yaml
1185
1186 linux:
1187 system:
1188 apt:
1189 config:
1190 compression-workaround:
1191 "Acquire::CompressionTypes::Order": "gz"
1192 docker-clean:
1193 "DPkg::Post-Invoke":
1194 - "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"
1195 "APT::Update::Post-Invoke":
1196 - "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 +02001197
Petr Michalec10462bb2017-03-23 19:18:08 +01001198RC
1199~~
1200
Jakub Pavlik78859382016-01-21 11:26:39 +01001201rc.local example
1202
1203.. code-block:: yaml
1204
1205 linux:
1206 system:
1207 rc:
1208 local: |
1209 #!/bin/sh -e
1210 #
1211 # rc.local
1212 #
1213 # This script is executed at the end of each multiuser runlevel.
1214 # Make sure that the script will "exit 0" on success or any other
1215 # value on error.
1216 #
1217 # In order to enable or disable this script just change the execution
1218 # bits.
1219 #
1220 # By default this script does nothing.
1221 exit 0
1222
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001223Prompt
1224~~~~~~
1225
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001226Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``.
1227Every user can have different prompt:
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001228
1229.. code-block:: yaml
1230
1231 linux:
1232 system:
1233 prompt:
1234 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\\]
1235 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
1236
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001237On Debian systems, to set prompt system-wide, it's necessary to
1238remove setting PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc``,
1239which comes from ``/etc/skel/.bashrc``. This formula will do
1240this automatically, but will not touch existing user's
1241``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +01001242
Filip Pytlouneef11c12016-03-25 11:00:23 +01001243Bash
1244~~~~
1245
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001246Fix bash configuration to preserve history across sessions
1247like ZSH does by default:
Filip Pytlouneef11c12016-03-25 11:00:23 +01001248
1249.. code-block:: yaml
1250
1251 linux:
1252 system:
1253 bash:
1254 preserve_history: true
1255
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001256Login banner message
1257~~~~~~~~~~~~~~~~~~~~
1258
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001259``/etc/issue`` is a text file which contains a message or system
1260identification to be printed before the login prompt. It may contain
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001261various @char and \char sequences, if supported by the getty-type
1262program employed on the system.
1263
1264Setting logon banner message is easy:
1265
1266.. code-block:: yaml
1267
1268 liunx:
1269 system:
1270 banner:
1271 enabled: true
1272 contents: |
1273 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1274
1275 You must have explicit, authorized permission to access or configure this
1276 device. Unauthorized attempts and actions to access or use this system may
1277 result in civil and/or criminal penalties.
1278 All activities performed on this system are logged and monitored.
1279
Filip Pytloune874dfb2016-01-22 16:57:34 +01001280Message of the day
1281~~~~~~~~~~~~~~~~~~
1282
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001283``pam_motd`` from package ``libpam-modules`` is used for dynamic
1284messages of the day. Setting custom ``motd`` will clean up existing ones.
Filip Pytloune874dfb2016-01-22 16:57:34 +01001285
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001286Setting static ``motd`` will replace existing ``/etc/motd`` and remove
1287scripts from ``/etc/update-motd.d``.
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001288
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001289Setting static ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001290
1291.. code-block:: yaml
1292
1293 linux:
1294 system:
1295 motd: |
1296 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1297
1298 You must have explicit, authorized permission to access or configure this
1299 device. Unauthorized attempts and actions to access or use this system may
1300 result in civil and/or criminal penalties.
1301 All activities performed on this system are logged and monitored.
1302
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001303Setting dynamic ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001304
Filip Pytloune874dfb2016-01-22 16:57:34 +01001305.. code-block:: yaml
1306
1307 linux:
1308 system:
1309 motd:
1310 - release: |
1311 #!/bin/sh
1312 [ -r /etc/lsb-release ] && . /etc/lsb-release
1313
1314 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
1315 # Fall back to using the very slow lsb_release utility
1316 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
1317 fi
1318
1319 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
1320 - warning: |
1321 #!/bin/sh
1322 printf "This is [company name] network.\n"
1323 printf "Unauthorized access strictly prohibited.\n"
1324
Marek Celoud713e9072017-05-18 15:20:25 +02001325Services
1326~~~~~~~~
1327
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001328Stop and disable the ``linux`` service:
Marek Celoud713e9072017-05-18 15:20:25 +02001329
1330.. code-block:: yaml
1331
1332 linux:
1333 system:
1334 service:
1335 apt-daily.timer:
1336 status: dead
1337
Dzmitry Stremkouski70d09782018-11-30 16:04:59 +01001338Override systemd service unit:
1339
1340.. code-block:: yaml
1341
1342 parameters:
1343
1344 linux:
1345 system:
1346 service:
1347 tgt:
1348 name: tgt
1349 status: running
1350 enabled: True
1351 override:
1352 50:
1353 target: tgt.service.d
1354 name: bind
1355 content: |
1356 [Service]
1357 ExecStart=
1358 ExecStart=/usr/sbin/tgtd -f --iscsi portal=${_param:single_address}:3260
1359
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001360Possible statuses are ``dead`` (disable service by default), ``running``
1361(enable service by default), ``enabled``, ``disabled``:
Marek Celoud713e9072017-05-18 15:20:25 +02001362
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001363Linux with the ``atop`` service:
Serhiy Ovsianikov67bd56a2017-08-11 15:56:01 +03001364
1365.. code-block:: yaml
1366
1367 linux:
1368 system:
1369 atop:
1370 enabled: true
1371 interval: 20
1372 logpath: "/var/log/atop"
1373 outfile: "/var/log/atop/daily.log"
1374
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001375Linux with the ``mcelog`` service:
Oleksii Chupryn144432b2018-05-22 10:34:48 +03001376
1377.. code-block:: yaml
1378
1379 linux:
1380 system:
1381 mcelog:
1382 enabled: true
1383 logging:
1384 syslog: true
1385 syslog_error: true
1386
Filip Pytloun2f70b492016-02-19 15:55:25 +01001387RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +01001388^^^^^^^^^^^^^
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001389Currently, ``update-motd`` is not available
1390for RHEL. So there is no native support for dynamic ``motd``.
1391You can still set a static one, with a different pillar structure:
Filip Pytloun2f70b492016-02-19 15:55:25 +01001392
1393.. code-block:: yaml
1394
1395 linux:
1396 system:
1397 motd: |
1398 This is [company name] network.
1399 Unauthorized access strictly prohibited.
1400
Filip Pytloun8296bb92016-02-19 18:42:09 +01001401Haveged
1402~~~~~~~
1403
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001404If you are running headless server and are low on entropy,
1405you may set up Haveged:
Filip Pytloun8296bb92016-02-19 18:42:09 +01001406
1407.. code-block:: yaml
1408
1409 linux:
1410 system:
1411 haveged:
1412 enabled: true
1413
Filip Pytlounf5383a42015-10-06 16:28:32 +02001414Linux network
1415-------------
1416
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001417Linux with network manager:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001418
1419.. code-block:: yaml
1420
1421 linux:
1422 network:
1423 enabled: true
1424 network_manager: true
1425
Dzmitry Stremkouski00cdbe62018-10-31 16:41:54 +01001426Execute linux.network.interface state without ifupdown activity:
1427
1428.. code-block:: bash
1429
1430 salt-call linux.network.interface pillar='{"linux":{"network":{"noifupdown":True}}}'
1431
1432
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001433Linux with default static network interfaces, default gateway
1434interface and DNS servers:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001435
1436.. code-block:: yaml
1437
1438 linux:
1439 network:
1440 enabled: true
1441 interface:
1442 eth0:
1443 enabled: true
1444 type: eth
1445 address: 192.168.0.102
1446 netmask: 255.255.255.0
1447 gateway: 192.168.0.1
1448 name_servers:
1449 - 8.8.8.8
1450 - 8.8.4.4
1451 mtu: 1500
1452
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001453Linux with bonded interfaces and disabled ``NetworkManager``:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001454
1455.. code-block:: yaml
1456
1457 linux:
1458 network:
1459 enabled: true
1460 interface:
1461 eth0:
1462 type: eth
1463 ...
1464 eth1:
1465 type: eth
1466 ...
1467 bond0:
1468 enabled: true
1469 type: bond
1470 address: 192.168.0.102
1471 netmask: 255.255.255.0
1472 mtu: 1500
1473 use_in:
1474 - interface: ${linux:interface:eth0}
1475 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +01001476 network_manager:
1477 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001478
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001479Linux with VLAN ``interface_params``:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001480
1481.. code-block:: yaml
1482
1483 linux:
1484 network:
1485 enabled: true
1486 interface:
1487 vlan69:
1488 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +01001489 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001490 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001491
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001492Linux with wireless interface parameters:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001493
1494.. code-block:: yaml
1495
1496 linux:
1497 network:
1498 enabled: true
1499 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001500 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001501 interface:
1502 wlan0:
1503 type: eth
1504 wireless:
1505 essid: example
1506 key: example_key
1507 security: wpa
1508 priority: 1
1509
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001510Linux networks with routes defined:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001511
1512.. code-block:: yaml
1513
1514 linux:
1515 network:
1516 enabled: true
1517 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001518 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001519 interface:
1520 eth0:
1521 type: eth
1522 route:
1523 default:
1524 address: 192.168.0.123
1525 netmask: 255.255.255.0
1526 gateway: 192.168.0.1
1527
ivce5011da2019-01-23 07:56:53 +03001528Linux networks with implicit routes definition:
1529
1530- on node 1:
1531
1532.. code-block:: yaml
1533
1534 linux:
1535 network:
1536 enabled: true
1537 router:
1538 ctl:
1539 # router that connects 10.0.1.0/24 and 10.0.2.0/24
1540 addresses:
1541 - 10.0.1.1/24
1542 - 10.0.2.1/24
1543 test:
1544 addresses:
1545 - 10.0.1.2/24
1546 networks:
1547 - 10.100.0.0/16
1548 interface:
1549 ctl:
1550 name: eth0
1551 address: 10.0.1.101
1552 netmask: 255.255.255.0
1553
1554- on node2:
1555
1556.. code-block:: yaml
1557
1558 linux:
1559 network:
1560 enabled: true
1561 router:
1562 ctl:
1563 # equivalent of node1's ctl router with 'implicit_routes = false'
1564 options:
1565 implicit_routes: false
1566 addresses:
1567 - 10.0.1.1/24
1568 - 10.0.2.1/24
1569 networks:
1570 - 10.0.1.0/24
1571 - 10.0.2.0/24
1572 interface:
1573 ctl:
1574 name: eth0
1575 address: 10.0.2.101
1576 netmask: 255.255.255.0
1577
1578
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001579Native Linux Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001580
1581.. code-block:: yaml
1582
1583 linux:
1584 network:
1585 interface:
1586 eth1:
1587 enabled: true
1588 type: eth
1589 proto: manual
1590 up_cmds:
1591 - ip address add 0/0 dev $IFACE
1592 - ip link set $IFACE up
1593 down_cmds:
1594 - ip link set $IFACE down
1595 br-ex:
1596 enabled: true
1597 type: bridge
1598 address: ${linux:network:host:public_local:address}
1599 netmask: 255.255.255.0
1600 use_interfaces:
1601 - eth1
1602
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001603Open vSwitch Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001604
1605.. code-block:: yaml
1606
1607 linux:
1608 network:
1609 bridge: openvswitch
1610 interface:
1611 eth1:
1612 enabled: true
1613 type: eth
1614 proto: manual
1615 up_cmds:
1616 - ip address add 0/0 dev $IFACE
1617 - ip link set $IFACE up
1618 down_cmds:
1619 - ip link set $IFACE down
1620 br-ex:
1621 enabled: true
1622 type: bridge
1623 address: ${linux:network:host:public_local:address}
1624 netmask: 255.255.255.0
1625 use_interfaces:
1626 - eth1
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001627 br-prv:
1628 enabled: true
1629 type: ovs_bridge
1630 mtu: 65000
1631 br-ens7:
1632 enabled: true
1633 name: br-ens7
1634 type: ovs_bridge
1635 proto: manual
1636 mtu: 9000
1637 use_interfaces:
1638 - ens7
1639 patch-br-ens7-br-prv:
1640 enabled: true
1641 name: ens7-prv
1642 ovs_type: ovs_port
1643 type: ovs_port
1644 bridge: br-ens7
1645 port_type: patch
1646 peer: prv-ens7
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001647 tag: 109 # [] to unset a tag
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001648 mtu: 65000
1649 patch-br-prv-br-ens7:
1650 enabled: true
1651 name: prv-ens7
1652 bridge: br-prv
1653 ovs_type: ovs_port
1654 type: ovs_port
1655 port_type: patch
1656 peer: ens7-prv
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001657 tag: 109
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001658 mtu: 65000
1659 ens7:
1660 enabled: true
1661 name: ens7
1662 proto: manual
1663 ovs_port_type: OVSPort
1664 type: ovs_port
1665 ovs_bridge: br-ens7
1666 bridge: br-ens7
Filip Pytlounf5383a42015-10-06 16:28:32 +02001667
Petr Jediný8f8ae542017-07-13 16:19:12 +02001668Debian manual proto interfaces
1669
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001670When you are changing interface proto from static in up state
1671to manual, you may need to flush ip addresses. For example,
1672if you want to use the interface and the ip on the bridge.
1673This can be done by setting the ``ipflush_onchange`` to true.
Petr Jediný8f8ae542017-07-13 16:19:12 +02001674
1675.. code-block:: yaml
1676
1677 linux:
1678 network:
1679 interface:
1680 eth1:
1681 enabled: true
1682 type: eth
1683 proto: manual
1684 mtu: 9100
1685 ipflush_onchange: true
1686
Jiri Broulik1a191e32018-01-15 15:54:21 +01001687Debian static proto interfaces
1688
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001689When you are changing interface proto from dhcp in up state to
1690static, you may need to flush ip addresses and restart interface
1691to assign ip address from a managed file. For example, if you wantto
1692use the interface and the ip on the bridge. This can be done by
1693setting the ``ipflush_onchange`` with combination ``restart_on_ipflush``
1694param set to true.
Jiri Broulik1a191e32018-01-15 15:54:21 +01001695
1696.. code-block:: yaml
1697
1698 linux:
1699 network:
1700 interface:
1701 eth1:
1702 enabled: true
1703 type: eth
1704 proto: static
1705 address: 10.1.0.22
1706 netmask: 255.255.255.0
1707 ipflush_onchange: true
1708 restart_on_ipflush: true
Petr Jediný8f8ae542017-07-13 16:19:12 +02001709
Petr Jedinýd577cb52017-06-28 20:17:49 +02001710Concatinating and removing interface files
1711
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001712Debian based distributions have ``/etc/network/interfaces.d/``
1713directory, where you can store configuration of network
1714interfaces in separate files. You can concatinate the files
1715to the defined destination when needed, this operation removes
1716the file from the ``/etc/network/interfaces.d/``. If you just need
1717to remove iface files, you can use the ``remove_iface_files`` key.
Petr Jedinýd577cb52017-06-28 20:17:49 +02001718
1719.. code-block:: yaml
1720
1721 linux:
1722 network:
1723 concat_iface_files:
1724 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
1725 dst: '/etc/network/interfaces'
1726 remove_iface_files:
1727 - '/etc/network/interfaces.d/90-custom.cfg'
1728
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001729Configure DHCP client
Petr Jedinýd577cb52017-06-28 20:17:49 +02001730
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001731None of the keys is mandatory, include only those you really need.
1732For full list of available options under send, supersede, prepend,
1733append refer to dhcp-options(5).
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001734
1735.. code-block:: yaml
1736
1737 linux:
1738 network:
1739 dhclient:
1740 enabled: true
1741 backoff_cutoff: 15
1742 initial_interval: 10
1743 reboot: 10
1744 retry: 60
1745 select_timeout: 0
1746 timeout: 120
1747 send:
1748 - option: host-name
1749 declaration: "= gethostname()"
1750 supersede:
1751 - option: host-name
1752 declaration: "spaceship"
1753 - option: domain-name
1754 declaration: "domain.home"
1755 #- option: arp-cache-timeout
1756 # declaration: 20
1757 prepend:
1758 - option: domain-name-servers
1759 declaration:
1760 - 8.8.8.8
1761 - 8.8.4.4
1762 - option: domain-search
1763 declaration:
1764 - example.com
1765 - eng.example.com
1766 #append:
1767 #- option: domain-name-servers
1768 # declaration: 127.0.0.1
1769 # ip or subnet to reject dhcp offer from
1770 reject:
1771 - 192.33.137.209
1772 - 10.0.2.0/24
1773 request:
1774 - subnet-mask
1775 - broadcast-address
1776 - time-offset
1777 - routers
1778 - domain-name
1779 - domain-name-servers
1780 - domain-search
1781 - host-name
1782 - dhcp6.name-servers
1783 - dhcp6.domain-search
1784 - dhcp6.fqdn
1785 - dhcp6.sntp-servers
1786 - netbios-name-servers
1787 - netbios-scope
1788 - interface-mtu
1789 - rfc3442-classless-static-routes
1790 - ntp-servers
1791 require:
1792 - subnet-mask
1793 - domain-name-servers
1794 # if per interface configuration required add below
1795 interface:
1796 ens2:
1797 initial_interval: 11
1798 reject:
1799 - 192.33.137.210
1800 ens3:
1801 initial_interval: 12
1802 reject:
1803 - 192.33.137.211
1804
Petr Michaleceb14b552017-06-01 10:27:05 +02001805Linux network systemd settings:
1806
1807.. code-block:: yaml
1808
1809 linux:
1810 network:
1811 ...
1812 systemd:
1813 link:
1814 10-iface-dmz:
1815 Match:
1816 MACAddress: c8:5b:67:fa:1a:af
1817 OriginalName: eth0
1818 Link:
1819 Name: dmz0
1820 netdev:
1821 20-bridge-dmz:
1822 match:
1823 name: dmz0
1824 network:
1825 mescription: bridge
1826 bridge: br-dmz0
1827 network:
1828 # works with lowercase, keys are by default capitalized
1829 40-dhcp:
1830 match:
1831 name: '*'
1832 network:
1833 DHCP: yes
1834
Petr Michalec10462bb2017-03-23 19:18:08 +01001835Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +01001836
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001837Use ``/etc/environment`` for static system wide variable assignment
1838after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001839
1840.. code-block:: yaml
1841
1842 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +01001843 system:
1844 env:
1845 BOB_VARIABLE: Alice
1846 ...
1847 BOB_PATH:
1848 - /srv/alice/bin
1849 - /srv/bob/bin
1850 ...
1851 ftp_proxy: none
1852 http_proxy: http://global-http-proxy.host.local:8080
1853 https_proxy: ${linux:system:proxy:https}
1854 no_proxy:
1855 - 192.168.0.80
1856 - 192.168.1.80
1857 - .domain.com
1858 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001859 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001860 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001861 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001862 ftp: ftp://proxy.host.local:2121
1863 http: http://proxy.host.local:3142
1864 https: https://proxy.host.local:3143
1865 noproxy:
1866 - .domain.com
1867 - .local
1868
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001869Configure the ``profile.d`` scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001870
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001871The ``profile.d`` scripts are being sourced during ``.sh`` execution
1872and support variable expansion in opposite to /etc/environment global
1873settings in ``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001874
1875.. code-block:: yaml
1876
1877 linux:
1878 system:
1879 profile:
1880 locales: |
1881 export LANG=C
1882 export LC_ALL=C
1883 ...
1884 vi_flavors.sh: |
1885 export PAGER=view
1886 export EDITOR=vim
1887 alias vi=vim
1888 shell_locales.sh: |
1889 export LANG=en_US
1890 export LC_ALL=en_US.UTF-8
1891 shell_proxies.sh: |
1892 export FTP_PROXY=ftp://127.0.3.3:2121
1893 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001894
Dmitry Teselkina0d31d12018-09-04 14:43:09 +03001895
1896Configure login.defs parameters
1897-------------------------------
1898
1899.. code-block:: yaml
1900
1901 linux:
1902 system:
1903 login_defs:
1904 <opt_name>:
1905 enabled: true
1906 value: <opt_value>
1907
1908<opt_name> is a configurational option defined in 'man login.defs'.
1909<opt_name> is case sensitive, should be UPPERCASE only!
1910
1911
Filip Pytlounf5383a42015-10-06 16:28:32 +02001912Linux with hosts
1913
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001914Parameter ``purge_hosts`` will enforce whole ``/etc/hosts file``,
1915removing entries that are not defined in model except defaults
1916for both IPv4 and IPv6 localhost and hostname as well as FQDN.
Ales Komarek417e8c52017-08-25 15:10:29 +02001917
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001918We recommend using this option to verify that ``/etc/hosts``
1919is always in a clean state. However it is not enabled by default
1920for security reasons.
Filip Pytloun86506fe2017-01-26 14:36:16 +01001921
Filip Pytlounf5383a42015-10-06 16:28:32 +02001922.. code-block:: yaml
1923
1924 linux:
1925 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001926 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001927 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001928 # No need to define this one if purge_hosts is true
1929 hostname:
1930 address: 127.0.1.1
1931 names:
1932 - ${linux:network:fqdn}
1933 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001934 node1:
1935 address: 192.168.10.200
1936 names:
1937 - node2.domain.com
1938 - service2.domain.com
1939 node2:
1940 address: 192.168.10.201
1941 names:
1942 - node2.domain.com
1943 - service2.domain.com
1944
Ales Komarek417e8c52017-08-25 15:10:29 +02001945Linux with hosts collected from mine
1946
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001947All DNS records defined within infrastrucuture
1948are passed to the local hosts records or any DNS server. Only
1949hosts with the ``grain`` parameter set to ``true`` will be propagated
1950to the mine.
Ales Komarek417e8c52017-08-25 15:10:29 +02001951
1952.. code-block:: yaml
1953
1954 linux:
1955 network:
1956 purge_hosts: true
1957 mine_dns_records: true
1958 host:
1959 node1:
1960 address: 192.168.10.200
1961 grain: true
1962 names:
1963 - node2.domain.com
1964 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01001965
Michael Polenchukc80ddd42019-01-15 18:47:48 +04001966Set up ``resolvconf's basic resolver info``, e.g. nameservers, search/domain and options:
Filip Pytlounde9bea52016-01-11 15:39:10 +01001967
1968.. code-block:: yaml
1969
1970 linux:
1971 network:
1972 resolv:
1973 dns:
Michael Polenchukc80ddd42019-01-15 18:47:48 +04001974 - 8.8.4.4
1975 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01001976 domain: my.example.com
1977 search:
Michael Polenchukc80ddd42019-01-15 18:47:48 +04001978 - my.example.com
1979 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01001980 options:
Michael Polenchukc80ddd42019-01-15 18:47:48 +04001981 - ndots:5
1982 - timeout:2
1983 - attempts:2
Filip Pytlounde9bea52016-01-11 15:39:10 +01001984
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001985Set up custom TX queue length for tap interfaces:
Andrii Petrenko735761d2017-03-21 17:17:35 -07001986
1987.. code-block:: yaml
1988
1989 linux:
1990 network:
1991 tap_custom_txqueuelen: 10000
1992
Michael Polenchukc37bd4a2019-04-22 15:20:03 +04001993Auto repair/re-attach libvirt's vnet interfaces:
1994
1995.. code-block:: yaml
1996
1997 linux:
1998 network:
1999 libvirt_vnet_repair: true
2000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002001DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002002
2003**DPDK OVS NIC**
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 dpkd0:
2020 name: ${_param:dpdk_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 enabled: true
2024 type: dpdk_ovs_port
2025 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002026 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002027 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01002028 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002029 br-prv:
2030 enabled: true
2031 type: dpdk_ovs_bridge
2032
2033**DPDK OVS Bond**
2034
2035.. code-block:: yaml
2036
2037 linux:
2038 network:
2039 bridge: openvswitch
2040 dpdk:
2041 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04002042 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002043 openvswitch:
2044 pmd_cpu_mask: "0x6"
2045 dpdk_socket_mem: "1024,1024"
2046 dpdk_lcore_mask: "0x400"
2047 memory_channels: 2
2048 interface:
2049 dpdk_second_nic:
2050 name: ${_param:primary_second_nic}
2051 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002052 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002053 bond: dpdkbond0
2054 enabled: true
2055 type: dpdk_ovs_port
2056 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002057 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002058 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002059 dpdk_first_nic:
2060 name: ${_param:primary_first_nic}
2061 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002062 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002063 bond: dpdkbond0
2064 enabled: true
2065 type: dpdk_ovs_port
2066 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002067 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002068 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002069 dpdkbond0:
2070 enabled: true
2071 bridge: br-prv
2072 type: dpdk_ovs_bond
2073 mode: active-backup
2074 br-prv:
2075 enabled: true
2076 type: dpdk_ovs_bridge
2077
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01002078**DPDK OVS LACP Bond with vlan tag**
2079
2080.. code-block:: yaml
2081
2082 linux:
2083 network:
2084 bridge: openvswitch
2085 dpdk:
2086 enabled: true
2087 driver: uio
2088 openvswitch:
2089 pmd_cpu_mask: "0x6"
2090 dpdk_socket_mem: "1024,1024"
2091 dpdk_lcore_mask: "0x400"
2092 memory_channels: "2"
2093 interface:
2094 eth3:
2095 enabled: true
2096 type: eth
2097 proto: manual
2098 name: ${_param:tenant_first_nic}
2099 eth4:
2100 enabled: true
2101 type: eth
2102 proto: manual
2103 name: ${_param:tenant_second_nic}
2104 dpdk0:
2105 name: ${_param:tenant_first_nic}
2106 pci: "0000:81:00.0"
2107 driver: igb_uio
2108 bond: bond1
2109 enabled: true
2110 type: dpdk_ovs_port
2111 n_rxq: 2
2112 dpdk1:
2113 name: ${_param:tenant_second_nic}
2114 pci: "0000:81:00.1"
2115 driver: igb_uio
2116 bond: bond1
2117 enabled: true
2118 type: dpdk_ovs_port
2119 n_rxq: 2
2120 bond1:
2121 enabled: true
2122 bridge: br-prv
2123 type: dpdk_ovs_bond
2124 mode: balance-slb
2125 br-prv:
2126 enabled: true
2127 type: dpdk_ovs_bridge
2128 tag: ${_param:tenant_vlan}
2129 address: ${_param:tenant_address}
2130 netmask: ${_param:tenant_network_netmask}
2131
Jakub Pavlikaa759062017-03-13 15:57:26 +01002132**DPDK OVS bridge for VXLAN**
2133
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002134If VXLAN is used as tenant segmentation, IP address must
2135be set on ``br-prv``.
Jakub Pavlikaa759062017-03-13 15:57:26 +01002136
2137.. code-block:: yaml
2138
2139 linux:
2140 network:
2141 ...
2142 interface:
2143 br-prv:
2144 enabled: true
2145 type: dpdk_ovs_bridge
2146 address: 192.168.50.0
2147 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04002148 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01002149 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002150
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02002151**DPDK OVS bridge with Linux network interface**
2152
2153.. code-block:: yaml
2154
2155 linux:
2156 network:
2157 ...
2158 interface:
2159 eth0:
2160 type: eth
2161 ovs_bridge: br-prv
2162 ...
2163 br-prv:
2164 enabled: true
2165 type: dpdk_ovs_bridge
2166 ...
2167
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002168Linux storage
2169-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02002170
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002171Linux with mounted Samba:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002172
2173.. code-block:: yaml
2174
2175 linux:
2176 storage:
2177 enabled: true
2178 mount:
2179 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01002180 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02002181 - path: /media/myuser/public/
2182 - device: //192.168.0.1/storage
2183 - file_system: cifs
2184 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
2185
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002186NFS mount:
Jiri Broulikb017f932017-03-31 13:55:36 +02002187
2188.. code-block:: yaml
2189
2190 linux:
2191 storage:
2192 enabled: true
2193 mount:
2194 nfs_glance:
2195 enabled: true
2196 path: /var/lib/glance/images
2197 device: 172.16.10.110:/var/nfs/glance
2198 file_system: nfs
2199 opts: rw,sync
2200
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002201File swap configuration:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002202
2203.. code-block:: yaml
2204
2205 linux:
2206 storage:
2207 enabled: true
2208 swap:
2209 file:
2210 enabled: true
2211 engine: file
2212 device: /swapfile
2213 size: 1024
2214
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002215Partition swap configuration:
Lachlan Evenson30676512016-01-22 15:43:28 -08002216
2217.. code-block:: yaml
2218
2219 linux:
2220 storage:
2221 enabled: true
2222 swap:
2223 partition:
2224 enabled: true
2225 engine: partition
2226 device: /dev/vg0/swap
2227
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002228LVM group ``vg1`` with one device and ``data`` volume mounted
2229into ``/mnt/data``.
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002230
2231.. code-block:: yaml
2232
2233 parameters:
2234 linux:
2235 storage:
2236 mount:
2237 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01002238 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002239 device: /dev/vg1/data
2240 file_system: ext4
2241 path: /mnt/data
2242 lvm:
2243 vg1:
2244 enabled: true
2245 devices:
2246 - /dev/sdb
2247 volume:
2248 data:
2249 size: 40G
2250 mount: ${linux:storage:mount:data}
root3387f332019-01-11 08:55:32 +00002251 # When set they will take precedence over filters aget from volume groups.
2252 lvm_filters:
2253 10:
2254 enabled: True
2255 value: "a|loop|"
2256 20:
2257 enabled: True
2258 value: "r|/dev/hdc|"
2259 30:
2260 enabled: True
2261 value: "a|/dev/ide|"
2262 40:
2263 enabled: True
2264 value: "r|.*|"
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002265
Jakub Pavlik4f742142017-08-08 15:05:50 +02002266Create partitions on disk. Specify size in MB. It expects empty
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002267disk without any existing partitions.
2268Set ``startsector=1`` if you want to start partitions from ``2048``.
Jakub Pavlik4f742142017-08-08 15:05:50 +02002269
2270.. code-block:: yaml
2271
2272 linux:
2273 storage:
2274 disk:
2275 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01002276 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02002277 name: /dev/loop1
2278 type: gpt
2279 partitions:
2280 - size: 200 #size in MB
2281 type: fat32
2282 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02002283 mkfs: True
2284 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02002285 /dev/vda1:
2286 partitions:
2287 - size: 5
2288 type: ext2
2289 - size: 10
2290 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02002291
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002292Multipath with Fujitsu Eternus DXL:
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 - fujitsu_eternus_dxl
2306
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002307Multipath with Hitachi VSP 1000:
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 backends:
2320 - hitachi_vsp1000
2321
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002322Multipath with IBM Storwize:
Ales Komareka634f4b2016-10-02 13:11:04 +02002323
2324.. code-block:: yaml
2325
2326 parameters:
2327 linux:
2328 storage:
2329 multipath:
2330 enabled: true
2331 blacklist_devices:
2332 - /dev/sda
2333 - /dev/sdb
2334 backends:
2335 - ibm_storwize
2336
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002337Multipath with multiple backends:
Ales Komareka634f4b2016-10-02 13:11:04 +02002338
2339.. code-block:: yaml
2340
2341 parameters:
2342 linux:
2343 storage:
2344 multipath:
2345 enabled: true
2346 blacklist_devices:
2347 - /dev/sda
2348 - /dev/sdb
2349 - /dev/sdc
2350 - /dev/sdd
2351 backends:
2352 - ibm_storwize
2353 - fujitsu_eternus_dxl
2354 - hitachi_vsp1000
2355
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002356PAM LDAP integration:
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002357
2358.. code-block:: yaml
2359
2360 parameters:
2361 linux:
2362 system:
2363 auth:
2364 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02002365 mkhomedir:
2366 enabled: true
2367 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002368 ldap:
2369 enabled: true
2370 binddn: cn=bind,ou=service_users,dc=example,dc=com
2371 bindpw: secret
2372 uri: ldap://127.0.0.1
2373 base: ou=users,dc=example,dc=com
2374 ldap_version: 3
2375 pagesize: 65536
2376 referrals: off
2377 filter:
2378 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2379 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2380 group: (&(objectClass=group)(gidNumber=*))
2381
Gleb Galkin93b9ae92018-10-18 13:57:30 +03002382PAM duo 2FA integration
2383
2384.. code-block:: yaml
2385
2386 parameters:
2387 linux:
2388 system:
2389 auth:
2390 enabled: true
2391 duo:
2392 enabled: true
2393 duo_host: localhost
2394 duo_ikey: DUO-INTEGRATION-KEY
2395 duo_skey: DUO-SECRET-KEY
2396
2397duo package version may be specified (optional)
2398
2399.. code-block:: yaml
2400
2401 linux:
2402 system:
2403 package:
2404 duo-unix:
2405 version: 1.10.1-0
2406
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002407Disabled multipath (the default setup):
Ales Komareka634f4b2016-10-02 13:11:04 +02002408
2409.. code-block:: yaml
2410
2411 parameters:
2412 linux:
2413 storage:
2414 multipath:
2415 enabled: false
2416
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002417Linux with local loopback device:
Simon Pasquier375001e2017-01-26 13:22:33 +01002418
2419.. code-block:: yaml
2420
2421 linux:
2422 storage:
2423 loopback:
2424 disk1:
2425 file: /srv/disk1
2426 size: 50G
2427
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002428External config generation
2429--------------------------
2430
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002431You are able to use config support metadata between formulas
2432and only generate configuration files for external use, for example, Docker, and so on.
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002433
2434.. code-block:: yaml
2435
2436 parameters:
2437 linux:
2438 system:
2439 config:
2440 pillar:
2441 jenkins:
2442 master:
2443 home: /srv/volumes/jenkins
2444 approved_scripts:
2445 - method java.net.URL openConnection
2446 credentials:
2447 - type: username_password
2448 scope: global
2449 id: test
2450 desc: Testing credentials
2451 username: test
2452 password: test
2453
Vladimir Ereminccf28842017-04-10 23:52:10 +03002454Netconsole Remote Kernel Logging
2455--------------------------------
2456
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002457Netconsole logger can be configured for the configfs-enabled kernels
2458(``CONFIG_NETCONSOLE_DYNAMIC`` must be enabled). The configuration
2459applies both in runtime (if network is already configured),
2460and on-boot after an interface initialization.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002461
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002462.. note::
2463
2464 * Receiver can be located only on the same L3 domain
2465 (or you need to configure gateway MAC manually).
2466 * The Receiver MAC is detected only on configuration time.
2467 * Using broadcast MAC is not recommended.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002468
2469.. code-block:: yaml
2470
2471 parameters:
2472 linux:
2473 system:
2474 netconsole:
2475 enabled: true
2476 port: 514 (optional)
2477 loglevel: debug (optional)
2478 target:
2479 192.168.0.1:
2480 interface: bond0
2481 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02002482
Dzmitry Stremkouskid1a268b2018-10-03 16:36:04 +02002483Check network params on the environment
2484---------------------------------------
2485
2486Grab nics and nics states
2487
2488.. code-block:: bash
2489
2490 salt osd001\* net_checks.get_nics
2491
2492**Example of system output:**
2493
2494.. code-block:: bash
2495
2496 osd001.domain.com:
2497 |_
2498 - bond0
2499 - None
2500 - 1e:c8:64:42:23:b9
2501 - 0
2502 - 1500
2503 |_
2504 - bond1
2505 - None
2506 - 3c:fd:fe:27:3b:00
2507 - 1
2508 - 9100
2509 |_
2510 - fourty1
2511 - None
2512 - 3c:fd:fe:27:3b:00
2513 - 1
2514 - 9100
2515 |_
2516 - fourty2
2517 - None
2518 - 3c:fd:fe:27:3b:02
2519 - 1
2520 - 9100
2521
2522Grab 10G nics PCI addresses for hugepages setup
2523
2524.. code-block:: bash
2525
2526 salt cmp001\* net_checks.get_ten_pci
2527
2528**Example of system output:**
2529
2530.. code-block:: bash
2531
2532 cmp001.domain.com:
2533 |_
2534 - ten1
2535 - 0000:19:00.0
2536 |_
2537 - ten2
2538 - 0000:19:00.1
2539 |_
2540 - ten3
2541 - 0000:19:00.2
2542 |_
2543 - ten4
2544 - 0000:19:00.3
2545
2546Grab ip address for an interface
2547
2548.. code-block:: bash
2549
2550 salt cmp001\* net_checks.get_ip iface=one4
2551
2552**Example of system output:**
2553
2554.. code-block:: bash
2555
2556 cmp001.domain.com:
2557 10.200.177.101
2558
2559Grab ip addresses map
2560
2561.. code-block:: bash
2562
2563 salt-call net_checks.nodes_addresses
2564
2565**Example of system output:**
2566
2567.. code-block:: bash
2568
2569 local:
2570 |_
2571 - cid01.domain.com
2572 |_
2573 |_
2574 - pxe
2575 - 10.200.177.91
2576 |_
2577 - control
2578 - 10.200.178.91
2579 |_
2580 - cmn02.domain.com
2581 |_
2582 |_
2583 - storage_access
2584 - 10.200.181.67
2585 |_
2586 - pxe
2587 - 10.200.177.67
2588 |_
2589 - control
2590 - 10.200.178.67
2591 |_
2592 - cmp010.domain.com
2593 |_
2594 |_
2595 - pxe
2596 - 10.200.177.110
2597 |_
2598 - storage_access
2599 - 10.200.181.110
2600 |_
2601 - control
2602 - 10.200.178.110
2603 |_
2604 - vxlan
2605 - 10.200.179.110
2606
2607Verify full mesh connectivity
2608
2609.. code-block:: bash
2610
2611 salt-call net_checks.ping_check
2612
2613**Example of positive system output:**
2614
2615.. code-block:: bash
2616
2617 ['PASSED']
2618 [INFO ] ['PASSED']
2619 local:
2620 True
2621
2622**Example of system output in case of failure:**
2623
2624.. code-block:: bash
2625
2626 FAILED
2627 [ERROR ] FAILED
2628 ['control: 10.0.1.92 -> 10.0.1.224: Failed']
2629 ['control: 10.0.1.93 -> 10.0.1.224: Failed']
2630 ['control: 10.0.1.51 -> 10.0.1.224: Failed']
2631 ['control: 10.0.1.102 -> 10.0.1.224: Failed']
2632 ['control: 10.0.1.13 -> 10.0.1.224: Failed']
2633 ['control: 10.0.1.81 -> 10.0.1.224: Failed']
2634 local:
2635 False
2636
2637For this feature to work, please mark addresses with some role.
2638Otherwise 'default' role is assumed and mesh would consist of all
2639addresses on the environment.
2640
2641Mesh mark is needed only for interfaces which are enabled and have
2642ip address assigned.
2643
2644Checking dhcp pxe network meaningless, as it is used for salt
2645master vs minion communications, therefore treated as checked.
2646
2647.. code-block:: yaml
2648
2649 parameters:
2650 linux:
2651 network:
2652 interface:
2653 ens3:
2654 enabled: true
2655 type: eth
2656 proto: static
2657 address: ${_param:deploy_address}
2658 netmask: ${_param:deploy_network_netmask}
2659 gateway: ${_param:deploy_network_gateway}
2660 mesh: pxe
2661
2662Check pillars for ip address duplicates
2663
2664.. code-block:: bash
2665
2666 salt-call net_checks.verify_addresses
2667
2668**Example of positive system output:**
2669
2670.. code-block:: bash
2671
2672 ['PASSED']
2673 [INFO ] ['PASSED']
2674 local:
2675 True
2676
2677**Example of system output in case of failure:**
2678
2679.. code-block:: bash
2680
2681 FAILED. Duplicates found
2682 [ERROR ] FAILED. Duplicates found
2683 ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2684 [ERROR ] ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2685 local:
2686 False
2687
2688Generate csv report for the env
2689
2690.. code-block:: bash
2691
2692 salt -C 'kvm* or cmp* or osd*' net_checks.get_nics_csv \
2693 | grep '^\ ' | sed 's/\ *//g' | grep -Ev ^server \
2694 | sed '1 i\server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr'
2695
2696**Example of system output:**
2697
2698.. code-block:: bash
2699
2700 server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr
2701 cmp010.domain.com,bond0,None,b4:96:91:10:5b:3a,1,1500,,,,
2702 cmp010.domain.com,bond0.21,10.200.178.110,b4:96:91:10:5b:3a,1,1500,,,,
2703 cmp010.domain.com,bond0.22,10.200.179.110,b4:96:91:10:5b:3a,1,1500,,,,
2704 cmp010.domain.com,bond1,None,3c:fd:fe:34:ad:22,0,1500,,,,
2705 cmp010.domain.com,bond1.24,10.200.181.110,3c:fd:fe:34:ad:22,0,1500,,,,
2706 cmp010.domain.com,fourty5,None,3c:fd:fe:34:ad:20,0,9000,,,,
2707 cmp010.domain.com,fourty6,None,3c:fd:fe:34:ad:22,0,9000,,,,
2708 cmp010.domain.com,one1,None,b4:96:91:10:5b:38,0,1500,,,,
2709 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
2710 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
2711 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
2712 cmp011.domain.com,bond0,None,b4:96:91:13:6c:aa,1,1500,,,,
2713 cmp011.domain.com,bond0.21,10.200.178.111,b4:96:91:13:6c:aa,1,1500,,,,
2714 cmp011.domain.com,bond0.22,10.200.179.111,b4:96:91:13:6c:aa,1,1500,,,,
2715 ...
2716
Filip Pytlounf5383a42015-10-06 16:28:32 +02002717Usage
2718=====
2719
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002720Set MTU of the eth0 network interface to 1400:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002721
2722.. code-block:: bash
2723
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002724 ip link set dev eth0 mtu 1400
Filip Pytlounf5383a42015-10-06 16:28:32 +02002725
2726Read more
2727=========
2728
2729* https://www.archlinux.org/
2730* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu