blob: 9c6637485e52dc04fa2090614292e2767fa775be [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
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001487Native Linux Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001488
1489.. code-block:: yaml
1490
1491 linux:
1492 network:
1493 interface:
1494 eth1:
1495 enabled: true
1496 type: eth
1497 proto: manual
1498 up_cmds:
1499 - ip address add 0/0 dev $IFACE
1500 - ip link set $IFACE up
1501 down_cmds:
1502 - ip link set $IFACE down
1503 br-ex:
1504 enabled: true
1505 type: bridge
1506 address: ${linux:network:host:public_local:address}
1507 netmask: 255.255.255.0
1508 use_interfaces:
1509 - eth1
1510
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001511Open vSwitch Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001512
1513.. code-block:: yaml
1514
1515 linux:
1516 network:
1517 bridge: openvswitch
1518 interface:
1519 eth1:
1520 enabled: true
1521 type: eth
1522 proto: manual
1523 up_cmds:
1524 - ip address add 0/0 dev $IFACE
1525 - ip link set $IFACE up
1526 down_cmds:
1527 - ip link set $IFACE down
1528 br-ex:
1529 enabled: true
1530 type: bridge
1531 address: ${linux:network:host:public_local:address}
1532 netmask: 255.255.255.0
1533 use_interfaces:
1534 - eth1
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001535 br-prv:
1536 enabled: true
1537 type: ovs_bridge
1538 mtu: 65000
1539 br-ens7:
1540 enabled: true
1541 name: br-ens7
1542 type: ovs_bridge
1543 proto: manual
1544 mtu: 9000
1545 use_interfaces:
1546 - ens7
1547 patch-br-ens7-br-prv:
1548 enabled: true
1549 name: ens7-prv
1550 ovs_type: ovs_port
1551 type: ovs_port
1552 bridge: br-ens7
1553 port_type: patch
1554 peer: prv-ens7
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001555 tag: 109 # [] to unset a tag
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001556 mtu: 65000
1557 patch-br-prv-br-ens7:
1558 enabled: true
1559 name: prv-ens7
1560 bridge: br-prv
1561 ovs_type: ovs_port
1562 type: ovs_port
1563 port_type: patch
1564 peer: ens7-prv
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001565 tag: 109
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001566 mtu: 65000
1567 ens7:
1568 enabled: true
1569 name: ens7
1570 proto: manual
1571 ovs_port_type: OVSPort
1572 type: ovs_port
1573 ovs_bridge: br-ens7
1574 bridge: br-ens7
Filip Pytlounf5383a42015-10-06 16:28:32 +02001575
Petr Jediný8f8ae542017-07-13 16:19:12 +02001576Debian manual proto interfaces
1577
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001578When you are changing interface proto from static in up state
1579to manual, you may need to flush ip addresses. For example,
1580if you want to use the interface and the ip on the bridge.
1581This can be done by setting the ``ipflush_onchange`` to true.
Petr Jediný8f8ae542017-07-13 16:19:12 +02001582
1583.. code-block:: yaml
1584
1585 linux:
1586 network:
1587 interface:
1588 eth1:
1589 enabled: true
1590 type: eth
1591 proto: manual
1592 mtu: 9100
1593 ipflush_onchange: true
1594
Jiri Broulik1a191e32018-01-15 15:54:21 +01001595Debian static proto interfaces
1596
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001597When you are changing interface proto from dhcp in up state to
1598static, you may need to flush ip addresses and restart interface
1599to assign ip address from a managed file. For example, if you wantto
1600use the interface and the ip on the bridge. This can be done by
1601setting the ``ipflush_onchange`` with combination ``restart_on_ipflush``
1602param set to true.
Jiri Broulik1a191e32018-01-15 15:54:21 +01001603
1604.. code-block:: yaml
1605
1606 linux:
1607 network:
1608 interface:
1609 eth1:
1610 enabled: true
1611 type: eth
1612 proto: static
1613 address: 10.1.0.22
1614 netmask: 255.255.255.0
1615 ipflush_onchange: true
1616 restart_on_ipflush: true
Petr Jediný8f8ae542017-07-13 16:19:12 +02001617
Petr Jedinýd577cb52017-06-28 20:17:49 +02001618Concatinating and removing interface files
1619
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001620Debian based distributions have ``/etc/network/interfaces.d/``
1621directory, where you can store configuration of network
1622interfaces in separate files. You can concatinate the files
1623to the defined destination when needed, this operation removes
1624the file from the ``/etc/network/interfaces.d/``. If you just need
1625to remove iface files, you can use the ``remove_iface_files`` key.
Petr Jedinýd577cb52017-06-28 20:17:49 +02001626
1627.. code-block:: yaml
1628
1629 linux:
1630 network:
1631 concat_iface_files:
1632 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
1633 dst: '/etc/network/interfaces'
1634 remove_iface_files:
1635 - '/etc/network/interfaces.d/90-custom.cfg'
1636
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001637Configure DHCP client
Petr Jedinýd577cb52017-06-28 20:17:49 +02001638
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001639None of the keys is mandatory, include only those you really need.
1640For full list of available options under send, supersede, prepend,
1641append refer to dhcp-options(5).
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001642
1643.. code-block:: yaml
1644
1645 linux:
1646 network:
1647 dhclient:
1648 enabled: true
1649 backoff_cutoff: 15
1650 initial_interval: 10
1651 reboot: 10
1652 retry: 60
1653 select_timeout: 0
1654 timeout: 120
1655 send:
1656 - option: host-name
1657 declaration: "= gethostname()"
1658 supersede:
1659 - option: host-name
1660 declaration: "spaceship"
1661 - option: domain-name
1662 declaration: "domain.home"
1663 #- option: arp-cache-timeout
1664 # declaration: 20
1665 prepend:
1666 - option: domain-name-servers
1667 declaration:
1668 - 8.8.8.8
1669 - 8.8.4.4
1670 - option: domain-search
1671 declaration:
1672 - example.com
1673 - eng.example.com
1674 #append:
1675 #- option: domain-name-servers
1676 # declaration: 127.0.0.1
1677 # ip or subnet to reject dhcp offer from
1678 reject:
1679 - 192.33.137.209
1680 - 10.0.2.0/24
1681 request:
1682 - subnet-mask
1683 - broadcast-address
1684 - time-offset
1685 - routers
1686 - domain-name
1687 - domain-name-servers
1688 - domain-search
1689 - host-name
1690 - dhcp6.name-servers
1691 - dhcp6.domain-search
1692 - dhcp6.fqdn
1693 - dhcp6.sntp-servers
1694 - netbios-name-servers
1695 - netbios-scope
1696 - interface-mtu
1697 - rfc3442-classless-static-routes
1698 - ntp-servers
1699 require:
1700 - subnet-mask
1701 - domain-name-servers
1702 # if per interface configuration required add below
1703 interface:
1704 ens2:
1705 initial_interval: 11
1706 reject:
1707 - 192.33.137.210
1708 ens3:
1709 initial_interval: 12
1710 reject:
1711 - 192.33.137.211
1712
Petr Michaleceb14b552017-06-01 10:27:05 +02001713Linux network systemd settings:
1714
1715.. code-block:: yaml
1716
1717 linux:
1718 network:
1719 ...
1720 systemd:
1721 link:
1722 10-iface-dmz:
1723 Match:
1724 MACAddress: c8:5b:67:fa:1a:af
1725 OriginalName: eth0
1726 Link:
1727 Name: dmz0
1728 netdev:
1729 20-bridge-dmz:
1730 match:
1731 name: dmz0
1732 network:
1733 mescription: bridge
1734 bridge: br-dmz0
1735 network:
1736 # works with lowercase, keys are by default capitalized
1737 40-dhcp:
1738 match:
1739 name: '*'
1740 network:
1741 DHCP: yes
1742
Petr Michalec10462bb2017-03-23 19:18:08 +01001743Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +01001744
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001745Use ``/etc/environment`` for static system wide variable assignment
1746after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001747
1748.. code-block:: yaml
1749
1750 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +01001751 system:
1752 env:
1753 BOB_VARIABLE: Alice
1754 ...
1755 BOB_PATH:
1756 - /srv/alice/bin
1757 - /srv/bob/bin
1758 ...
1759 ftp_proxy: none
1760 http_proxy: http://global-http-proxy.host.local:8080
1761 https_proxy: ${linux:system:proxy:https}
1762 no_proxy:
1763 - 192.168.0.80
1764 - 192.168.1.80
1765 - .domain.com
1766 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001767 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001768 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001769 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001770 ftp: ftp://proxy.host.local:2121
1771 http: http://proxy.host.local:3142
1772 https: https://proxy.host.local:3143
1773 noproxy:
1774 - .domain.com
1775 - .local
1776
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001777Configure the ``profile.d`` scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001778
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001779The ``profile.d`` scripts are being sourced during ``.sh`` execution
1780and support variable expansion in opposite to /etc/environment global
1781settings in ``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001782
1783.. code-block:: yaml
1784
1785 linux:
1786 system:
1787 profile:
1788 locales: |
1789 export LANG=C
1790 export LC_ALL=C
1791 ...
1792 vi_flavors.sh: |
1793 export PAGER=view
1794 export EDITOR=vim
1795 alias vi=vim
1796 shell_locales.sh: |
1797 export LANG=en_US
1798 export LC_ALL=en_US.UTF-8
1799 shell_proxies.sh: |
1800 export FTP_PROXY=ftp://127.0.3.3:2121
1801 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001802
Dmitry Teselkina0d31d12018-09-04 14:43:09 +03001803
1804Configure login.defs parameters
1805-------------------------------
1806
1807.. code-block:: yaml
1808
1809 linux:
1810 system:
1811 login_defs:
1812 <opt_name>:
1813 enabled: true
1814 value: <opt_value>
1815
1816<opt_name> is a configurational option defined in 'man login.defs'.
1817<opt_name> is case sensitive, should be UPPERCASE only!
1818
1819
Filip Pytlounf5383a42015-10-06 16:28:32 +02001820Linux with hosts
1821
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001822Parameter ``purge_hosts`` will enforce whole ``/etc/hosts file``,
1823removing entries that are not defined in model except defaults
1824for both IPv4 and IPv6 localhost and hostname as well as FQDN.
Ales Komarek417e8c52017-08-25 15:10:29 +02001825
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001826We recommend using this option to verify that ``/etc/hosts``
1827is always in a clean state. However it is not enabled by default
1828for security reasons.
Filip Pytloun86506fe2017-01-26 14:36:16 +01001829
Filip Pytlounf5383a42015-10-06 16:28:32 +02001830.. code-block:: yaml
1831
1832 linux:
1833 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001834 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001835 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001836 # No need to define this one if purge_hosts is true
1837 hostname:
1838 address: 127.0.1.1
1839 names:
1840 - ${linux:network:fqdn}
1841 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001842 node1:
1843 address: 192.168.10.200
1844 names:
1845 - node2.domain.com
1846 - service2.domain.com
1847 node2:
1848 address: 192.168.10.201
1849 names:
1850 - node2.domain.com
1851 - service2.domain.com
1852
Ales Komarek417e8c52017-08-25 15:10:29 +02001853Linux with hosts collected from mine
1854
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001855All DNS records defined within infrastrucuture
1856are passed to the local hosts records or any DNS server. Only
1857hosts with the ``grain`` parameter set to ``true`` will be propagated
1858to the mine.
Ales Komarek417e8c52017-08-25 15:10:29 +02001859
1860.. code-block:: yaml
1861
1862 linux:
1863 network:
1864 purge_hosts: true
1865 mine_dns_records: true
1866 host:
1867 node1:
1868 address: 192.168.10.200
1869 grain: true
1870 names:
1871 - node2.domain.com
1872 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01001873
Michael Polenchukc80ddd42019-01-15 18:47:48 +04001874Set up ``resolvconf's basic resolver info``, e.g. nameservers, search/domain and options:
Filip Pytlounde9bea52016-01-11 15:39:10 +01001875
1876.. code-block:: yaml
1877
1878 linux:
1879 network:
1880 resolv:
1881 dns:
Michael Polenchukc80ddd42019-01-15 18:47:48 +04001882 - 8.8.4.4
1883 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01001884 domain: my.example.com
1885 search:
Michael Polenchukc80ddd42019-01-15 18:47:48 +04001886 - my.example.com
1887 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01001888 options:
Michael Polenchukc80ddd42019-01-15 18:47:48 +04001889 - ndots:5
1890 - timeout:2
1891 - attempts:2
Filip Pytlounde9bea52016-01-11 15:39:10 +01001892
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001893Set up custom TX queue length for tap interfaces:
Andrii Petrenko735761d2017-03-21 17:17:35 -07001894
1895.. code-block:: yaml
1896
1897 linux:
1898 network:
1899 tap_custom_txqueuelen: 10000
1900
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001901DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001902
1903**DPDK OVS NIC**
1904
1905.. code-block:: yaml
1906
1907 linux:
1908 network:
1909 bridge: openvswitch
1910 dpdk:
1911 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001912 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001913 openvswitch:
1914 pmd_cpu_mask: "0x6"
1915 dpdk_socket_mem: "1024,1024"
1916 dpdk_lcore_mask: "0x400"
1917 memory_channels: 2
1918 interface:
1919 dpkd0:
1920 name: ${_param:dpdk_nic}
1921 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001922 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001923 enabled: true
1924 type: dpdk_ovs_port
1925 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001926 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001927 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01001928 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001929 br-prv:
1930 enabled: true
1931 type: dpdk_ovs_bridge
1932
1933**DPDK OVS Bond**
1934
1935.. code-block:: yaml
1936
1937 linux:
1938 network:
1939 bridge: openvswitch
1940 dpdk:
1941 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001942 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001943 openvswitch:
1944 pmd_cpu_mask: "0x6"
1945 dpdk_socket_mem: "1024,1024"
1946 dpdk_lcore_mask: "0x400"
1947 memory_channels: 2
1948 interface:
1949 dpdk_second_nic:
1950 name: ${_param:primary_second_nic}
1951 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001952 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001953 bond: dpdkbond0
1954 enabled: true
1955 type: dpdk_ovs_port
1956 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001957 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001958 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001959 dpdk_first_nic:
1960 name: ${_param:primary_first_nic}
1961 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001962 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001963 bond: dpdkbond0
1964 enabled: true
1965 type: dpdk_ovs_port
1966 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001967 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001968 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001969 dpdkbond0:
1970 enabled: true
1971 bridge: br-prv
1972 type: dpdk_ovs_bond
1973 mode: active-backup
1974 br-prv:
1975 enabled: true
1976 type: dpdk_ovs_bridge
1977
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01001978**DPDK OVS LACP Bond with vlan tag**
1979
1980.. code-block:: yaml
1981
1982 linux:
1983 network:
1984 bridge: openvswitch
1985 dpdk:
1986 enabled: true
1987 driver: uio
1988 openvswitch:
1989 pmd_cpu_mask: "0x6"
1990 dpdk_socket_mem: "1024,1024"
1991 dpdk_lcore_mask: "0x400"
1992 memory_channels: "2"
1993 interface:
1994 eth3:
1995 enabled: true
1996 type: eth
1997 proto: manual
1998 name: ${_param:tenant_first_nic}
1999 eth4:
2000 enabled: true
2001 type: eth
2002 proto: manual
2003 name: ${_param:tenant_second_nic}
2004 dpdk0:
2005 name: ${_param:tenant_first_nic}
2006 pci: "0000:81:00.0"
2007 driver: igb_uio
2008 bond: bond1
2009 enabled: true
2010 type: dpdk_ovs_port
2011 n_rxq: 2
2012 dpdk1:
2013 name: ${_param:tenant_second_nic}
2014 pci: "0000:81:00.1"
2015 driver: igb_uio
2016 bond: bond1
2017 enabled: true
2018 type: dpdk_ovs_port
2019 n_rxq: 2
2020 bond1:
2021 enabled: true
2022 bridge: br-prv
2023 type: dpdk_ovs_bond
2024 mode: balance-slb
2025 br-prv:
2026 enabled: true
2027 type: dpdk_ovs_bridge
2028 tag: ${_param:tenant_vlan}
2029 address: ${_param:tenant_address}
2030 netmask: ${_param:tenant_network_netmask}
2031
Jakub Pavlikaa759062017-03-13 15:57:26 +01002032**DPDK OVS bridge for VXLAN**
2033
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002034If VXLAN is used as tenant segmentation, IP address must
2035be set on ``br-prv``.
Jakub Pavlikaa759062017-03-13 15:57:26 +01002036
2037.. code-block:: yaml
2038
2039 linux:
2040 network:
2041 ...
2042 interface:
2043 br-prv:
2044 enabled: true
2045 type: dpdk_ovs_bridge
2046 address: 192.168.50.0
2047 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04002048 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01002049 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002050
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02002051**DPDK OVS bridge with Linux network interface**
2052
2053.. code-block:: yaml
2054
2055 linux:
2056 network:
2057 ...
2058 interface:
2059 eth0:
2060 type: eth
2061 ovs_bridge: br-prv
2062 ...
2063 br-prv:
2064 enabled: true
2065 type: dpdk_ovs_bridge
2066 ...
2067
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002068Linux storage
2069-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02002070
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002071Linux with mounted Samba:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002072
2073.. code-block:: yaml
2074
2075 linux:
2076 storage:
2077 enabled: true
2078 mount:
2079 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01002080 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02002081 - path: /media/myuser/public/
2082 - device: //192.168.0.1/storage
2083 - file_system: cifs
2084 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
2085
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002086NFS mount:
Jiri Broulikb017f932017-03-31 13:55:36 +02002087
2088.. code-block:: yaml
2089
2090 linux:
2091 storage:
2092 enabled: true
2093 mount:
2094 nfs_glance:
2095 enabled: true
2096 path: /var/lib/glance/images
2097 device: 172.16.10.110:/var/nfs/glance
2098 file_system: nfs
2099 opts: rw,sync
2100
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002101File swap configuration:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002102
2103.. code-block:: yaml
2104
2105 linux:
2106 storage:
2107 enabled: true
2108 swap:
2109 file:
2110 enabled: true
2111 engine: file
2112 device: /swapfile
2113 size: 1024
2114
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002115Partition swap configuration:
Lachlan Evenson30676512016-01-22 15:43:28 -08002116
2117.. code-block:: yaml
2118
2119 linux:
2120 storage:
2121 enabled: true
2122 swap:
2123 partition:
2124 enabled: true
2125 engine: partition
2126 device: /dev/vg0/swap
2127
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002128LVM group ``vg1`` with one device and ``data`` volume mounted
2129into ``/mnt/data``.
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002130
2131.. code-block:: yaml
2132
2133 parameters:
2134 linux:
2135 storage:
2136 mount:
2137 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01002138 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002139 device: /dev/vg1/data
2140 file_system: ext4
2141 path: /mnt/data
2142 lvm:
2143 vg1:
2144 enabled: true
2145 devices:
2146 - /dev/sdb
2147 volume:
2148 data:
2149 size: 40G
2150 mount: ${linux:storage:mount:data}
root3387f332019-01-11 08:55:32 +00002151 # When set they will take precedence over filters aget from volume groups.
2152 lvm_filters:
2153 10:
2154 enabled: True
2155 value: "a|loop|"
2156 20:
2157 enabled: True
2158 value: "r|/dev/hdc|"
2159 30:
2160 enabled: True
2161 value: "a|/dev/ide|"
2162 40:
2163 enabled: True
2164 value: "r|.*|"
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002165
Jakub Pavlik4f742142017-08-08 15:05:50 +02002166Create partitions on disk. Specify size in MB. It expects empty
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002167disk without any existing partitions.
2168Set ``startsector=1`` if you want to start partitions from ``2048``.
Jakub Pavlik4f742142017-08-08 15:05:50 +02002169
2170.. code-block:: yaml
2171
2172 linux:
2173 storage:
2174 disk:
2175 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01002176 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02002177 name: /dev/loop1
2178 type: gpt
2179 partitions:
2180 - size: 200 #size in MB
2181 type: fat32
2182 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02002183 mkfs: True
2184 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02002185 /dev/vda1:
2186 partitions:
2187 - size: 5
2188 type: ext2
2189 - size: 10
2190 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02002191
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002192Multipath with Fujitsu Eternus DXL:
Ales Komareka634f4b2016-10-02 13:11:04 +02002193
2194.. code-block:: yaml
2195
2196 parameters:
2197 linux:
2198 storage:
2199 multipath:
2200 enabled: true
2201 blacklist_devices:
2202 - /dev/sda
2203 - /dev/sdb
2204 backends:
2205 - fujitsu_eternus_dxl
2206
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002207Multipath with Hitachi VSP 1000:
Ales Komareka634f4b2016-10-02 13:11:04 +02002208
2209.. code-block:: yaml
2210
2211 parameters:
2212 linux:
2213 storage:
2214 multipath:
2215 enabled: true
2216 blacklist_devices:
2217 - /dev/sda
2218 - /dev/sdb
2219 backends:
2220 - hitachi_vsp1000
2221
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002222Multipath with IBM Storwize:
Ales Komareka634f4b2016-10-02 13:11:04 +02002223
2224.. code-block:: yaml
2225
2226 parameters:
2227 linux:
2228 storage:
2229 multipath:
2230 enabled: true
2231 blacklist_devices:
2232 - /dev/sda
2233 - /dev/sdb
2234 backends:
2235 - ibm_storwize
2236
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002237Multipath with multiple backends:
Ales Komareka634f4b2016-10-02 13:11:04 +02002238
2239.. code-block:: yaml
2240
2241 parameters:
2242 linux:
2243 storage:
2244 multipath:
2245 enabled: true
2246 blacklist_devices:
2247 - /dev/sda
2248 - /dev/sdb
2249 - /dev/sdc
2250 - /dev/sdd
2251 backends:
2252 - ibm_storwize
2253 - fujitsu_eternus_dxl
2254 - hitachi_vsp1000
2255
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002256PAM LDAP integration:
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002257
2258.. code-block:: yaml
2259
2260 parameters:
2261 linux:
2262 system:
2263 auth:
2264 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02002265 mkhomedir:
2266 enabled: true
2267 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002268 ldap:
2269 enabled: true
2270 binddn: cn=bind,ou=service_users,dc=example,dc=com
2271 bindpw: secret
2272 uri: ldap://127.0.0.1
2273 base: ou=users,dc=example,dc=com
2274 ldap_version: 3
2275 pagesize: 65536
2276 referrals: off
2277 filter:
2278 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2279 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2280 group: (&(objectClass=group)(gidNumber=*))
2281
Gleb Galkin93b9ae92018-10-18 13:57:30 +03002282PAM duo 2FA integration
2283
2284.. code-block:: yaml
2285
2286 parameters:
2287 linux:
2288 system:
2289 auth:
2290 enabled: true
2291 duo:
2292 enabled: true
2293 duo_host: localhost
2294 duo_ikey: DUO-INTEGRATION-KEY
2295 duo_skey: DUO-SECRET-KEY
2296
2297duo package version may be specified (optional)
2298
2299.. code-block:: yaml
2300
2301 linux:
2302 system:
2303 package:
2304 duo-unix:
2305 version: 1.10.1-0
2306
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002307Disabled multipath (the default setup):
Ales Komareka634f4b2016-10-02 13:11:04 +02002308
2309.. code-block:: yaml
2310
2311 parameters:
2312 linux:
2313 storage:
2314 multipath:
2315 enabled: false
2316
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002317Linux with local loopback device:
Simon Pasquier375001e2017-01-26 13:22:33 +01002318
2319.. code-block:: yaml
2320
2321 linux:
2322 storage:
2323 loopback:
2324 disk1:
2325 file: /srv/disk1
2326 size: 50G
2327
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002328External config generation
2329--------------------------
2330
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002331You are able to use config support metadata between formulas
2332and only generate configuration files for external use, for example, Docker, and so on.
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002333
2334.. code-block:: yaml
2335
2336 parameters:
2337 linux:
2338 system:
2339 config:
2340 pillar:
2341 jenkins:
2342 master:
2343 home: /srv/volumes/jenkins
2344 approved_scripts:
2345 - method java.net.URL openConnection
2346 credentials:
2347 - type: username_password
2348 scope: global
2349 id: test
2350 desc: Testing credentials
2351 username: test
2352 password: test
2353
Vladimir Ereminccf28842017-04-10 23:52:10 +03002354Netconsole Remote Kernel Logging
2355--------------------------------
2356
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002357Netconsole logger can be configured for the configfs-enabled kernels
2358(``CONFIG_NETCONSOLE_DYNAMIC`` must be enabled). The configuration
2359applies both in runtime (if network is already configured),
2360and on-boot after an interface initialization.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002361
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002362.. note::
2363
2364 * Receiver can be located only on the same L3 domain
2365 (or you need to configure gateway MAC manually).
2366 * The Receiver MAC is detected only on configuration time.
2367 * Using broadcast MAC is not recommended.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002368
2369.. code-block:: yaml
2370
2371 parameters:
2372 linux:
2373 system:
2374 netconsole:
2375 enabled: true
2376 port: 514 (optional)
2377 loglevel: debug (optional)
2378 target:
2379 192.168.0.1:
2380 interface: bond0
2381 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02002382
Dzmitry Stremkouskid1a268b2018-10-03 16:36:04 +02002383Check network params on the environment
2384---------------------------------------
2385
2386Grab nics and nics states
2387
2388.. code-block:: bash
2389
2390 salt osd001\* net_checks.get_nics
2391
2392**Example of system output:**
2393
2394.. code-block:: bash
2395
2396 osd001.domain.com:
2397 |_
2398 - bond0
2399 - None
2400 - 1e:c8:64:42:23:b9
2401 - 0
2402 - 1500
2403 |_
2404 - bond1
2405 - None
2406 - 3c:fd:fe:27:3b:00
2407 - 1
2408 - 9100
2409 |_
2410 - fourty1
2411 - None
2412 - 3c:fd:fe:27:3b:00
2413 - 1
2414 - 9100
2415 |_
2416 - fourty2
2417 - None
2418 - 3c:fd:fe:27:3b:02
2419 - 1
2420 - 9100
2421
2422Grab 10G nics PCI addresses for hugepages setup
2423
2424.. code-block:: bash
2425
2426 salt cmp001\* net_checks.get_ten_pci
2427
2428**Example of system output:**
2429
2430.. code-block:: bash
2431
2432 cmp001.domain.com:
2433 |_
2434 - ten1
2435 - 0000:19:00.0
2436 |_
2437 - ten2
2438 - 0000:19:00.1
2439 |_
2440 - ten3
2441 - 0000:19:00.2
2442 |_
2443 - ten4
2444 - 0000:19:00.3
2445
2446Grab ip address for an interface
2447
2448.. code-block:: bash
2449
2450 salt cmp001\* net_checks.get_ip iface=one4
2451
2452**Example of system output:**
2453
2454.. code-block:: bash
2455
2456 cmp001.domain.com:
2457 10.200.177.101
2458
2459Grab ip addresses map
2460
2461.. code-block:: bash
2462
2463 salt-call net_checks.nodes_addresses
2464
2465**Example of system output:**
2466
2467.. code-block:: bash
2468
2469 local:
2470 |_
2471 - cid01.domain.com
2472 |_
2473 |_
2474 - pxe
2475 - 10.200.177.91
2476 |_
2477 - control
2478 - 10.200.178.91
2479 |_
2480 - cmn02.domain.com
2481 |_
2482 |_
2483 - storage_access
2484 - 10.200.181.67
2485 |_
2486 - pxe
2487 - 10.200.177.67
2488 |_
2489 - control
2490 - 10.200.178.67
2491 |_
2492 - cmp010.domain.com
2493 |_
2494 |_
2495 - pxe
2496 - 10.200.177.110
2497 |_
2498 - storage_access
2499 - 10.200.181.110
2500 |_
2501 - control
2502 - 10.200.178.110
2503 |_
2504 - vxlan
2505 - 10.200.179.110
2506
2507Verify full mesh connectivity
2508
2509.. code-block:: bash
2510
2511 salt-call net_checks.ping_check
2512
2513**Example of positive system output:**
2514
2515.. code-block:: bash
2516
2517 ['PASSED']
2518 [INFO ] ['PASSED']
2519 local:
2520 True
2521
2522**Example of system output in case of failure:**
2523
2524.. code-block:: bash
2525
2526 FAILED
2527 [ERROR ] FAILED
2528 ['control: 10.0.1.92 -> 10.0.1.224: Failed']
2529 ['control: 10.0.1.93 -> 10.0.1.224: Failed']
2530 ['control: 10.0.1.51 -> 10.0.1.224: Failed']
2531 ['control: 10.0.1.102 -> 10.0.1.224: Failed']
2532 ['control: 10.0.1.13 -> 10.0.1.224: Failed']
2533 ['control: 10.0.1.81 -> 10.0.1.224: Failed']
2534 local:
2535 False
2536
2537For this feature to work, please mark addresses with some role.
2538Otherwise 'default' role is assumed and mesh would consist of all
2539addresses on the environment.
2540
2541Mesh mark is needed only for interfaces which are enabled and have
2542ip address assigned.
2543
2544Checking dhcp pxe network meaningless, as it is used for salt
2545master vs minion communications, therefore treated as checked.
2546
2547.. code-block:: yaml
2548
2549 parameters:
2550 linux:
2551 network:
2552 interface:
2553 ens3:
2554 enabled: true
2555 type: eth
2556 proto: static
2557 address: ${_param:deploy_address}
2558 netmask: ${_param:deploy_network_netmask}
2559 gateway: ${_param:deploy_network_gateway}
2560 mesh: pxe
2561
2562Check pillars for ip address duplicates
2563
2564.. code-block:: bash
2565
2566 salt-call net_checks.verify_addresses
2567
2568**Example of positive system output:**
2569
2570.. code-block:: bash
2571
2572 ['PASSED']
2573 [INFO ] ['PASSED']
2574 local:
2575 True
2576
2577**Example of system output in case of failure:**
2578
2579.. code-block:: bash
2580
2581 FAILED. Duplicates found
2582 [ERROR ] FAILED. Duplicates found
2583 ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2584 [ERROR ] ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2585 local:
2586 False
2587
2588Generate csv report for the env
2589
2590.. code-block:: bash
2591
2592 salt -C 'kvm* or cmp* or osd*' net_checks.get_nics_csv \
2593 | grep '^\ ' | sed 's/\ *//g' | grep -Ev ^server \
2594 | sed '1 i\server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr'
2595
2596**Example of system output:**
2597
2598.. code-block:: bash
2599
2600 server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr
2601 cmp010.domain.com,bond0,None,b4:96:91:10:5b:3a,1,1500,,,,
2602 cmp010.domain.com,bond0.21,10.200.178.110,b4:96:91:10:5b:3a,1,1500,,,,
2603 cmp010.domain.com,bond0.22,10.200.179.110,b4:96:91:10:5b:3a,1,1500,,,,
2604 cmp010.domain.com,bond1,None,3c:fd:fe:34:ad:22,0,1500,,,,
2605 cmp010.domain.com,bond1.24,10.200.181.110,3c:fd:fe:34:ad:22,0,1500,,,,
2606 cmp010.domain.com,fourty5,None,3c:fd:fe:34:ad:20,0,9000,,,,
2607 cmp010.domain.com,fourty6,None,3c:fd:fe:34:ad:22,0,9000,,,,
2608 cmp010.domain.com,one1,None,b4:96:91:10:5b:38,0,1500,,,,
2609 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
2610 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
2611 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
2612 cmp011.domain.com,bond0,None,b4:96:91:13:6c:aa,1,1500,,,,
2613 cmp011.domain.com,bond0.21,10.200.178.111,b4:96:91:13:6c:aa,1,1500,,,,
2614 cmp011.domain.com,bond0.22,10.200.179.111,b4:96:91:13:6c:aa,1,1500,,,,
2615 ...
2616
Filip Pytlounf5383a42015-10-06 16:28:32 +02002617Usage
2618=====
2619
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002620Set MTU of the eth0 network interface to 1400:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002621
2622.. code-block:: bash
2623
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002624 ip link set dev eth0 mtu 1400
Filip Pytlounf5383a42015-10-06 16:28:32 +02002625
2626Read more
2627=========
2628
2629* https://www.archlinux.org/
2630* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu