blob: 2bfd2c624ad60b8997d633de268ef0735c0ef046 [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
Jiri Broulik34a29b42017-04-25 14:42:54 +02001125Remove all repositories:
1126
1127.. code-block:: yaml
1128
1129 linux:
1130 system:
1131 purge_repos: true
1132
azvyagintsevff089d22018-07-27 16:52:34 +02001133Refresh repositories metada, after configuration:
1134
1135.. code-block:: yaml
1136
1137 linux:
1138 system:
1139 refresh_repos_meta: true
1140
Filip Pytlounc512e6c2017-11-22 14:28:10 +01001141Setup custom apt config options:
1142
1143.. code-block:: yaml
1144
1145 linux:
1146 system:
1147 apt:
1148 config:
1149 compression-workaround:
1150 "Acquire::CompressionTypes::Order": "gz"
1151 docker-clean:
1152 "DPkg::Post-Invoke":
1153 - "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"
1154 "APT::Update::Post-Invoke":
1155 - "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 +02001156
Petr Michalec10462bb2017-03-23 19:18:08 +01001157RC
1158~~
1159
Jakub Pavlik78859382016-01-21 11:26:39 +01001160rc.local example
1161
1162.. code-block:: yaml
1163
1164 linux:
1165 system:
1166 rc:
1167 local: |
1168 #!/bin/sh -e
1169 #
1170 # rc.local
1171 #
1172 # This script is executed at the end of each multiuser runlevel.
1173 # Make sure that the script will "exit 0" on success or any other
1174 # value on error.
1175 #
1176 # In order to enable or disable this script just change the execution
1177 # bits.
1178 #
1179 # By default this script does nothing.
1180 exit 0
1181
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001182Prompt
1183~~~~~~
1184
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001185Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``.
1186Every user can have different prompt:
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001187
1188.. code-block:: yaml
1189
1190 linux:
1191 system:
1192 prompt:
1193 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\\]
1194 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
1195
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001196On Debian systems, to set prompt system-wide, it's necessary to
1197remove setting PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc``,
1198which comes from ``/etc/skel/.bashrc``. This formula will do
1199this automatically, but will not touch existing user's
1200``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +01001201
Filip Pytlouneef11c12016-03-25 11:00:23 +01001202Bash
1203~~~~
1204
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001205Fix bash configuration to preserve history across sessions
1206like ZSH does by default:
Filip Pytlouneef11c12016-03-25 11:00:23 +01001207
1208.. code-block:: yaml
1209
1210 linux:
1211 system:
1212 bash:
1213 preserve_history: true
1214
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001215Login banner message
1216~~~~~~~~~~~~~~~~~~~~
1217
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001218``/etc/issue`` is a text file which contains a message or system
1219identification to be printed before the login prompt. It may contain
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001220various @char and \char sequences, if supported by the getty-type
1221program employed on the system.
1222
1223Setting logon banner message is easy:
1224
1225.. code-block:: yaml
1226
1227 liunx:
1228 system:
1229 banner:
1230 enabled: true
1231 contents: |
1232 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1233
1234 You must have explicit, authorized permission to access or configure this
1235 device. Unauthorized attempts and actions to access or use this system may
1236 result in civil and/or criminal penalties.
1237 All activities performed on this system are logged and monitored.
1238
Filip Pytloune874dfb2016-01-22 16:57:34 +01001239Message of the day
1240~~~~~~~~~~~~~~~~~~
1241
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001242``pam_motd`` from package ``libpam-modules`` is used for dynamic
1243messages of the day. Setting custom ``motd`` will clean up existing ones.
Filip Pytloune874dfb2016-01-22 16:57:34 +01001244
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001245Setting static ``motd`` will replace existing ``/etc/motd`` and remove
1246scripts from ``/etc/update-motd.d``.
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001247
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001248Setting static ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001249
1250.. code-block:: yaml
1251
1252 linux:
1253 system:
1254 motd: |
1255 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1256
1257 You must have explicit, authorized permission to access or configure this
1258 device. Unauthorized attempts and actions to access or use this system may
1259 result in civil and/or criminal penalties.
1260 All activities performed on this system are logged and monitored.
1261
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001262Setting dynamic ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001263
Filip Pytloune874dfb2016-01-22 16:57:34 +01001264.. code-block:: yaml
1265
1266 linux:
1267 system:
1268 motd:
1269 - release: |
1270 #!/bin/sh
1271 [ -r /etc/lsb-release ] && . /etc/lsb-release
1272
1273 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
1274 # Fall back to using the very slow lsb_release utility
1275 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
1276 fi
1277
1278 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
1279 - warning: |
1280 #!/bin/sh
1281 printf "This is [company name] network.\n"
1282 printf "Unauthorized access strictly prohibited.\n"
1283
Marek Celoud713e9072017-05-18 15:20:25 +02001284Services
1285~~~~~~~~
1286
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001287Stop and disable the ``linux`` service:
Marek Celoud713e9072017-05-18 15:20:25 +02001288
1289.. code-block:: yaml
1290
1291 linux:
1292 system:
1293 service:
1294 apt-daily.timer:
1295 status: dead
1296
Dzmitry Stremkouski70d09782018-11-30 16:04:59 +01001297Override systemd service unit:
1298
1299.. code-block:: yaml
1300
1301 parameters:
1302
1303 linux:
1304 system:
1305 service:
1306 tgt:
1307 name: tgt
1308 status: running
1309 enabled: True
1310 override:
1311 50:
1312 target: tgt.service.d
1313 name: bind
1314 content: |
1315 [Service]
1316 ExecStart=
1317 ExecStart=/usr/sbin/tgtd -f --iscsi portal=${_param:single_address}:3260
1318
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001319Possible statuses are ``dead`` (disable service by default), ``running``
1320(enable service by default), ``enabled``, ``disabled``:
Marek Celoud713e9072017-05-18 15:20:25 +02001321
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001322Linux with the ``atop`` service:
Serhiy Ovsianikov67bd56a2017-08-11 15:56:01 +03001323
1324.. code-block:: yaml
1325
1326 linux:
1327 system:
1328 atop:
1329 enabled: true
1330 interval: 20
1331 logpath: "/var/log/atop"
1332 outfile: "/var/log/atop/daily.log"
1333
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001334Linux with the ``mcelog`` service:
Oleksii Chupryn144432b2018-05-22 10:34:48 +03001335
1336.. code-block:: yaml
1337
1338 linux:
1339 system:
1340 mcelog:
1341 enabled: true
1342 logging:
1343 syslog: true
1344 syslog_error: true
1345
Filip Pytloun2f70b492016-02-19 15:55:25 +01001346RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +01001347^^^^^^^^^^^^^
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001348Currently, ``update-motd`` is not available
1349for RHEL. So there is no native support for dynamic ``motd``.
1350You can still set a static one, with a different pillar structure:
Filip Pytloun2f70b492016-02-19 15:55:25 +01001351
1352.. code-block:: yaml
1353
1354 linux:
1355 system:
1356 motd: |
1357 This is [company name] network.
1358 Unauthorized access strictly prohibited.
1359
Filip Pytloun8296bb92016-02-19 18:42:09 +01001360Haveged
1361~~~~~~~
1362
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001363If you are running headless server and are low on entropy,
1364you may set up Haveged:
Filip Pytloun8296bb92016-02-19 18:42:09 +01001365
1366.. code-block:: yaml
1367
1368 linux:
1369 system:
1370 haveged:
1371 enabled: true
1372
Filip Pytlounf5383a42015-10-06 16:28:32 +02001373Linux network
1374-------------
1375
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001376Linux with network manager:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001377
1378.. code-block:: yaml
1379
1380 linux:
1381 network:
1382 enabled: true
1383 network_manager: true
1384
Dzmitry Stremkouski00cdbe62018-10-31 16:41:54 +01001385Execute linux.network.interface state without ifupdown activity:
1386
1387.. code-block:: bash
1388
1389 salt-call linux.network.interface pillar='{"linux":{"network":{"noifupdown":True}}}'
1390
1391
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001392Linux with default static network interfaces, default gateway
1393interface and DNS servers:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001394
1395.. code-block:: yaml
1396
1397 linux:
1398 network:
1399 enabled: true
1400 interface:
1401 eth0:
1402 enabled: true
1403 type: eth
1404 address: 192.168.0.102
1405 netmask: 255.255.255.0
1406 gateway: 192.168.0.1
1407 name_servers:
1408 - 8.8.8.8
1409 - 8.8.4.4
1410 mtu: 1500
1411
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001412Linux with bonded interfaces and disabled ``NetworkManager``:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001413
1414.. code-block:: yaml
1415
1416 linux:
1417 network:
1418 enabled: true
1419 interface:
1420 eth0:
1421 type: eth
1422 ...
1423 eth1:
1424 type: eth
1425 ...
1426 bond0:
1427 enabled: true
1428 type: bond
1429 address: 192.168.0.102
1430 netmask: 255.255.255.0
1431 mtu: 1500
1432 use_in:
1433 - interface: ${linux:interface:eth0}
1434 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +01001435 network_manager:
1436 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001437
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001438Linux with VLAN ``interface_params``:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001439
1440.. code-block:: yaml
1441
1442 linux:
1443 network:
1444 enabled: true
1445 interface:
1446 vlan69:
1447 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +01001448 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001449 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001450
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001451Linux with wireless interface parameters:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001452
1453.. code-block:: yaml
1454
1455 linux:
1456 network:
1457 enabled: true
1458 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001459 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001460 interface:
1461 wlan0:
1462 type: eth
1463 wireless:
1464 essid: example
1465 key: example_key
1466 security: wpa
1467 priority: 1
1468
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001469Linux networks with routes defined:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001470
1471.. code-block:: yaml
1472
1473 linux:
1474 network:
1475 enabled: true
1476 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001477 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001478 interface:
1479 eth0:
1480 type: eth
1481 route:
1482 default:
1483 address: 192.168.0.123
1484 netmask: 255.255.255.0
1485 gateway: 192.168.0.1
1486
ivce5011da2019-01-23 07:56:53 +03001487Linux networks with implicit routes definition:
1488
1489- on node 1:
1490
1491.. code-block:: yaml
1492
1493 linux:
1494 network:
1495 enabled: true
1496 router:
1497 ctl:
1498 # router that connects 10.0.1.0/24 and 10.0.2.0/24
1499 addresses:
1500 - 10.0.1.1/24
1501 - 10.0.2.1/24
1502 test:
1503 addresses:
1504 - 10.0.1.2/24
1505 networks:
1506 - 10.100.0.0/16
1507 interface:
1508 ctl:
1509 name: eth0
1510 address: 10.0.1.101
1511 netmask: 255.255.255.0
1512
1513- on node2:
1514
1515.. code-block:: yaml
1516
1517 linux:
1518 network:
1519 enabled: true
1520 router:
1521 ctl:
1522 # equivalent of node1's ctl router with 'implicit_routes = false'
1523 options:
1524 implicit_routes: false
1525 addresses:
1526 - 10.0.1.1/24
1527 - 10.0.2.1/24
1528 networks:
1529 - 10.0.1.0/24
1530 - 10.0.2.0/24
1531 interface:
1532 ctl:
1533 name: eth0
1534 address: 10.0.2.101
1535 netmask: 255.255.255.0
1536
1537
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001538Native Linux Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001539
1540.. code-block:: yaml
1541
1542 linux:
1543 network:
1544 interface:
1545 eth1:
1546 enabled: true
1547 type: eth
1548 proto: manual
1549 up_cmds:
1550 - ip address add 0/0 dev $IFACE
1551 - ip link set $IFACE up
1552 down_cmds:
1553 - ip link set $IFACE down
1554 br-ex:
1555 enabled: true
1556 type: bridge
1557 address: ${linux:network:host:public_local:address}
1558 netmask: 255.255.255.0
1559 use_interfaces:
1560 - eth1
1561
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001562Open vSwitch Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001563
1564.. code-block:: yaml
1565
1566 linux:
1567 network:
1568 bridge: openvswitch
1569 interface:
1570 eth1:
1571 enabled: true
1572 type: eth
1573 proto: manual
1574 up_cmds:
1575 - ip address add 0/0 dev $IFACE
1576 - ip link set $IFACE up
1577 down_cmds:
1578 - ip link set $IFACE down
1579 br-ex:
1580 enabled: true
1581 type: bridge
1582 address: ${linux:network:host:public_local:address}
1583 netmask: 255.255.255.0
1584 use_interfaces:
1585 - eth1
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001586 br-prv:
1587 enabled: true
1588 type: ovs_bridge
1589 mtu: 65000
1590 br-ens7:
1591 enabled: true
1592 name: br-ens7
1593 type: ovs_bridge
1594 proto: manual
1595 mtu: 9000
1596 use_interfaces:
1597 - ens7
1598 patch-br-ens7-br-prv:
1599 enabled: true
1600 name: ens7-prv
1601 ovs_type: ovs_port
1602 type: ovs_port
1603 bridge: br-ens7
1604 port_type: patch
1605 peer: prv-ens7
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001606 tag: 109 # [] to unset a tag
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001607 mtu: 65000
1608 patch-br-prv-br-ens7:
1609 enabled: true
1610 name: prv-ens7
1611 bridge: br-prv
1612 ovs_type: ovs_port
1613 type: ovs_port
1614 port_type: patch
1615 peer: ens7-prv
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001616 tag: 109
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001617 mtu: 65000
1618 ens7:
1619 enabled: true
1620 name: ens7
1621 proto: manual
1622 ovs_port_type: OVSPort
1623 type: ovs_port
1624 ovs_bridge: br-ens7
1625 bridge: br-ens7
Filip Pytlounf5383a42015-10-06 16:28:32 +02001626
Petr Jediný8f8ae542017-07-13 16:19:12 +02001627Debian manual proto interfaces
1628
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001629When you are changing interface proto from static in up state
1630to manual, you may need to flush ip addresses. For example,
1631if you want to use the interface and the ip on the bridge.
1632This can be done by setting the ``ipflush_onchange`` to true.
Petr Jediný8f8ae542017-07-13 16:19:12 +02001633
1634.. code-block:: yaml
1635
1636 linux:
1637 network:
1638 interface:
1639 eth1:
1640 enabled: true
1641 type: eth
1642 proto: manual
1643 mtu: 9100
1644 ipflush_onchange: true
1645
Jiri Broulik1a191e32018-01-15 15:54:21 +01001646Debian static proto interfaces
1647
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001648When you are changing interface proto from dhcp in up state to
1649static, you may need to flush ip addresses and restart interface
1650to assign ip address from a managed file. For example, if you wantto
1651use the interface and the ip on the bridge. This can be done by
1652setting the ``ipflush_onchange`` with combination ``restart_on_ipflush``
1653param set to true.
Jiri Broulik1a191e32018-01-15 15:54:21 +01001654
1655.. code-block:: yaml
1656
1657 linux:
1658 network:
1659 interface:
1660 eth1:
1661 enabled: true
1662 type: eth
1663 proto: static
1664 address: 10.1.0.22
1665 netmask: 255.255.255.0
1666 ipflush_onchange: true
1667 restart_on_ipflush: true
Petr Jediný8f8ae542017-07-13 16:19:12 +02001668
Petr Jedinýd577cb52017-06-28 20:17:49 +02001669Concatinating and removing interface files
1670
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001671Debian based distributions have ``/etc/network/interfaces.d/``
1672directory, where you can store configuration of network
1673interfaces in separate files. You can concatinate the files
1674to the defined destination when needed, this operation removes
1675the file from the ``/etc/network/interfaces.d/``. If you just need
1676to remove iface files, you can use the ``remove_iface_files`` key.
Petr Jedinýd577cb52017-06-28 20:17:49 +02001677
1678.. code-block:: yaml
1679
1680 linux:
1681 network:
1682 concat_iface_files:
1683 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
1684 dst: '/etc/network/interfaces'
1685 remove_iface_files:
1686 - '/etc/network/interfaces.d/90-custom.cfg'
1687
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001688Configure DHCP client
Petr Jedinýd577cb52017-06-28 20:17:49 +02001689
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001690None of the keys is mandatory, include only those you really need.
1691For full list of available options under send, supersede, prepend,
1692append refer to dhcp-options(5).
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001693
1694.. code-block:: yaml
1695
1696 linux:
1697 network:
1698 dhclient:
1699 enabled: true
1700 backoff_cutoff: 15
1701 initial_interval: 10
1702 reboot: 10
1703 retry: 60
1704 select_timeout: 0
1705 timeout: 120
1706 send:
1707 - option: host-name
1708 declaration: "= gethostname()"
1709 supersede:
1710 - option: host-name
1711 declaration: "spaceship"
1712 - option: domain-name
1713 declaration: "domain.home"
1714 #- option: arp-cache-timeout
1715 # declaration: 20
1716 prepend:
1717 - option: domain-name-servers
1718 declaration:
1719 - 8.8.8.8
1720 - 8.8.4.4
1721 - option: domain-search
1722 declaration:
1723 - example.com
1724 - eng.example.com
1725 #append:
1726 #- option: domain-name-servers
1727 # declaration: 127.0.0.1
1728 # ip or subnet to reject dhcp offer from
1729 reject:
1730 - 192.33.137.209
1731 - 10.0.2.0/24
1732 request:
1733 - subnet-mask
1734 - broadcast-address
1735 - time-offset
1736 - routers
1737 - domain-name
1738 - domain-name-servers
1739 - domain-search
1740 - host-name
1741 - dhcp6.name-servers
1742 - dhcp6.domain-search
1743 - dhcp6.fqdn
1744 - dhcp6.sntp-servers
1745 - netbios-name-servers
1746 - netbios-scope
1747 - interface-mtu
1748 - rfc3442-classless-static-routes
1749 - ntp-servers
1750 require:
1751 - subnet-mask
1752 - domain-name-servers
1753 # if per interface configuration required add below
1754 interface:
1755 ens2:
1756 initial_interval: 11
1757 reject:
1758 - 192.33.137.210
1759 ens3:
1760 initial_interval: 12
1761 reject:
1762 - 192.33.137.211
1763
Petr Michaleceb14b552017-06-01 10:27:05 +02001764Linux network systemd settings:
1765
1766.. code-block:: yaml
1767
1768 linux:
1769 network:
1770 ...
1771 systemd:
1772 link:
1773 10-iface-dmz:
1774 Match:
1775 MACAddress: c8:5b:67:fa:1a:af
1776 OriginalName: eth0
1777 Link:
1778 Name: dmz0
1779 netdev:
1780 20-bridge-dmz:
1781 match:
1782 name: dmz0
1783 network:
1784 mescription: bridge
1785 bridge: br-dmz0
1786 network:
1787 # works with lowercase, keys are by default capitalized
1788 40-dhcp:
1789 match:
1790 name: '*'
1791 network:
1792 DHCP: yes
1793
Petr Michalec10462bb2017-03-23 19:18:08 +01001794Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +01001795
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001796Use ``/etc/environment`` for static system wide variable assignment
1797after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001798
1799.. code-block:: yaml
1800
1801 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +01001802 system:
1803 env:
1804 BOB_VARIABLE: Alice
1805 ...
1806 BOB_PATH:
1807 - /srv/alice/bin
1808 - /srv/bob/bin
1809 ...
1810 ftp_proxy: none
1811 http_proxy: http://global-http-proxy.host.local:8080
1812 https_proxy: ${linux:system:proxy:https}
1813 no_proxy:
1814 - 192.168.0.80
1815 - 192.168.1.80
1816 - .domain.com
1817 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001818 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001819 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001820 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001821 ftp: ftp://proxy.host.local:2121
1822 http: http://proxy.host.local:3142
1823 https: https://proxy.host.local:3143
1824 noproxy:
1825 - .domain.com
1826 - .local
1827
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001828Configure the ``profile.d`` scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001829
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001830The ``profile.d`` scripts are being sourced during ``.sh`` execution
1831and support variable expansion in opposite to /etc/environment global
1832settings in ``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001833
1834.. code-block:: yaml
1835
1836 linux:
1837 system:
1838 profile:
1839 locales: |
1840 export LANG=C
1841 export LC_ALL=C
1842 ...
1843 vi_flavors.sh: |
1844 export PAGER=view
1845 export EDITOR=vim
1846 alias vi=vim
1847 shell_locales.sh: |
1848 export LANG=en_US
1849 export LC_ALL=en_US.UTF-8
1850 shell_proxies.sh: |
1851 export FTP_PROXY=ftp://127.0.3.3:2121
1852 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001853
Dmitry Teselkina0d31d12018-09-04 14:43:09 +03001854
1855Configure login.defs parameters
1856-------------------------------
1857
1858.. code-block:: yaml
1859
1860 linux:
1861 system:
1862 login_defs:
1863 <opt_name>:
1864 enabled: true
1865 value: <opt_value>
1866
1867<opt_name> is a configurational option defined in 'man login.defs'.
1868<opt_name> is case sensitive, should be UPPERCASE only!
1869
1870
Filip Pytlounf5383a42015-10-06 16:28:32 +02001871Linux with hosts
1872
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001873Parameter ``purge_hosts`` will enforce whole ``/etc/hosts file``,
1874removing entries that are not defined in model except defaults
1875for both IPv4 and IPv6 localhost and hostname as well as FQDN.
Ales Komarek417e8c52017-08-25 15:10:29 +02001876
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001877We recommend using this option to verify that ``/etc/hosts``
1878is always in a clean state. However it is not enabled by default
1879for security reasons.
Filip Pytloun86506fe2017-01-26 14:36:16 +01001880
Filip Pytlounf5383a42015-10-06 16:28:32 +02001881.. code-block:: yaml
1882
1883 linux:
1884 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001885 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001886 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001887 # No need to define this one if purge_hosts is true
1888 hostname:
1889 address: 127.0.1.1
1890 names:
1891 - ${linux:network:fqdn}
1892 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001893 node1:
1894 address: 192.168.10.200
1895 names:
1896 - node2.domain.com
1897 - service2.domain.com
1898 node2:
1899 address: 192.168.10.201
1900 names:
1901 - node2.domain.com
1902 - service2.domain.com
1903
Ales Komarek417e8c52017-08-25 15:10:29 +02001904Linux with hosts collected from mine
1905
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001906All DNS records defined within infrastrucuture
1907are passed to the local hosts records or any DNS server. Only
1908hosts with the ``grain`` parameter set to ``true`` will be propagated
1909to the mine.
Ales Komarek417e8c52017-08-25 15:10:29 +02001910
1911.. code-block:: yaml
1912
1913 linux:
1914 network:
1915 purge_hosts: true
1916 mine_dns_records: true
1917 host:
1918 node1:
1919 address: 192.168.10.200
1920 grain: true
1921 names:
1922 - node2.domain.com
1923 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01001924
Michael Polenchukc80ddd42019-01-15 18:47:48 +04001925Set up ``resolvconf's basic resolver info``, e.g. nameservers, search/domain and options:
Filip Pytlounde9bea52016-01-11 15:39:10 +01001926
1927.. code-block:: yaml
1928
1929 linux:
1930 network:
1931 resolv:
1932 dns:
Michael Polenchukc80ddd42019-01-15 18:47:48 +04001933 - 8.8.4.4
1934 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01001935 domain: my.example.com
1936 search:
Michael Polenchukc80ddd42019-01-15 18:47:48 +04001937 - my.example.com
1938 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01001939 options:
Michael Polenchukc80ddd42019-01-15 18:47:48 +04001940 - ndots:5
1941 - timeout:2
1942 - attempts:2
Filip Pytlounde9bea52016-01-11 15:39:10 +01001943
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001944Set up custom TX queue length for tap interfaces:
Andrii Petrenko735761d2017-03-21 17:17:35 -07001945
1946.. code-block:: yaml
1947
1948 linux:
1949 network:
1950 tap_custom_txqueuelen: 10000
1951
Michael Polenchukc37bd4a2019-04-22 15:20:03 +04001952Auto repair/re-attach libvirt's vnet interfaces:
1953
1954.. code-block:: yaml
1955
1956 linux:
1957 network:
1958 libvirt_vnet_repair: true
1959
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001960DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001961
1962**DPDK OVS NIC**
1963
1964.. code-block:: yaml
1965
1966 linux:
1967 network:
1968 bridge: openvswitch
1969 dpdk:
1970 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001971 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001972 openvswitch:
1973 pmd_cpu_mask: "0x6"
1974 dpdk_socket_mem: "1024,1024"
1975 dpdk_lcore_mask: "0x400"
1976 memory_channels: 2
1977 interface:
1978 dpkd0:
1979 name: ${_param:dpdk_nic}
1980 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001981 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001982 enabled: true
1983 type: dpdk_ovs_port
1984 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001985 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001986 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01001987 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001988 br-prv:
1989 enabled: true
1990 type: dpdk_ovs_bridge
1991
1992**DPDK OVS Bond**
1993
1994.. code-block:: yaml
1995
1996 linux:
1997 network:
1998 bridge: openvswitch
1999 dpdk:
2000 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04002001 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002002 openvswitch:
2003 pmd_cpu_mask: "0x6"
2004 dpdk_socket_mem: "1024,1024"
2005 dpdk_lcore_mask: "0x400"
2006 memory_channels: 2
2007 interface:
2008 dpdk_second_nic:
2009 name: ${_param:primary_second_nic}
2010 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002011 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002012 bond: dpdkbond0
2013 enabled: true
2014 type: dpdk_ovs_port
2015 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04002016 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01002017 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002018 dpdk_first_nic:
2019 name: ${_param:primary_first_nic}
2020 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04002021 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002022 bond: dpdkbond0
2023 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 Pavlikaa759062017-03-13 15:57:26 +01002027 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002028 dpdkbond0:
2029 enabled: true
2030 bridge: br-prv
2031 type: dpdk_ovs_bond
2032 mode: active-backup
2033 br-prv:
2034 enabled: true
2035 type: dpdk_ovs_bridge
2036
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01002037**DPDK OVS LACP Bond with vlan tag**
2038
2039.. code-block:: yaml
2040
2041 linux:
2042 network:
2043 bridge: openvswitch
2044 dpdk:
2045 enabled: true
2046 driver: uio
2047 openvswitch:
2048 pmd_cpu_mask: "0x6"
2049 dpdk_socket_mem: "1024,1024"
2050 dpdk_lcore_mask: "0x400"
2051 memory_channels: "2"
2052 interface:
2053 eth3:
2054 enabled: true
2055 type: eth
2056 proto: manual
2057 name: ${_param:tenant_first_nic}
2058 eth4:
2059 enabled: true
2060 type: eth
2061 proto: manual
2062 name: ${_param:tenant_second_nic}
2063 dpdk0:
2064 name: ${_param:tenant_first_nic}
2065 pci: "0000:81:00.0"
2066 driver: igb_uio
2067 bond: bond1
2068 enabled: true
2069 type: dpdk_ovs_port
2070 n_rxq: 2
2071 dpdk1:
2072 name: ${_param:tenant_second_nic}
2073 pci: "0000:81:00.1"
2074 driver: igb_uio
2075 bond: bond1
2076 enabled: true
2077 type: dpdk_ovs_port
2078 n_rxq: 2
2079 bond1:
2080 enabled: true
2081 bridge: br-prv
2082 type: dpdk_ovs_bond
2083 mode: balance-slb
2084 br-prv:
2085 enabled: true
2086 type: dpdk_ovs_bridge
2087 tag: ${_param:tenant_vlan}
2088 address: ${_param:tenant_address}
2089 netmask: ${_param:tenant_network_netmask}
2090
Jakub Pavlikaa759062017-03-13 15:57:26 +01002091**DPDK OVS bridge for VXLAN**
2092
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002093If VXLAN is used as tenant segmentation, IP address must
2094be set on ``br-prv``.
Jakub Pavlikaa759062017-03-13 15:57:26 +01002095
2096.. code-block:: yaml
2097
2098 linux:
2099 network:
2100 ...
2101 interface:
2102 br-prv:
2103 enabled: true
2104 type: dpdk_ovs_bridge
2105 address: 192.168.50.0
2106 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04002107 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01002108 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002109
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02002110**DPDK OVS bridge with Linux network interface**
2111
2112.. code-block:: yaml
2113
2114 linux:
2115 network:
2116 ...
2117 interface:
2118 eth0:
2119 type: eth
2120 ovs_bridge: br-prv
2121 ...
2122 br-prv:
2123 enabled: true
2124 type: dpdk_ovs_bridge
2125 ...
2126
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002127Linux storage
2128-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02002129
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002130Linux with mounted Samba:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002131
2132.. code-block:: yaml
2133
2134 linux:
2135 storage:
2136 enabled: true
2137 mount:
2138 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01002139 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02002140 - path: /media/myuser/public/
2141 - device: //192.168.0.1/storage
2142 - file_system: cifs
2143 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
2144
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002145NFS mount:
Jiri Broulikb017f932017-03-31 13:55:36 +02002146
2147.. code-block:: yaml
2148
2149 linux:
2150 storage:
2151 enabled: true
2152 mount:
2153 nfs_glance:
2154 enabled: true
2155 path: /var/lib/glance/images
2156 device: 172.16.10.110:/var/nfs/glance
2157 file_system: nfs
2158 opts: rw,sync
2159
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002160File swap configuration:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002161
2162.. code-block:: yaml
2163
2164 linux:
2165 storage:
2166 enabled: true
2167 swap:
2168 file:
2169 enabled: true
2170 engine: file
2171 device: /swapfile
2172 size: 1024
2173
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002174Partition swap configuration:
Lachlan Evenson30676512016-01-22 15:43:28 -08002175
2176.. code-block:: yaml
2177
2178 linux:
2179 storage:
2180 enabled: true
2181 swap:
2182 partition:
2183 enabled: true
2184 engine: partition
2185 device: /dev/vg0/swap
2186
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002187LVM group ``vg1`` with one device and ``data`` volume mounted
2188into ``/mnt/data``.
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002189
2190.. code-block:: yaml
2191
2192 parameters:
2193 linux:
2194 storage:
2195 mount:
2196 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01002197 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002198 device: /dev/vg1/data
2199 file_system: ext4
2200 path: /mnt/data
2201 lvm:
2202 vg1:
2203 enabled: true
2204 devices:
2205 - /dev/sdb
2206 volume:
2207 data:
2208 size: 40G
2209 mount: ${linux:storage:mount:data}
root3387f332019-01-11 08:55:32 +00002210 # When set they will take precedence over filters aget from volume groups.
2211 lvm_filters:
2212 10:
2213 enabled: True
2214 value: "a|loop|"
2215 20:
2216 enabled: True
2217 value: "r|/dev/hdc|"
2218 30:
2219 enabled: True
2220 value: "a|/dev/ide|"
2221 40:
2222 enabled: True
2223 value: "r|.*|"
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002224
Jakub Pavlik4f742142017-08-08 15:05:50 +02002225Create partitions on disk. Specify size in MB. It expects empty
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002226disk without any existing partitions.
2227Set ``startsector=1`` if you want to start partitions from ``2048``.
Jakub Pavlik4f742142017-08-08 15:05:50 +02002228
2229.. code-block:: yaml
2230
2231 linux:
2232 storage:
2233 disk:
2234 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01002235 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02002236 name: /dev/loop1
2237 type: gpt
2238 partitions:
2239 - size: 200 #size in MB
2240 type: fat32
2241 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02002242 mkfs: True
2243 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02002244 /dev/vda1:
2245 partitions:
2246 - size: 5
2247 type: ext2
2248 - size: 10
2249 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02002250
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002251Multipath with Fujitsu Eternus DXL:
Ales Komareka634f4b2016-10-02 13:11:04 +02002252
2253.. code-block:: yaml
2254
2255 parameters:
2256 linux:
2257 storage:
2258 multipath:
2259 enabled: true
2260 blacklist_devices:
2261 - /dev/sda
2262 - /dev/sdb
2263 backends:
2264 - fujitsu_eternus_dxl
2265
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002266Multipath with Hitachi VSP 1000:
Ales Komareka634f4b2016-10-02 13:11:04 +02002267
2268.. code-block:: yaml
2269
2270 parameters:
2271 linux:
2272 storage:
2273 multipath:
2274 enabled: true
2275 blacklist_devices:
2276 - /dev/sda
2277 - /dev/sdb
2278 backends:
2279 - hitachi_vsp1000
2280
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002281Multipath with IBM Storwize:
Ales Komareka634f4b2016-10-02 13:11:04 +02002282
2283.. code-block:: yaml
2284
2285 parameters:
2286 linux:
2287 storage:
2288 multipath:
2289 enabled: true
2290 blacklist_devices:
2291 - /dev/sda
2292 - /dev/sdb
2293 backends:
2294 - ibm_storwize
2295
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002296Multipath with multiple backends:
Ales Komareka634f4b2016-10-02 13:11:04 +02002297
2298.. code-block:: yaml
2299
2300 parameters:
2301 linux:
2302 storage:
2303 multipath:
2304 enabled: true
2305 blacklist_devices:
2306 - /dev/sda
2307 - /dev/sdb
2308 - /dev/sdc
2309 - /dev/sdd
2310 backends:
2311 - ibm_storwize
2312 - fujitsu_eternus_dxl
2313 - hitachi_vsp1000
2314
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002315PAM LDAP integration:
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002316
2317.. code-block:: yaml
2318
2319 parameters:
2320 linux:
2321 system:
2322 auth:
2323 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02002324 mkhomedir:
2325 enabled: true
2326 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002327 ldap:
2328 enabled: true
2329 binddn: cn=bind,ou=service_users,dc=example,dc=com
2330 bindpw: secret
2331 uri: ldap://127.0.0.1
2332 base: ou=users,dc=example,dc=com
2333 ldap_version: 3
2334 pagesize: 65536
2335 referrals: off
2336 filter:
2337 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2338 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2339 group: (&(objectClass=group)(gidNumber=*))
2340
Gleb Galkin93b9ae92018-10-18 13:57:30 +03002341PAM duo 2FA integration
2342
2343.. code-block:: yaml
2344
2345 parameters:
2346 linux:
2347 system:
2348 auth:
2349 enabled: true
2350 duo:
2351 enabled: true
2352 duo_host: localhost
2353 duo_ikey: DUO-INTEGRATION-KEY
2354 duo_skey: DUO-SECRET-KEY
2355
2356duo package version may be specified (optional)
2357
2358.. code-block:: yaml
2359
2360 linux:
2361 system:
2362 package:
2363 duo-unix:
2364 version: 1.10.1-0
2365
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002366Disabled multipath (the default setup):
Ales Komareka634f4b2016-10-02 13:11:04 +02002367
2368.. code-block:: yaml
2369
2370 parameters:
2371 linux:
2372 storage:
2373 multipath:
2374 enabled: false
2375
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002376Linux with local loopback device:
Simon Pasquier375001e2017-01-26 13:22:33 +01002377
2378.. code-block:: yaml
2379
2380 linux:
2381 storage:
2382 loopback:
2383 disk1:
2384 file: /srv/disk1
2385 size: 50G
2386
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002387External config generation
2388--------------------------
2389
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002390You are able to use config support metadata between formulas
2391and only generate configuration files for external use, for example, Docker, and so on.
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002392
2393.. code-block:: yaml
2394
2395 parameters:
2396 linux:
2397 system:
2398 config:
2399 pillar:
2400 jenkins:
2401 master:
2402 home: /srv/volumes/jenkins
2403 approved_scripts:
2404 - method java.net.URL openConnection
2405 credentials:
2406 - type: username_password
2407 scope: global
2408 id: test
2409 desc: Testing credentials
2410 username: test
2411 password: test
2412
Vladimir Ereminccf28842017-04-10 23:52:10 +03002413Netconsole Remote Kernel Logging
2414--------------------------------
2415
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002416Netconsole logger can be configured for the configfs-enabled kernels
2417(``CONFIG_NETCONSOLE_DYNAMIC`` must be enabled). The configuration
2418applies both in runtime (if network is already configured),
2419and on-boot after an interface initialization.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002420
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002421.. note::
2422
2423 * Receiver can be located only on the same L3 domain
2424 (or you need to configure gateway MAC manually).
2425 * The Receiver MAC is detected only on configuration time.
2426 * Using broadcast MAC is not recommended.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002427
2428.. code-block:: yaml
2429
2430 parameters:
2431 linux:
2432 system:
2433 netconsole:
2434 enabled: true
2435 port: 514 (optional)
2436 loglevel: debug (optional)
2437 target:
2438 192.168.0.1:
2439 interface: bond0
2440 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02002441
Dzmitry Stremkouskid1a268b2018-10-03 16:36:04 +02002442Check network params on the environment
2443---------------------------------------
2444
2445Grab nics and nics states
2446
2447.. code-block:: bash
2448
2449 salt osd001\* net_checks.get_nics
2450
2451**Example of system output:**
2452
2453.. code-block:: bash
2454
2455 osd001.domain.com:
2456 |_
2457 - bond0
2458 - None
2459 - 1e:c8:64:42:23:b9
2460 - 0
2461 - 1500
2462 |_
2463 - bond1
2464 - None
2465 - 3c:fd:fe:27:3b:00
2466 - 1
2467 - 9100
2468 |_
2469 - fourty1
2470 - None
2471 - 3c:fd:fe:27:3b:00
2472 - 1
2473 - 9100
2474 |_
2475 - fourty2
2476 - None
2477 - 3c:fd:fe:27:3b:02
2478 - 1
2479 - 9100
2480
2481Grab 10G nics PCI addresses for hugepages setup
2482
2483.. code-block:: bash
2484
2485 salt cmp001\* net_checks.get_ten_pci
2486
2487**Example of system output:**
2488
2489.. code-block:: bash
2490
2491 cmp001.domain.com:
2492 |_
2493 - ten1
2494 - 0000:19:00.0
2495 |_
2496 - ten2
2497 - 0000:19:00.1
2498 |_
2499 - ten3
2500 - 0000:19:00.2
2501 |_
2502 - ten4
2503 - 0000:19:00.3
2504
2505Grab ip address for an interface
2506
2507.. code-block:: bash
2508
2509 salt cmp001\* net_checks.get_ip iface=one4
2510
2511**Example of system output:**
2512
2513.. code-block:: bash
2514
2515 cmp001.domain.com:
2516 10.200.177.101
2517
2518Grab ip addresses map
2519
2520.. code-block:: bash
2521
2522 salt-call net_checks.nodes_addresses
2523
2524**Example of system output:**
2525
2526.. code-block:: bash
2527
2528 local:
2529 |_
2530 - cid01.domain.com
2531 |_
2532 |_
2533 - pxe
2534 - 10.200.177.91
2535 |_
2536 - control
2537 - 10.200.178.91
2538 |_
2539 - cmn02.domain.com
2540 |_
2541 |_
2542 - storage_access
2543 - 10.200.181.67
2544 |_
2545 - pxe
2546 - 10.200.177.67
2547 |_
2548 - control
2549 - 10.200.178.67
2550 |_
2551 - cmp010.domain.com
2552 |_
2553 |_
2554 - pxe
2555 - 10.200.177.110
2556 |_
2557 - storage_access
2558 - 10.200.181.110
2559 |_
2560 - control
2561 - 10.200.178.110
2562 |_
2563 - vxlan
2564 - 10.200.179.110
2565
2566Verify full mesh connectivity
2567
2568.. code-block:: bash
2569
2570 salt-call net_checks.ping_check
2571
2572**Example of positive system output:**
2573
2574.. code-block:: bash
2575
2576 ['PASSED']
2577 [INFO ] ['PASSED']
2578 local:
2579 True
2580
2581**Example of system output in case of failure:**
2582
2583.. code-block:: bash
2584
2585 FAILED
2586 [ERROR ] FAILED
2587 ['control: 10.0.1.92 -> 10.0.1.224: Failed']
2588 ['control: 10.0.1.93 -> 10.0.1.224: Failed']
2589 ['control: 10.0.1.51 -> 10.0.1.224: Failed']
2590 ['control: 10.0.1.102 -> 10.0.1.224: Failed']
2591 ['control: 10.0.1.13 -> 10.0.1.224: Failed']
2592 ['control: 10.0.1.81 -> 10.0.1.224: Failed']
2593 local:
2594 False
2595
2596For this feature to work, please mark addresses with some role.
2597Otherwise 'default' role is assumed and mesh would consist of all
2598addresses on the environment.
2599
2600Mesh mark is needed only for interfaces which are enabled and have
2601ip address assigned.
2602
2603Checking dhcp pxe network meaningless, as it is used for salt
2604master vs minion communications, therefore treated as checked.
2605
2606.. code-block:: yaml
2607
2608 parameters:
2609 linux:
2610 network:
2611 interface:
2612 ens3:
2613 enabled: true
2614 type: eth
2615 proto: static
2616 address: ${_param:deploy_address}
2617 netmask: ${_param:deploy_network_netmask}
2618 gateway: ${_param:deploy_network_gateway}
2619 mesh: pxe
2620
2621Check pillars for ip address duplicates
2622
2623.. code-block:: bash
2624
2625 salt-call net_checks.verify_addresses
2626
2627**Example of positive system output:**
2628
2629.. code-block:: bash
2630
2631 ['PASSED']
2632 [INFO ] ['PASSED']
2633 local:
2634 True
2635
2636**Example of system output in case of failure:**
2637
2638.. code-block:: bash
2639
2640 FAILED. Duplicates found
2641 [ERROR ] FAILED. Duplicates found
2642 ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2643 [ERROR ] ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2644 local:
2645 False
2646
2647Generate csv report for the env
2648
2649.. code-block:: bash
2650
2651 salt -C 'kvm* or cmp* or osd*' net_checks.get_nics_csv \
2652 | grep '^\ ' | sed 's/\ *//g' | grep -Ev ^server \
2653 | sed '1 i\server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr'
2654
2655**Example of system output:**
2656
2657.. code-block:: bash
2658
2659 server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr
2660 cmp010.domain.com,bond0,None,b4:96:91:10:5b:3a,1,1500,,,,
2661 cmp010.domain.com,bond0.21,10.200.178.110,b4:96:91:10:5b:3a,1,1500,,,,
2662 cmp010.domain.com,bond0.22,10.200.179.110,b4:96:91:10:5b:3a,1,1500,,,,
2663 cmp010.domain.com,bond1,None,3c:fd:fe:34:ad:22,0,1500,,,,
2664 cmp010.domain.com,bond1.24,10.200.181.110,3c:fd:fe:34:ad:22,0,1500,,,,
2665 cmp010.domain.com,fourty5,None,3c:fd:fe:34:ad:20,0,9000,,,,
2666 cmp010.domain.com,fourty6,None,3c:fd:fe:34:ad:22,0,9000,,,,
2667 cmp010.domain.com,one1,None,b4:96:91:10:5b:38,0,1500,,,,
2668 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
2669 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
2670 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
2671 cmp011.domain.com,bond0,None,b4:96:91:13:6c:aa,1,1500,,,,
2672 cmp011.domain.com,bond0.21,10.200.178.111,b4:96:91:13:6c:aa,1,1500,,,,
2673 cmp011.domain.com,bond0.22,10.200.179.111,b4:96:91:13:6c:aa,1,1500,,,,
2674 ...
2675
Filip Pytlounf5383a42015-10-06 16:28:32 +02002676Usage
2677=====
2678
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002679Set MTU of the eth0 network interface to 1400:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002680
2681.. code-block:: bash
2682
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002683 ip link set dev eth0 mtu 1400
Filip Pytlounf5383a42015-10-06 16:28:32 +02002684
2685Read more
2686=========
2687
2688* https://www.archlinux.org/
2689* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu