blob: c844aef4036d2c07b6908ea6074887e69703605b [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 Teselkin47e41f42018-09-27 14:10:09 +030079Configure password expiration parameters
80----------------------------------------
81The following login.defs parameters can be overridden per-user:
82
83* PASS_MAX_DAYS
84* PASS_MIN_DAYS
85* PASS_WARN_DAYS
86* INACTIVE
87
88.. code-block:: yaml
89
90 linux:
91 system:
92 ...
93 user:
94 jdoe:
95 name: 'jdoe'
96 enabled: true
97 ...
98 maxdays: <PASS_MAX_DAYS>
99 mindays: <PASS_MIN_DAYS>
100 warndays: <PASS_WARN_DAYS>
101 inactdays: <INACTIVE>
102
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100103Configure sudo for users and groups under ``/etc/sudoers.d/``.
104This ways ``linux.system.sudo`` pillar map to actual sudo attributes:
105
106.. code-block:: jinja
Aleš Komárek63572992017-04-11 13:16:44 +0200107
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100108 # simplified template:
109 Cmds_Alias {{ alias }}={{ commands }}
110 {{ user }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
111 %{{ group }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
112
113 # when rendered:
114 saltuser1 ALL=(ALL) NOPASSWD: ALL
115
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100116.. code-block:: yaml
Aleš Komárek63572992017-04-11 13:16:44 +0200117
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100118 linux:
119 system:
120 sudo:
121 enabled: true
Tomas Kammd8eb3002017-05-08 19:30:29 +0200122 aliases:
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100123 host:
124 LOCAL:
125 - localhost
126 PRODUCTION:
127 - db1
128 - db2
129 runas:
130 DBA:
131 - postgres
132 - mysql
133 SALT:
134 - root
135 command:
136 # Note: This is not 100% safe when ALL keyword is used, user still may modify configs and hide his actions.
137 # Best practice is to specify full list of commands user is allowed to run.
138 SUPPORT_RESTRICTED:
139 - /bin/vi /etc/sudoers*
140 - /bin/vim /etc/sudoers*
141 - /bin/nano /etc/sudoers*
142 - /bin/emacs /etc/sudoers*
143 - /bin/su - root
144 - /bin/su -
145 - /bin/su
146 - /usr/sbin/visudo
147 SUPPORT_SHELLS:
148 - /bin/sh
149 - /bin/ksh
150 - /bin/bash
151 - /bin/rbash
152 - /bin/dash
153 - /bin/zsh
154 - /bin/csh
155 - /bin/fish
156 - /bin/tcsh
157 - /usr/bin/login
158 - /usr/bin/su
159 - /usr/su
160 ALL_SALT_SAFE:
161 - /usr/bin/salt state*
162 - /usr/bin/salt service*
163 - /usr/bin/salt pillar*
164 - /usr/bin/salt grains*
165 - /usr/bin/salt saltutil*
166 - /usr/bin/salt-call state*
167 - /usr/bin/salt-call service*
168 - /usr/bin/salt-call pillar*
169 - /usr/bin/salt-call grains*
170 - /usr/bin/salt-call saltutil*
171 SALT_TRUSTED:
172 - /usr/bin/salt*
173 users:
174 # saltuser1 with default values: saltuser1 ALL=(ALL) NOPASSWD: ALL
175 saltuser1: {}
176 saltuser2:
177 hosts:
178 - LOCAL
179 # User Alias DBA
180 DBA:
181 hosts:
182 - ALL
183 commands:
184 - ALL_SALT_SAFE
185 groups:
186 db-ops:
187 hosts:
188 - ALL
189 - '!PRODUCTION'
190 runas:
191 - DBA
192 commands:
193 - /bin/cat *
194 - /bin/less *
195 - /bin/ls *
196 salt-ops:
197 hosts:
198 - 'ALL'
199 runas:
200 - SALT
201 commands:
202 - SUPPORT_SHELLS
203 salt-ops-2nd:
204 name: salt-ops
205 nopasswd: false
Jakub Josef7a9d9b92017-05-16 11:39:01 +0200206 setenv: true # Enable sudo -E option
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100207 runas:
208 - DBA
209 commands:
210 - ALL
211 - '!SUPPORT_SHELLS'
212 - '!SUPPORT_RESTRICTED'
213
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300214Linux with package, latest version:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200215
216.. code-block:: yaml
217
218 linux:
219 system:
220 ...
221 package:
222 package-name:
223 version: latest
224
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300225Linux with package from certail repo, version with no upgrades:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200226
227.. code-block:: yaml
228
229 linux:
230 system:
231 ...
232 package:
233 package-name:
234 version: 2132.323
235 repo: 'custom-repo'
236 hold: true
237
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300238Linux with package from certail repo, version with no GPG
239verification:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200240
241.. code-block:: yaml
242
243 linux:
244 system:
245 ...
246 package:
247 package-name:
248 version: 2132.323
249 repo: 'custom-repo'
250 verify: false
251
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300252Linux with autoupdates (automatically install security package
253updates):
Bruno Binet69a9d8d2017-02-16 22:34:32 +0100254
255.. code-block:: yaml
256
257 linux:
258 system:
259 ...
260 autoupdates:
261 enabled: true
262 mail: root@localhost
263 mail_only_on_error: true
264 remove_unused_dependencies: false
265 automatic_reboot: true
266 automatic_reboot_time: "02:00"
267
Dmitry Teselkin0f084a02018-08-29 14:46:38 +0300268Managing cron tasks
269-------------------
270
271There are two data structures that are related to managing cron itself and
272cron tasks:
273
274.. code-block:: yaml
275
276 linux:
277 system:
278 cron:
279
280and
281
282.. code-block:: yaml
283
284 linux:
285 system:
286 job:
287
288`linux:system:cron` manages cron packages, services, and '/etc/cron.allow' file.
289
290'deny' files are managed the only way - we're ensuring they are absent, that's
291a requirement from CIS 5.1.8
292
293'cron' pillar structure is the following:
294
295.. code-block:: yaml
296
297 linux:
298 system:
299 cron:
300 enabled: true
301 pkgs: [ <cron packages> ]
302 services: [ <cron services> ]
303 user:
304 <username>:
305 enabled: true
306
307To add user to '/etc/cron.allow' use 'enabled' key as shown above.
308
309'/etc/cron.deny' is not managed as CIS 5.1.8 requires it was removed.
310
311A user would be ignored if any of the following is true:
312* user is disabled in `linux:system:user:<username>`
313* user is disabled in `linux:system:cron:user:<username>`
314
315`linux:system:job` manages individual cron tasks.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300316
317By default, it will use name as an identifier, unless identifier key is
Filip Pytloun91222222017-08-04 10:55:27 +0200318explicitly set or False (then it will use Salt's default behavior which is
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300319identifier same as command resulting in not being able to change it):
Filip Pytlounf5383a42015-10-06 16:28:32 +0200320
321.. code-block:: yaml
322
323 linux:
324 system:
325 ...
326 job:
327 cmd1:
328 command: '/cmd/to/run'
Filip Pytloun91222222017-08-04 10:55:27 +0200329 identifier: cmd1
Filip Pytlounf5383a42015-10-06 16:28:32 +0200330 enabled: true
331 user: 'root'
332 hour: 2
333 minute: 0
334
Dmitry Teselkin0f084a02018-08-29 14:46:38 +0300335Managing 'at' tasks
336-------------------
337
338Pillar for managing `at` tasks is similar to one for `cron` tasks:
339
340.. code-block:: yaml
341
342 linux:
343 system:
344 at:
345 enabled: true
346 pkgs: [ <at packages> ]
347 services: [ <at services> ]
348 user:
349 <username>:
350 enabled: true
351
352To add a user to '/etc/at.allow' use 'enabled' key as shown above.
353
354'/etc/at.deny' is not managed as CIS 5.1.8 requires it was removed.
355
356A user will be ignored if any of the following is true:
357* user is disabled in `linux:system:user:<username>`
358* user is disabled in `linux:system:at:user:<username>`
359
360
Filip Pytlound0a29e72015-11-30 15:23:34 +0100361Linux security limits (limit sensu user memory usage to max 1GB):
362
363.. code-block:: yaml
364
365 linux:
366 system:
367 ...
368 limit:
369 sensu:
370 enabled: true
371 domain: sensu
372 limits:
373 - type: hard
374 item: as
375 value: 1000000
376
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300377Enable autologin on ``tty1`` (may work only for Ubuntu 14.04):
Filip Pytloun7fee0542015-10-15 11:19:24 +0200378
379.. code-block:: yaml
380
381 linux:
382 system:
383 console:
384 tty1:
385 autologin: root
Filip Pytloun281d0202016-01-29 14:03:51 +0100386 # Enable serial console
387 ttyS0:
388 autologin: root
389 rate: 115200
390 term: xterm
Filip Pytloun7fee0542015-10-15 11:19:24 +0200391
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300392To disable set autologin to ``false``.
Filip Pytloun7fee0542015-10-15 11:19:24 +0200393
Filip Pytloun7731b852016-02-01 11:13:47 +0100394Set ``policy-rc.d`` on Debian-based systems. Action can be any available
395command in ``while true`` loop and ``case`` context.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300396Following will disallow dpkg to stop/start services for the Cassandra
397package automatically:
Filip Pytloun7731b852016-02-01 11:13:47 +0100398
399.. code-block:: yaml
400
401 linux:
402 system:
403 policyrcd:
404 - package: cassandra
405 action: exit 101
406 - package: '*'
407 action: switch
408
Filip Pytlounc49445a2016-04-04 14:23:20 +0200409Set system locales:
410
411.. code-block:: yaml
412
413 linux:
414 system:
415 locale:
416 en_US.UTF-8:
417 default: true
Filip Pytlounee1745f2016-04-04 17:39:41 +0200418 "cs_CZ.UTF-8 UTF-8":
Filip Pytlounc49445a2016-04-04 14:23:20 +0200419 enabled: true
420
Andrey Shestakove7cca052017-05-24 23:06:24 +0300421Systemd settings:
422
423.. code-block:: yaml
424
425 linux:
426 system:
427 ...
428 systemd:
429 system:
430 Manager:
431 DefaultLimitNOFILE: 307200
432 DefaultLimitNPROC: 307200
433 user:
434 Manager:
435 DefaultLimitCPU: 2
436 DefaultLimitNPROC: 4
437
Filip Pytloun8b2131e2017-11-08 13:29:03 +0100438Ensure presence of directory:
439
440.. code-block:: yaml
441
442 linux:
443 system:
444 directory:
445 /tmp/test:
446 user: root
447 group: root
448 mode: 700
449 makedirs: true
450
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300451Ensure presence of file by specifying its source:
Richard Felkl2e07d652018-01-19 10:19:06 +0100452
453.. code-block:: yaml
454
455 linux:
456 system:
457 file:
458 /tmp/test.txt:
459 source: http://example.com/test.txt
Richard Felklf40599a2018-02-06 22:56:41 +0100460 user: root #optional
461 group: root #optional
462 mode: 700 #optional
463 dir_mode: 700 #optional
464 encoding: utf-8 #optional
465 hash: <<hash>> or <<URI to hash>> #optional
466 makedirs: true #optional
467
468 linux:
469 system:
470 file:
471 test.txt:
472 name: /tmp/test.txt
473 source: http://example.com/test.txt
Richard Felkl2e07d652018-01-19 10:19:06 +0100474
Gabor Orosz35815c02018-09-07 17:31:05 +0200475 linux:
476 system:
477 file:
478 test2:
479 name: /tmp/test2.txt
480 source: http://example.com/test2.jinja
481 template: jinja
482
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300483Ensure presence of file by specifying its contents:
Richard Felkl2e07d652018-01-19 10:19:06 +0100484
485.. code-block:: yaml
486
487 linux:
488 system:
489 file:
490 /tmp/test.txt:
491 contents: |
492 line1
493 line2
Richard Felklf40599a2018-02-06 22:56:41 +0100494
495 linux:
496 system:
497 file:
498 /tmp/test.txt:
499 contents_pillar: linux:network:hostname
500
501 linux:
502 system:
503 file:
504 /tmp/test.txt:
505 contents_grains: motd
506
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300507Ensure presence of file to be serialized through one of the
508serializer modules (see:
509https://docs.saltstack.com/en/latest/ref/serializers/all/index.html):
Bruno Binet9c2fe222018-06-08 16:57:32 +0200510
511.. code-block:: yaml
512
513 linux:
514 system:
515 file:
516 /tmp/test.json:
517 serialize: json
518 contents:
519 foo: 1
520 bar: 'bar'
521
agoriunovd7b19ce2019-02-18 11:37:32 +0200522Ensure presence of file to be decoded through file.decode module (see:
523https://docs.saltstack.com/en/latest/ref/states/all/salt.states.file.html#salt.states.file.decode):
524
525.. code-block:: yaml
526
527 linux:
528 system:
529 file:
530 /tmp/test4.txt:
531 decode: True
532 encoded_data: |
533 dGVzdDQK
534
Filip Pytloun281034a2016-01-04 18:06:22 +0100535Kernel
536~~~~~~
537
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300538Install always up to date LTS kernel and headers from Ubuntu Trusty:
Filip Pytloun281034a2016-01-04 18:06:22 +0100539
540.. code-block:: yaml
541
542 linux:
543 system:
544 kernel:
545 type: generic
546 lts: trusty
547 headers: true
548
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300549Load kernel modules and add them to ``/etc/modules``:
Tomáš Kukrálba35b212017-02-15 17:59:46 +0100550
551.. code-block:: yaml
552
553 linux:
554 system:
555 kernel:
556 modules:
557 - nf_conntrack
558 - tp_smapi
559 - 8021q
560
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300561Configure or blacklist kernel modules with additional options to
562``/etc/modprobe.d`` following example will add
563``/etc/modprobe.d/nf_conntrack.conf`` file with line
564``options nf_conntrack hashsize=262144``:
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300565
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300566'option' can be a mapping (with 'enabled' and 'value' keys) or a scalar.
567
568Example for 'scalar' option value:
569
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300570.. code-block:: yaml
571
572 linux:
573 system:
574 kernel:
575 module:
576 nf_conntrack:
577 option:
578 hashsize: 262144
579
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300580Example for 'mapping' option value:
581
582.. code-block:: yaml
583
584 linux:
585 system:
586 kernel:
587 module:
588 nf_conntrack:
589 option:
590 hashsize:
591 enabled: true
592 value: 262144
593
594NOTE: 'enabled' key is optional and is True by default.
595
596Blacklist a module:
597
598.. code-block:: yaml
599
600 linux:
601 system:
602 kernel:
603 module:
604 nf_conntrack:
605 blacklist: true
606
607A module can have a number of aliases, wildcards are allowed.
608Define an alias for a module:
609
610.. code-block:: yaml
611
612 linux:
613 system:
614 kernel:
615 module:
616 nf_conntrack:
617 alias:
618 nfct:
619 enabled: true
620 "nf_conn*":
621 enabled: true
622
623NOTE: 'enabled' key is mandatory as there are no other keys exist.
624
625Execute custom command instead of 'insmod' when inserting a module:
626
627.. code-block:: yaml
628
629 linux:
630 system:
631 kernel:
632 module:
633 nf_conntrack:
634 install:
635 enabled: true
636 command: /bin/true
637
638NOTE: 'enabled' key is optional and is True by default.
639
640Execute custom command instead of 'rmmod' when removing a module:
641
642.. code-block:: yaml
643
644 linux:
645 system:
646 kernel:
647 module:
648 nf_conntrack:
649 remove:
650 enabled: true
651 command: /bin/true
652
653NOTE: 'enabled' key is optional and is True by default.
654
655Define module dependencies:
656
657.. code-block:: yaml
658
659 linux:
660 system:
661 kernel:
662 module:
663 nf_conntrack:
664 softdep:
665 pre:
666 1:
667 enabled: true
668 value: a
669 2:
670 enabled: true
671 value: b
672 3:
673 enabled: true
674 value: c
675 post:
676 1:
677 enabled: true
678 value: x
679 2:
680 enabled: true
681 value: y
682 3:
683 enabled: true
684 value: z
685
686NOTE: 'enabled' key is optional and is True by default.
687
688
Filip Pytloun281034a2016-01-04 18:06:22 +0100689Install specific kernel version and ensure all other kernel packages are
690not present. Also install extra modules and headers for this kernel:
691
692.. code-block:: yaml
693
694 linux:
695 system:
696 kernel:
697 type: generic
698 extra: true
699 headers: true
700 version: 4.2.0-22
701
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300702Systcl kernel parameters:
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100703
704.. code-block:: yaml
705
706 linux:
707 system:
708 kernel:
709 sysctl:
710 net.ipv4.tcp_keepalive_intvl: 3
711 net.ipv4.tcp_keepalive_time: 30
712 net.ipv4.tcp_keepalive_probes: 8
713
Michael Polenchukebf55522018-01-25 13:22:39 +0400714Configure kernel boot options:
715
716.. code-block:: yaml
717
718 linux:
719 system:
720 kernel:
721 boot_options:
722 - elevator=deadline
723 - spectre_v2=off
724 - nopti
725
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100726CPU
727~~~
728
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300729Enable cpufreq governor for every cpu:
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100730
731.. code-block:: yaml
732
733 linux:
734 system:
735 cpu:
736 governor: performance
737
Nick Metzf04f5f32018-01-08 15:25:04 +0100738
Jiri Broulik303905d2018-01-11 14:12:48 +0100739CGROUPS
740~~~~~~~
741
742Setup linux cgroups:
743
744.. code-block:: yaml
745
746 linux:
747 system:
748 cgroup:
749 enabled: true
750 group:
751 ceph_group_1:
752 controller:
753 cpu:
754 shares:
755 value: 250
756 cpuacct:
757 usage:
758 value: 0
759 cpuset:
760 cpus:
761 value: 1,2,3
762 memory:
763 limit_in_bytes:
764 value: 2G
765 memsw.limit_in_bytes:
766 value: 3G
767 mapping:
768 subjects:
769 - '@ceph'
770 generic_group_1:
771 controller:
772 cpu:
773 shares:
774 value: 250
775 cpuacct:
776 usage:
777 value: 0
778 mapping:
779 subjects:
780 - '*:firefox'
781 - 'student:cp'
782
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300783Shared libraries
Nick Metzf04f5f32018-01-08 15:25:04 +0100784~~~~~~~~~~~~~~~~
785
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300786Set additional shared library to Linux system library path:
Nick Metzf04f5f32018-01-08 15:25:04 +0100787
788.. code-block:: yaml
789
790 linux:
791 system:
792 ld:
793 library:
794 java:
795 - /usr/lib/jvm/jre-openjdk/lib/amd64/server
796 - /opt/java/jre/lib/amd64/server
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200797
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200798Certificates
799~~~~~~~~~~~~
800
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300801Add certificate authority into system trusted CA bundle:
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200802
803.. code-block:: yaml
804
805 linux:
806 system:
807 ca_certificates:
808 mycert: |
809 -----BEGIN CERTIFICATE-----
810 MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
811 A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
812 cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
813 MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
814 BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
815 YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
816 ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
817 BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
818 I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
819 CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
820 lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
821 AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
822 -----END CERTIFICATE-----
823
Filip Pytloun361096c2017-08-23 10:57:20 +0200824Sysfs
825~~~~~
826
827Install sysfsutils and set sysfs attributes:
828
829.. code-block:: yaml
830
831 linux:
832 system:
833 sysfs:
834 scheduler:
835 block/sda/queue/scheduler: deadline
836 power:
837 mode:
838 power/state: 0660
839 owner:
840 power/state: "root:power"
841 devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
842
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200843Optional: You can also use list that will ensure order of items.
844
845.. code-block:: yaml
846
847 linux:
848 system:
849 sysfs:
850 scheduler:
851 block/sda/queue/scheduler: deadline
852 power:
853 - mode:
854 power/state: 0660
855 - owner:
856 power/state: "root:power"
857 - devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
858
Martin Polreich148e1b82018-09-13 15:54:25 +0200859Sysfs definition with disabled automatic write. Attributes are saved
860to configuration, but are not applied during the run.
861Thay will be applied automatically after the reboot.
862
863
864.. code-block:: yaml
865
866 linux:
867 system:
868 sysfs:
869 enable_apply: false
870 scheduler:
871 block/sda/queue/scheduler: deadline
872
873.. note:: The `enable_apply` parameter defaults to `True` if not defined.
874
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100875Huge Pages
876~~~~~~~~~~~~
877
878Huge Pages give a performance boost to applications that intensively deal
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300879with memory allocation/deallocation by decreasing memory fragmentation:
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100880
881.. code-block:: yaml
882
883 linux:
884 system:
885 kernel:
886 hugepages:
887 small:
888 size: 2M
889 count: 107520
890 mount_point: /mnt/hugepages_2MB
Michael Polenchukd9369fe2018-05-08 17:53:08 +0400891 mount: false/true # default is true (mount immediately) / false (just save in the fstab)
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100892 large:
893 default: true # default automatically mounted
894 size: 1G
895 count: 210
896 mount_point: /mnt/hugepages_1GB
897
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300898.. note:: Not recommended to use both pagesizes concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100899
Jakub Pavlik5398d872017-02-13 22:30:47 +0100900Intel SR-IOV
901~~~~~~~~~~~~
902
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300903PCI-SIG Single Root I/O Virtualization and Sharing (SR-IOV)
904specification defines a standardized mechanism to virtualize
905PCIe devices. The mechanism can virtualize a single PCIe
906Ethernet controller to appear as multiple PCIe devices:
Jakub Pavlik5398d872017-02-13 22:30:47 +0100907
908.. code-block:: yaml
909
910 linux:
911 system:
912 kernel:
913 sriov: True
914 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
915 rc:
916 local: |
917 #!/bin/sh -e
918 # Enable 7 VF on eth1
919 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
920 exit 0
921
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100922Isolate CPU options
923~~~~~~~~~~~~~~~~~~~
924
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300925Remove the specified CPUs, as defined by the cpu_number values, from
926the general kernel SMP balancing and scheduler algroithms. The only
927way to move a process onto or off an *isolated* CPU is via the CPU
928affinity syscalls. ``cpu_number begins`` at ``0``, so the
929maximum value is ``1`` less than the number of CPUs on the system.:
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100930
931.. code-block:: yaml
932
933 linux:
934 system:
935 kernel:
936 isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100937
Filip Pytlounf5383a42015-10-06 16:28:32 +0200938Repositories
939~~~~~~~~~~~~
940
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300941RedHat-based Linux with additional OpenStack repo:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200942
943.. code-block:: yaml
944
945 linux:
946 system:
947 ...
948 repo:
949 rdo-icehouse:
950 enabled: true
951 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
952 pgpcheck: 0
953
954Ensure system repository to use czech Debian mirror (``default: true``)
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300955Also pin it's packages with priority ``900``:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200956
957.. code-block:: yaml
958
959 linux:
960 system:
961 repo:
962 debian:
963 default: true
964 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
965 # Import signing key from URL if needed
966 key_url: "http://dummy.com/public.gpg"
967 pin:
968 - pin: 'origin "ftp.cz.debian.org"'
969 priority: 900
970 package: '*'
971
azvyagintseva3a73d02018-12-06 14:49:58 +0200972Sometimes better to use one pining rule file, to decrease mistaken
973ordering. You can use those option ``system:apt:preferences``, which would add opts into
974``/etc/apt/preferences`` file:
975
976.. code-block:: yaml
977
978 parameters:
979 linux:
980 system:
981 apt:
982 preferences:
983 enabled: true
984 rules:
985 100:
986 enabled: true
987 name: 'some origin pin'
988 pin: 'release o=Debian'
989 priority: 1100
990 package: '*'
991
992
azvyagintsev4494a472018-09-14 19:19:23 +0300993If you need to add multiple pin rules for one repo, please use new,ordered definition format
994('pinning' definition will be in priotity to use):
995
996.. code-block:: yaml
997
998 linux:
999 system:
1000 repo:
1001 mcp_saltstack:
1002 source: "deb [arch=amd64] http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/ xenial main"
1003 architectures: amd64
1004 clean_file: true
1005 pinning:
1006 10:
1007 enabled: true
1008 pin: 'release o=SaltStack'
1009 priority: 50
1010 package: 'libsodium18'
1011 20:
1012 enabled: true
1013 pin: 'release o=SaltStack'
1014 priority: 1100
1015 package: '*'
1016
1017
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001018.. note:: For old Ubuntu releases (<xenial)
azvyagintsevff089d22018-07-27 16:52:34 +02001019 extra packages for apt transport, like ``apt-transport-https``
1020 may be required to be installed manually.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001021 (Chicken-eggs issue: we need to install packages to
azvyagintsevff089d22018-07-27 16:52:34 +02001022 reach repo from where they should be installed)
1023 Otherwise, you still can try 'fortune' and install prereq.packages before
1024 any repo configuration, using list of requires in map.jinja.
1025
1026
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001027Disabling any prerequisite packages installation:
1028
azvyagintsevff089d22018-07-27 16:52:34 +02001029You can simply drop any package pre-installation (before system.linux.repo
1030will be processed) via cluster lvl:
1031
1032.. code-block:: yaml
1033
1034 linux:
1035 system:
1036 pkgs: ~
1037
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001038Package manager proxy global setup:
Petr Michalec10462bb2017-03-23 19:18:08 +01001039
1040.. code-block:: yaml
1041
1042 linux:
1043 system:
1044 ...
1045 repo:
1046 apt-mk:
1047 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1048 ...
1049 proxy:
1050 pkg:
1051 enabled: true
1052 ftp: ftp://ftp-proxy-for-apt.host.local:2121
1053 ...
1054 # NOTE: Global defaults for any other componet that configure proxy on the system.
1055 # If your environment has just one simple proxy, set it on linux:system:proxy.
1056 #
1057 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
1058 # as for https and http
1059 ftp: ftp://proxy.host.local:2121
1060 http: http://proxy.host.local:3142
1061 https: https://proxy.host.local:3143
1062
1063Package manager proxy setup per repository:
1064
1065.. code-block:: yaml
1066
1067 linux:
1068 system:
1069 ...
1070 repo:
1071 debian:
1072 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1073 ...
1074 apt-mk:
1075 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1076 # per repository proxy
1077 proxy:
1078 enabled: true
1079 http: http://maas-01:8080
1080 https: http://maas-01:8080
1081 ...
1082 proxy:
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001083 # package manager fallback defaults
Petr Michalec10462bb2017-03-23 19:18:08 +01001084 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
1085 pkg:
1086 enabled: true
1087 ftp: ftp://proxy.host.local:2121
1088 #http: http://proxy.host.local:3142
1089 #https: https://proxy.host.local:3143
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001090 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001091 # global system fallback system defaults
1092 ftp: ftp://proxy.host.local:2121
1093 http: http://proxy.host.local:3142
1094 https: https://proxy.host.local:3143
1095
Jiri Broulik34a29b42017-04-25 14:42:54 +02001096Remove all repositories:
1097
1098.. code-block:: yaml
1099
1100 linux:
1101 system:
1102 purge_repos: true
1103
azvyagintsevff089d22018-07-27 16:52:34 +02001104Refresh repositories metada, after configuration:
1105
1106.. code-block:: yaml
1107
1108 linux:
1109 system:
1110 refresh_repos_meta: true
1111
Filip Pytlounc512e6c2017-11-22 14:28:10 +01001112Setup custom apt config options:
1113
1114.. code-block:: yaml
1115
1116 linux:
1117 system:
1118 apt:
1119 config:
1120 compression-workaround:
1121 "Acquire::CompressionTypes::Order": "gz"
1122 docker-clean:
1123 "DPkg::Post-Invoke":
1124 - "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"
1125 "APT::Update::Post-Invoke":
1126 - "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 +02001127
Petr Michalec10462bb2017-03-23 19:18:08 +01001128RC
1129~~
1130
Jakub Pavlik78859382016-01-21 11:26:39 +01001131rc.local example
1132
1133.. code-block:: yaml
1134
1135 linux:
1136 system:
1137 rc:
1138 local: |
1139 #!/bin/sh -e
1140 #
1141 # rc.local
1142 #
1143 # This script is executed at the end of each multiuser runlevel.
1144 # Make sure that the script will "exit 0" on success or any other
1145 # value on error.
1146 #
1147 # In order to enable or disable this script just change the execution
1148 # bits.
1149 #
1150 # By default this script does nothing.
1151 exit 0
1152
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001153Prompt
1154~~~~~~
1155
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001156Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``.
1157Every user can have different prompt:
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001158
1159.. code-block:: yaml
1160
1161 linux:
1162 system:
1163 prompt:
1164 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\\]
1165 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
1166
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001167On Debian systems, to set prompt system-wide, it's necessary to
1168remove setting PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc``,
1169which comes from ``/etc/skel/.bashrc``. This formula will do
1170this automatically, but will not touch existing user's
1171``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +01001172
Filip Pytlouneef11c12016-03-25 11:00:23 +01001173Bash
1174~~~~
1175
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001176Fix bash configuration to preserve history across sessions
1177like ZSH does by default:
Filip Pytlouneef11c12016-03-25 11:00:23 +01001178
1179.. code-block:: yaml
1180
1181 linux:
1182 system:
1183 bash:
1184 preserve_history: true
1185
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001186Login banner message
1187~~~~~~~~~~~~~~~~~~~~
1188
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001189``/etc/issue`` is a text file which contains a message or system
1190identification to be printed before the login prompt. It may contain
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001191various @char and \char sequences, if supported by the getty-type
1192program employed on the system.
1193
1194Setting logon banner message is easy:
1195
1196.. code-block:: yaml
1197
1198 liunx:
1199 system:
1200 banner:
1201 enabled: true
1202 contents: |
1203 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1204
1205 You must have explicit, authorized permission to access or configure this
1206 device. Unauthorized attempts and actions to access or use this system may
1207 result in civil and/or criminal penalties.
1208 All activities performed on this system are logged and monitored.
1209
Filip Pytloune874dfb2016-01-22 16:57:34 +01001210Message of the day
1211~~~~~~~~~~~~~~~~~~
1212
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001213``pam_motd`` from package ``libpam-modules`` is used for dynamic
1214messages of the day. Setting custom ``motd`` will clean up existing ones.
Filip Pytloune874dfb2016-01-22 16:57:34 +01001215
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001216Setting static ``motd`` will replace existing ``/etc/motd`` and remove
1217scripts from ``/etc/update-motd.d``.
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001218
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001219Setting static ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001220
1221.. code-block:: yaml
1222
1223 linux:
1224 system:
1225 motd: |
1226 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1227
1228 You must have explicit, authorized permission to access or configure this
1229 device. Unauthorized attempts and actions to access or use this system may
1230 result in civil and/or criminal penalties.
1231 All activities performed on this system are logged and monitored.
1232
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001233Setting dynamic ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001234
Filip Pytloune874dfb2016-01-22 16:57:34 +01001235.. code-block:: yaml
1236
1237 linux:
1238 system:
1239 motd:
1240 - release: |
1241 #!/bin/sh
1242 [ -r /etc/lsb-release ] && . /etc/lsb-release
1243
1244 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
1245 # Fall back to using the very slow lsb_release utility
1246 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
1247 fi
1248
1249 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
1250 - warning: |
1251 #!/bin/sh
1252 printf "This is [company name] network.\n"
1253 printf "Unauthorized access strictly prohibited.\n"
1254
Marek Celoud713e9072017-05-18 15:20:25 +02001255Services
1256~~~~~~~~
1257
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001258Stop and disable the ``linux`` service:
Marek Celoud713e9072017-05-18 15:20:25 +02001259
1260.. code-block:: yaml
1261
1262 linux:
1263 system:
1264 service:
1265 apt-daily.timer:
1266 status: dead
1267
Dzmitry Stremkouski70d09782018-11-30 16:04:59 +01001268Override systemd service unit:
1269
1270.. code-block:: yaml
1271
1272 parameters:
1273
1274 linux:
1275 system:
1276 service:
1277 tgt:
1278 name: tgt
1279 status: running
1280 enabled: True
1281 override:
1282 50:
1283 target: tgt.service.d
1284 name: bind
1285 content: |
1286 [Service]
1287 ExecStart=
1288 ExecStart=/usr/sbin/tgtd -f --iscsi portal=${_param:single_address}:3260
1289
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001290Possible statuses are ``dead`` (disable service by default), ``running``
1291(enable service by default), ``enabled``, ``disabled``:
Marek Celoud713e9072017-05-18 15:20:25 +02001292
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001293Linux with the ``atop`` service:
Serhiy Ovsianikov67bd56a2017-08-11 15:56:01 +03001294
1295.. code-block:: yaml
1296
1297 linux:
1298 system:
1299 atop:
1300 enabled: true
1301 interval: 20
1302 logpath: "/var/log/atop"
1303 outfile: "/var/log/atop/daily.log"
1304
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001305Linux with the ``mcelog`` service:
Oleksii Chupryn144432b2018-05-22 10:34:48 +03001306
1307.. code-block:: yaml
1308
1309 linux:
1310 system:
1311 mcelog:
1312 enabled: true
1313 logging:
1314 syslog: true
1315 syslog_error: true
1316
Filip Pytloun2f70b492016-02-19 15:55:25 +01001317RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +01001318^^^^^^^^^^^^^
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001319Currently, ``update-motd`` is not available
1320for RHEL. So there is no native support for dynamic ``motd``.
1321You can still set a static one, with a different pillar structure:
Filip Pytloun2f70b492016-02-19 15:55:25 +01001322
1323.. code-block:: yaml
1324
1325 linux:
1326 system:
1327 motd: |
1328 This is [company name] network.
1329 Unauthorized access strictly prohibited.
1330
Filip Pytloun8296bb92016-02-19 18:42:09 +01001331Haveged
1332~~~~~~~
1333
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001334If you are running headless server and are low on entropy,
1335you may set up Haveged:
Filip Pytloun8296bb92016-02-19 18:42:09 +01001336
1337.. code-block:: yaml
1338
1339 linux:
1340 system:
1341 haveged:
1342 enabled: true
1343
Filip Pytlounf5383a42015-10-06 16:28:32 +02001344Linux network
1345-------------
1346
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001347Linux with network manager:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001348
1349.. code-block:: yaml
1350
1351 linux:
1352 network:
1353 enabled: true
1354 network_manager: true
1355
Dzmitry Stremkouski00cdbe62018-10-31 16:41:54 +01001356Execute linux.network.interface state without ifupdown activity:
1357
1358.. code-block:: bash
1359
1360 salt-call linux.network.interface pillar='{"linux":{"network":{"noifupdown":True}}}'
1361
1362
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001363Linux with default static network interfaces, default gateway
1364interface and DNS servers:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001365
1366.. code-block:: yaml
1367
1368 linux:
1369 network:
1370 enabled: true
1371 interface:
1372 eth0:
1373 enabled: true
1374 type: eth
1375 address: 192.168.0.102
1376 netmask: 255.255.255.0
1377 gateway: 192.168.0.1
1378 name_servers:
1379 - 8.8.8.8
1380 - 8.8.4.4
1381 mtu: 1500
1382
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001383Linux with bonded interfaces and disabled ``NetworkManager``:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001384
1385.. code-block:: yaml
1386
1387 linux:
1388 network:
1389 enabled: true
1390 interface:
1391 eth0:
1392 type: eth
1393 ...
1394 eth1:
1395 type: eth
1396 ...
1397 bond0:
1398 enabled: true
1399 type: bond
1400 address: 192.168.0.102
1401 netmask: 255.255.255.0
1402 mtu: 1500
1403 use_in:
1404 - interface: ${linux:interface:eth0}
1405 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +01001406 network_manager:
1407 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001408
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001409Linux with VLAN ``interface_params``:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001410
1411.. code-block:: yaml
1412
1413 linux:
1414 network:
1415 enabled: true
1416 interface:
1417 vlan69:
1418 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +01001419 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001420 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001421
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001422Linux with wireless interface parameters:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001423
1424.. code-block:: yaml
1425
1426 linux:
1427 network:
1428 enabled: true
1429 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001430 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001431 interface:
1432 wlan0:
1433 type: eth
1434 wireless:
1435 essid: example
1436 key: example_key
1437 security: wpa
1438 priority: 1
1439
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001440Linux networks with routes defined:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001441
1442.. code-block:: yaml
1443
1444 linux:
1445 network:
1446 enabled: true
1447 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001448 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001449 interface:
1450 eth0:
1451 type: eth
1452 route:
1453 default:
1454 address: 192.168.0.123
1455 netmask: 255.255.255.0
1456 gateway: 192.168.0.1
1457
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001458Native Linux Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001459
1460.. code-block:: yaml
1461
1462 linux:
1463 network:
1464 interface:
1465 eth1:
1466 enabled: true
1467 type: eth
1468 proto: manual
1469 up_cmds:
1470 - ip address add 0/0 dev $IFACE
1471 - ip link set $IFACE up
1472 down_cmds:
1473 - ip link set $IFACE down
1474 br-ex:
1475 enabled: true
1476 type: bridge
1477 address: ${linux:network:host:public_local:address}
1478 netmask: 255.255.255.0
1479 use_interfaces:
1480 - eth1
1481
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001482Open vSwitch Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001483
1484.. code-block:: yaml
1485
1486 linux:
1487 network:
1488 bridge: openvswitch
1489 interface:
1490 eth1:
1491 enabled: true
1492 type: eth
1493 proto: manual
1494 up_cmds:
1495 - ip address add 0/0 dev $IFACE
1496 - ip link set $IFACE up
1497 down_cmds:
1498 - ip link set $IFACE down
1499 br-ex:
1500 enabled: true
1501 type: bridge
1502 address: ${linux:network:host:public_local:address}
1503 netmask: 255.255.255.0
1504 use_interfaces:
1505 - eth1
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001506 br-prv:
1507 enabled: true
1508 type: ovs_bridge
1509 mtu: 65000
1510 br-ens7:
1511 enabled: true
1512 name: br-ens7
1513 type: ovs_bridge
1514 proto: manual
1515 mtu: 9000
1516 use_interfaces:
1517 - ens7
1518 patch-br-ens7-br-prv:
1519 enabled: true
1520 name: ens7-prv
1521 ovs_type: ovs_port
1522 type: ovs_port
1523 bridge: br-ens7
1524 port_type: patch
1525 peer: prv-ens7
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001526 tag: 109 # [] to unset a tag
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001527 mtu: 65000
1528 patch-br-prv-br-ens7:
1529 enabled: true
1530 name: prv-ens7
1531 bridge: br-prv
1532 ovs_type: ovs_port
1533 type: ovs_port
1534 port_type: patch
1535 peer: ens7-prv
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001536 tag: 109
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001537 mtu: 65000
1538 ens7:
1539 enabled: true
1540 name: ens7
1541 proto: manual
1542 ovs_port_type: OVSPort
1543 type: ovs_port
1544 ovs_bridge: br-ens7
1545 bridge: br-ens7
Filip Pytlounf5383a42015-10-06 16:28:32 +02001546
Petr Jediný8f8ae542017-07-13 16:19:12 +02001547Debian manual proto interfaces
1548
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001549When you are changing interface proto from static in up state
1550to manual, you may need to flush ip addresses. For example,
1551if you want to use the interface and the ip on the bridge.
1552This can be done by setting the ``ipflush_onchange`` to true.
Petr Jediný8f8ae542017-07-13 16:19:12 +02001553
1554.. code-block:: yaml
1555
1556 linux:
1557 network:
1558 interface:
1559 eth1:
1560 enabled: true
1561 type: eth
1562 proto: manual
1563 mtu: 9100
1564 ipflush_onchange: true
1565
Jiri Broulik1a191e32018-01-15 15:54:21 +01001566Debian static proto interfaces
1567
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001568When you are changing interface proto from dhcp in up state to
1569static, you may need to flush ip addresses and restart interface
1570to assign ip address from a managed file. For example, if you wantto
1571use the interface and the ip on the bridge. This can be done by
1572setting the ``ipflush_onchange`` with combination ``restart_on_ipflush``
1573param set to true.
Jiri Broulik1a191e32018-01-15 15:54:21 +01001574
1575.. code-block:: yaml
1576
1577 linux:
1578 network:
1579 interface:
1580 eth1:
1581 enabled: true
1582 type: eth
1583 proto: static
1584 address: 10.1.0.22
1585 netmask: 255.255.255.0
1586 ipflush_onchange: true
1587 restart_on_ipflush: true
Petr Jediný8f8ae542017-07-13 16:19:12 +02001588
Petr Jedinýd577cb52017-06-28 20:17:49 +02001589Concatinating and removing interface files
1590
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001591Debian based distributions have ``/etc/network/interfaces.d/``
1592directory, where you can store configuration of network
1593interfaces in separate files. You can concatinate the files
1594to the defined destination when needed, this operation removes
1595the file from the ``/etc/network/interfaces.d/``. If you just need
1596to remove iface files, you can use the ``remove_iface_files`` key.
Petr Jedinýd577cb52017-06-28 20:17:49 +02001597
1598.. code-block:: yaml
1599
1600 linux:
1601 network:
1602 concat_iface_files:
1603 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
1604 dst: '/etc/network/interfaces'
1605 remove_iface_files:
1606 - '/etc/network/interfaces.d/90-custom.cfg'
1607
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001608Configure DHCP client
Petr Jedinýd577cb52017-06-28 20:17:49 +02001609
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001610None of the keys is mandatory, include only those you really need.
1611For full list of available options under send, supersede, prepend,
1612append refer to dhcp-options(5).
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001613
1614.. code-block:: yaml
1615
1616 linux:
1617 network:
1618 dhclient:
1619 enabled: true
1620 backoff_cutoff: 15
1621 initial_interval: 10
1622 reboot: 10
1623 retry: 60
1624 select_timeout: 0
1625 timeout: 120
1626 send:
1627 - option: host-name
1628 declaration: "= gethostname()"
1629 supersede:
1630 - option: host-name
1631 declaration: "spaceship"
1632 - option: domain-name
1633 declaration: "domain.home"
1634 #- option: arp-cache-timeout
1635 # declaration: 20
1636 prepend:
1637 - option: domain-name-servers
1638 declaration:
1639 - 8.8.8.8
1640 - 8.8.4.4
1641 - option: domain-search
1642 declaration:
1643 - example.com
1644 - eng.example.com
1645 #append:
1646 #- option: domain-name-servers
1647 # declaration: 127.0.0.1
1648 # ip or subnet to reject dhcp offer from
1649 reject:
1650 - 192.33.137.209
1651 - 10.0.2.0/24
1652 request:
1653 - subnet-mask
1654 - broadcast-address
1655 - time-offset
1656 - routers
1657 - domain-name
1658 - domain-name-servers
1659 - domain-search
1660 - host-name
1661 - dhcp6.name-servers
1662 - dhcp6.domain-search
1663 - dhcp6.fqdn
1664 - dhcp6.sntp-servers
1665 - netbios-name-servers
1666 - netbios-scope
1667 - interface-mtu
1668 - rfc3442-classless-static-routes
1669 - ntp-servers
1670 require:
1671 - subnet-mask
1672 - domain-name-servers
1673 # if per interface configuration required add below
1674 interface:
1675 ens2:
1676 initial_interval: 11
1677 reject:
1678 - 192.33.137.210
1679 ens3:
1680 initial_interval: 12
1681 reject:
1682 - 192.33.137.211
1683
Petr Michaleceb14b552017-06-01 10:27:05 +02001684Linux network systemd settings:
1685
1686.. code-block:: yaml
1687
1688 linux:
1689 network:
1690 ...
1691 systemd:
1692 link:
1693 10-iface-dmz:
1694 Match:
1695 MACAddress: c8:5b:67:fa:1a:af
1696 OriginalName: eth0
1697 Link:
1698 Name: dmz0
1699 netdev:
1700 20-bridge-dmz:
1701 match:
1702 name: dmz0
1703 network:
1704 mescription: bridge
1705 bridge: br-dmz0
1706 network:
1707 # works with lowercase, keys are by default capitalized
1708 40-dhcp:
1709 match:
1710 name: '*'
1711 network:
1712 DHCP: yes
1713
Petr Michalec10462bb2017-03-23 19:18:08 +01001714Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +01001715
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001716Use ``/etc/environment`` for static system wide variable assignment
1717after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001718
1719.. code-block:: yaml
1720
1721 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +01001722 system:
1723 env:
1724 BOB_VARIABLE: Alice
1725 ...
1726 BOB_PATH:
1727 - /srv/alice/bin
1728 - /srv/bob/bin
1729 ...
1730 ftp_proxy: none
1731 http_proxy: http://global-http-proxy.host.local:8080
1732 https_proxy: ${linux:system:proxy:https}
1733 no_proxy:
1734 - 192.168.0.80
1735 - 192.168.1.80
1736 - .domain.com
1737 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001738 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001739 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001740 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001741 ftp: ftp://proxy.host.local:2121
1742 http: http://proxy.host.local:3142
1743 https: https://proxy.host.local:3143
1744 noproxy:
1745 - .domain.com
1746 - .local
1747
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001748Configure the ``profile.d`` scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001749
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001750The ``profile.d`` scripts are being sourced during ``.sh`` execution
1751and support variable expansion in opposite to /etc/environment global
1752settings in ``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001753
1754.. code-block:: yaml
1755
1756 linux:
1757 system:
1758 profile:
1759 locales: |
1760 export LANG=C
1761 export LC_ALL=C
1762 ...
1763 vi_flavors.sh: |
1764 export PAGER=view
1765 export EDITOR=vim
1766 alias vi=vim
1767 shell_locales.sh: |
1768 export LANG=en_US
1769 export LC_ALL=en_US.UTF-8
1770 shell_proxies.sh: |
1771 export FTP_PROXY=ftp://127.0.3.3:2121
1772 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001773
Dmitry Teselkina0d31d12018-09-04 14:43:09 +03001774
1775Configure login.defs parameters
1776-------------------------------
1777
1778.. code-block:: yaml
1779
1780 linux:
1781 system:
1782 login_defs:
1783 <opt_name>:
1784 enabled: true
1785 value: <opt_value>
1786
1787<opt_name> is a configurational option defined in 'man login.defs'.
1788<opt_name> is case sensitive, should be UPPERCASE only!
1789
1790
Filip Pytlounf5383a42015-10-06 16:28:32 +02001791Linux with hosts
1792
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001793Parameter ``purge_hosts`` will enforce whole ``/etc/hosts file``,
1794removing entries that are not defined in model except defaults
1795for both IPv4 and IPv6 localhost and hostname as well as FQDN.
Ales Komarek417e8c52017-08-25 15:10:29 +02001796
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001797We recommend using this option to verify that ``/etc/hosts``
1798is always in a clean state. However it is not enabled by default
1799for security reasons.
Filip Pytloun86506fe2017-01-26 14:36:16 +01001800
Filip Pytlounf5383a42015-10-06 16:28:32 +02001801.. code-block:: yaml
1802
1803 linux:
1804 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001805 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001806 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001807 # No need to define this one if purge_hosts is true
1808 hostname:
1809 address: 127.0.1.1
1810 names:
1811 - ${linux:network:fqdn}
1812 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001813 node1:
1814 address: 192.168.10.200
1815 names:
1816 - node2.domain.com
1817 - service2.domain.com
1818 node2:
1819 address: 192.168.10.201
1820 names:
1821 - node2.domain.com
1822 - service2.domain.com
1823
Ales Komarek417e8c52017-08-25 15:10:29 +02001824Linux with hosts collected from mine
1825
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001826All DNS records defined within infrastrucuture
1827are passed to the local hosts records or any DNS server. Only
1828hosts with the ``grain`` parameter set to ``true`` will be propagated
1829to the mine.
Ales Komarek417e8c52017-08-25 15:10:29 +02001830
1831.. code-block:: yaml
1832
1833 linux:
1834 network:
1835 purge_hosts: true
1836 mine_dns_records: true
1837 host:
1838 node1:
1839 address: 192.168.10.200
1840 grain: true
1841 names:
1842 - node2.domain.com
1843 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01001844
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001845Set up ``resolvconf's basic resolver info``, e.g. nameservers, search/domain and options:
Filip Pytlounde9bea52016-01-11 15:39:10 +01001846
1847.. code-block:: yaml
1848
1849 linux:
1850 network:
1851 resolv:
1852 dns:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001853 - 8.8.4.4
1854 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01001855 domain: my.example.com
1856 search:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001857 - my.example.com
1858 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01001859 options:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001860 - ndots:5
1861 - timeout:2
1862 - attempts:2
Filip Pytlounde9bea52016-01-11 15:39:10 +01001863
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001864Set up custom TX queue length for tap interfaces:
Andrii Petrenko735761d2017-03-21 17:17:35 -07001865
1866.. code-block:: yaml
1867
1868 linux:
1869 network:
1870 tap_custom_txqueuelen: 10000
1871
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001872DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001873
1874**DPDK OVS NIC**
1875
1876.. code-block:: yaml
1877
1878 linux:
1879 network:
1880 bridge: openvswitch
1881 dpdk:
1882 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001883 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001884 openvswitch:
1885 pmd_cpu_mask: "0x6"
1886 dpdk_socket_mem: "1024,1024"
1887 dpdk_lcore_mask: "0x400"
1888 memory_channels: 2
1889 interface:
1890 dpkd0:
1891 name: ${_param:dpdk_nic}
1892 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001893 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001894 enabled: true
1895 type: dpdk_ovs_port
1896 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001897 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001898 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01001899 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001900 br-prv:
1901 enabled: true
1902 type: dpdk_ovs_bridge
1903
1904**DPDK OVS Bond**
1905
1906.. code-block:: yaml
1907
1908 linux:
1909 network:
1910 bridge: openvswitch
1911 dpdk:
1912 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001913 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001914 openvswitch:
1915 pmd_cpu_mask: "0x6"
1916 dpdk_socket_mem: "1024,1024"
1917 dpdk_lcore_mask: "0x400"
1918 memory_channels: 2
1919 interface:
1920 dpdk_second_nic:
1921 name: ${_param:primary_second_nic}
1922 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001923 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001924 bond: dpdkbond0
1925 enabled: true
1926 type: dpdk_ovs_port
1927 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001928 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001929 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001930 dpdk_first_nic:
1931 name: ${_param:primary_first_nic}
1932 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001933 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001934 bond: dpdkbond0
1935 enabled: true
1936 type: dpdk_ovs_port
1937 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001938 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001939 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001940 dpdkbond0:
1941 enabled: true
1942 bridge: br-prv
1943 type: dpdk_ovs_bond
1944 mode: active-backup
1945 br-prv:
1946 enabled: true
1947 type: dpdk_ovs_bridge
1948
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01001949**DPDK OVS LACP Bond with vlan tag**
1950
1951.. code-block:: yaml
1952
1953 linux:
1954 network:
1955 bridge: openvswitch
1956 dpdk:
1957 enabled: true
1958 driver: uio
1959 openvswitch:
1960 pmd_cpu_mask: "0x6"
1961 dpdk_socket_mem: "1024,1024"
1962 dpdk_lcore_mask: "0x400"
1963 memory_channels: "2"
1964 interface:
1965 eth3:
1966 enabled: true
1967 type: eth
1968 proto: manual
1969 name: ${_param:tenant_first_nic}
1970 eth4:
1971 enabled: true
1972 type: eth
1973 proto: manual
1974 name: ${_param:tenant_second_nic}
1975 dpdk0:
1976 name: ${_param:tenant_first_nic}
1977 pci: "0000:81:00.0"
1978 driver: igb_uio
1979 bond: bond1
1980 enabled: true
1981 type: dpdk_ovs_port
1982 n_rxq: 2
1983 dpdk1:
1984 name: ${_param:tenant_second_nic}
1985 pci: "0000:81:00.1"
1986 driver: igb_uio
1987 bond: bond1
1988 enabled: true
1989 type: dpdk_ovs_port
1990 n_rxq: 2
1991 bond1:
1992 enabled: true
1993 bridge: br-prv
1994 type: dpdk_ovs_bond
1995 mode: balance-slb
1996 br-prv:
1997 enabled: true
1998 type: dpdk_ovs_bridge
1999 tag: ${_param:tenant_vlan}
2000 address: ${_param:tenant_address}
2001 netmask: ${_param:tenant_network_netmask}
2002
Jakub Pavlikaa759062017-03-13 15:57:26 +01002003**DPDK OVS bridge for VXLAN**
2004
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002005If VXLAN is used as tenant segmentation, IP address must
2006be set on ``br-prv``.
Jakub Pavlikaa759062017-03-13 15:57:26 +01002007
2008.. code-block:: yaml
2009
2010 linux:
2011 network:
2012 ...
2013 interface:
2014 br-prv:
2015 enabled: true
2016 type: dpdk_ovs_bridge
2017 address: 192.168.50.0
2018 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04002019 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01002020 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002021
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02002022**DPDK OVS bridge with Linux network interface**
2023
2024.. code-block:: yaml
2025
2026 linux:
2027 network:
2028 ...
2029 interface:
2030 eth0:
2031 type: eth
2032 ovs_bridge: br-prv
2033 ...
2034 br-prv:
2035 enabled: true
2036 type: dpdk_ovs_bridge
2037 ...
2038
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002039Linux storage
2040-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02002041
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002042Linux with mounted Samba:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002043
2044.. code-block:: yaml
2045
2046 linux:
2047 storage:
2048 enabled: true
2049 mount:
2050 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01002051 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02002052 - path: /media/myuser/public/
2053 - device: //192.168.0.1/storage
2054 - file_system: cifs
2055 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
2056
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002057NFS mount:
Jiri Broulikb017f932017-03-31 13:55:36 +02002058
2059.. code-block:: yaml
2060
2061 linux:
2062 storage:
2063 enabled: true
2064 mount:
2065 nfs_glance:
2066 enabled: true
2067 path: /var/lib/glance/images
2068 device: 172.16.10.110:/var/nfs/glance
2069 file_system: nfs
2070 opts: rw,sync
2071
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002072File swap configuration:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002073
2074.. code-block:: yaml
2075
2076 linux:
2077 storage:
2078 enabled: true
2079 swap:
2080 file:
2081 enabled: true
2082 engine: file
2083 device: /swapfile
2084 size: 1024
2085
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002086Partition swap configuration:
Lachlan Evenson30676512016-01-22 15:43:28 -08002087
2088.. code-block:: yaml
2089
2090 linux:
2091 storage:
2092 enabled: true
2093 swap:
2094 partition:
2095 enabled: true
2096 engine: partition
2097 device: /dev/vg0/swap
2098
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002099LVM group ``vg1`` with one device and ``data`` volume mounted
2100into ``/mnt/data``.
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002101
2102.. code-block:: yaml
2103
2104 parameters:
2105 linux:
2106 storage:
2107 mount:
2108 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01002109 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002110 device: /dev/vg1/data
2111 file_system: ext4
2112 path: /mnt/data
2113 lvm:
2114 vg1:
2115 enabled: true
2116 devices:
2117 - /dev/sdb
2118 volume:
2119 data:
2120 size: 40G
2121 mount: ${linux:storage:mount:data}
root40bb5e72019-01-11 08:55:32 +00002122 # When set they will take precedence over filters aget from volume groups.
2123 lvm_filters:
2124 10:
2125 enabled: True
2126 value: "a|loop|"
2127 20:
2128 enabled: True
2129 value: "r|/dev/hdc|"
2130 30:
2131 enabled: True
2132 value: "a|/dev/ide|"
2133 40:
2134 enabled: True
2135 value: "r|.*|"
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002136
Jakub Pavlik4f742142017-08-08 15:05:50 +02002137Create partitions on disk. Specify size in MB. It expects empty
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002138disk without any existing partitions.
2139Set ``startsector=1`` if you want to start partitions from ``2048``.
Jakub Pavlik4f742142017-08-08 15:05:50 +02002140
2141.. code-block:: yaml
2142
2143 linux:
2144 storage:
2145 disk:
2146 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01002147 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02002148 name: /dev/loop1
2149 type: gpt
2150 partitions:
2151 - size: 200 #size in MB
2152 type: fat32
2153 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02002154 mkfs: True
2155 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02002156 /dev/vda1:
2157 partitions:
2158 - size: 5
2159 type: ext2
2160 - size: 10
2161 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02002162
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002163Multipath with Fujitsu Eternus DXL:
Ales Komareka634f4b2016-10-02 13:11:04 +02002164
2165.. code-block:: yaml
2166
2167 parameters:
2168 linux:
2169 storage:
2170 multipath:
2171 enabled: true
2172 blacklist_devices:
2173 - /dev/sda
2174 - /dev/sdb
2175 backends:
2176 - fujitsu_eternus_dxl
2177
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002178Multipath with Hitachi VSP 1000:
Ales Komareka634f4b2016-10-02 13:11:04 +02002179
2180.. code-block:: yaml
2181
2182 parameters:
2183 linux:
2184 storage:
2185 multipath:
2186 enabled: true
2187 blacklist_devices:
2188 - /dev/sda
2189 - /dev/sdb
2190 backends:
2191 - hitachi_vsp1000
2192
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002193Multipath with IBM Storwize:
Ales Komareka634f4b2016-10-02 13:11:04 +02002194
2195.. code-block:: yaml
2196
2197 parameters:
2198 linux:
2199 storage:
2200 multipath:
2201 enabled: true
2202 blacklist_devices:
2203 - /dev/sda
2204 - /dev/sdb
2205 backends:
2206 - ibm_storwize
2207
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002208Multipath with multiple backends:
Ales Komareka634f4b2016-10-02 13:11:04 +02002209
2210.. code-block:: yaml
2211
2212 parameters:
2213 linux:
2214 storage:
2215 multipath:
2216 enabled: true
2217 blacklist_devices:
2218 - /dev/sda
2219 - /dev/sdb
2220 - /dev/sdc
2221 - /dev/sdd
2222 backends:
2223 - ibm_storwize
2224 - fujitsu_eternus_dxl
2225 - hitachi_vsp1000
2226
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002227PAM LDAP integration:
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002228
2229.. code-block:: yaml
2230
2231 parameters:
2232 linux:
2233 system:
2234 auth:
2235 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02002236 mkhomedir:
2237 enabled: true
2238 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002239 ldap:
2240 enabled: true
2241 binddn: cn=bind,ou=service_users,dc=example,dc=com
2242 bindpw: secret
2243 uri: ldap://127.0.0.1
2244 base: ou=users,dc=example,dc=com
2245 ldap_version: 3
2246 pagesize: 65536
2247 referrals: off
2248 filter:
2249 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2250 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2251 group: (&(objectClass=group)(gidNumber=*))
2252
Gleb Galkin93b9ae92018-10-18 13:57:30 +03002253PAM duo 2FA integration
2254
2255.. code-block:: yaml
2256
2257 parameters:
2258 linux:
2259 system:
2260 auth:
2261 enabled: true
2262 duo:
2263 enabled: true
2264 duo_host: localhost
2265 duo_ikey: DUO-INTEGRATION-KEY
2266 duo_skey: DUO-SECRET-KEY
2267
2268duo package version may be specified (optional)
2269
2270.. code-block:: yaml
2271
2272 linux:
2273 system:
2274 package:
2275 duo-unix:
2276 version: 1.10.1-0
2277
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002278Disabled multipath (the default setup):
Ales Komareka634f4b2016-10-02 13:11:04 +02002279
2280.. code-block:: yaml
2281
2282 parameters:
2283 linux:
2284 storage:
2285 multipath:
2286 enabled: false
2287
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002288Linux with local loopback device:
Simon Pasquier375001e2017-01-26 13:22:33 +01002289
2290.. code-block:: yaml
2291
2292 linux:
2293 storage:
2294 loopback:
2295 disk1:
2296 file: /srv/disk1
2297 size: 50G
2298
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002299External config generation
2300--------------------------
2301
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002302You are able to use config support metadata between formulas
2303and only generate configuration files for external use, for example, Docker, and so on.
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002304
2305.. code-block:: yaml
2306
2307 parameters:
2308 linux:
2309 system:
2310 config:
2311 pillar:
2312 jenkins:
2313 master:
2314 home: /srv/volumes/jenkins
2315 approved_scripts:
2316 - method java.net.URL openConnection
2317 credentials:
2318 - type: username_password
2319 scope: global
2320 id: test
2321 desc: Testing credentials
2322 username: test
2323 password: test
2324
Vladimir Ereminccf28842017-04-10 23:52:10 +03002325Netconsole Remote Kernel Logging
2326--------------------------------
2327
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002328Netconsole logger can be configured for the configfs-enabled kernels
2329(``CONFIG_NETCONSOLE_DYNAMIC`` must be enabled). The configuration
2330applies both in runtime (if network is already configured),
2331and on-boot after an interface initialization.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002332
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002333.. note::
2334
2335 * Receiver can be located only on the same L3 domain
2336 (or you need to configure gateway MAC manually).
2337 * The Receiver MAC is detected only on configuration time.
2338 * Using broadcast MAC is not recommended.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002339
2340.. code-block:: yaml
2341
2342 parameters:
2343 linux:
2344 system:
2345 netconsole:
2346 enabled: true
2347 port: 514 (optional)
2348 loglevel: debug (optional)
2349 target:
2350 192.168.0.1:
2351 interface: bond0
2352 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02002353
Dzmitry Stremkouskid1a268b2018-10-03 16:36:04 +02002354Check network params on the environment
2355---------------------------------------
2356
2357Grab nics and nics states
2358
2359.. code-block:: bash
2360
2361 salt osd001\* net_checks.get_nics
2362
2363**Example of system output:**
2364
2365.. code-block:: bash
2366
2367 osd001.domain.com:
2368 |_
2369 - bond0
2370 - None
2371 - 1e:c8:64:42:23:b9
2372 - 0
2373 - 1500
2374 |_
2375 - bond1
2376 - None
2377 - 3c:fd:fe:27:3b:00
2378 - 1
2379 - 9100
2380 |_
2381 - fourty1
2382 - None
2383 - 3c:fd:fe:27:3b:00
2384 - 1
2385 - 9100
2386 |_
2387 - fourty2
2388 - None
2389 - 3c:fd:fe:27:3b:02
2390 - 1
2391 - 9100
2392
2393Grab 10G nics PCI addresses for hugepages setup
2394
2395.. code-block:: bash
2396
2397 salt cmp001\* net_checks.get_ten_pci
2398
2399**Example of system output:**
2400
2401.. code-block:: bash
2402
2403 cmp001.domain.com:
2404 |_
2405 - ten1
2406 - 0000:19:00.0
2407 |_
2408 - ten2
2409 - 0000:19:00.1
2410 |_
2411 - ten3
2412 - 0000:19:00.2
2413 |_
2414 - ten4
2415 - 0000:19:00.3
2416
2417Grab ip address for an interface
2418
2419.. code-block:: bash
2420
2421 salt cmp001\* net_checks.get_ip iface=one4
2422
2423**Example of system output:**
2424
2425.. code-block:: bash
2426
2427 cmp001.domain.com:
2428 10.200.177.101
2429
2430Grab ip addresses map
2431
2432.. code-block:: bash
2433
2434 salt-call net_checks.nodes_addresses
2435
2436**Example of system output:**
2437
2438.. code-block:: bash
2439
2440 local:
2441 |_
2442 - cid01.domain.com
2443 |_
2444 |_
2445 - pxe
2446 - 10.200.177.91
2447 |_
2448 - control
2449 - 10.200.178.91
2450 |_
2451 - cmn02.domain.com
2452 |_
2453 |_
2454 - storage_access
2455 - 10.200.181.67
2456 |_
2457 - pxe
2458 - 10.200.177.67
2459 |_
2460 - control
2461 - 10.200.178.67
2462 |_
2463 - cmp010.domain.com
2464 |_
2465 |_
2466 - pxe
2467 - 10.200.177.110
2468 |_
2469 - storage_access
2470 - 10.200.181.110
2471 |_
2472 - control
2473 - 10.200.178.110
2474 |_
2475 - vxlan
2476 - 10.200.179.110
2477
2478Verify full mesh connectivity
2479
2480.. code-block:: bash
2481
2482 salt-call net_checks.ping_check
2483
2484**Example of positive system output:**
2485
2486.. code-block:: bash
2487
2488 ['PASSED']
2489 [INFO ] ['PASSED']
2490 local:
2491 True
2492
2493**Example of system output in case of failure:**
2494
2495.. code-block:: bash
2496
2497 FAILED
2498 [ERROR ] FAILED
2499 ['control: 10.0.1.92 -> 10.0.1.224: Failed']
2500 ['control: 10.0.1.93 -> 10.0.1.224: Failed']
2501 ['control: 10.0.1.51 -> 10.0.1.224: Failed']
2502 ['control: 10.0.1.102 -> 10.0.1.224: Failed']
2503 ['control: 10.0.1.13 -> 10.0.1.224: Failed']
2504 ['control: 10.0.1.81 -> 10.0.1.224: Failed']
2505 local:
2506 False
2507
2508For this feature to work, please mark addresses with some role.
2509Otherwise 'default' role is assumed and mesh would consist of all
2510addresses on the environment.
2511
2512Mesh mark is needed only for interfaces which are enabled and have
2513ip address assigned.
2514
2515Checking dhcp pxe network meaningless, as it is used for salt
2516master vs minion communications, therefore treated as checked.
2517
2518.. code-block:: yaml
2519
2520 parameters:
2521 linux:
2522 network:
2523 interface:
2524 ens3:
2525 enabled: true
2526 type: eth
2527 proto: static
2528 address: ${_param:deploy_address}
2529 netmask: ${_param:deploy_network_netmask}
2530 gateway: ${_param:deploy_network_gateway}
2531 mesh: pxe
2532
2533Check pillars for ip address duplicates
2534
2535.. code-block:: bash
2536
2537 salt-call net_checks.verify_addresses
2538
2539**Example of positive system output:**
2540
2541.. code-block:: bash
2542
2543 ['PASSED']
2544 [INFO ] ['PASSED']
2545 local:
2546 True
2547
2548**Example of system output in case of failure:**
2549
2550.. code-block:: bash
2551
2552 FAILED. Duplicates found
2553 [ERROR ] FAILED. Duplicates found
2554 ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2555 [ERROR ] ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2556 local:
2557 False
2558
2559Generate csv report for the env
2560
2561.. code-block:: bash
2562
2563 salt -C 'kvm* or cmp* or osd*' net_checks.get_nics_csv \
2564 | grep '^\ ' | sed 's/\ *//g' | grep -Ev ^server \
2565 | sed '1 i\server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr'
2566
2567**Example of system output:**
2568
2569.. code-block:: bash
2570
2571 server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr
2572 cmp010.domain.com,bond0,None,b4:96:91:10:5b:3a,1,1500,,,,
2573 cmp010.domain.com,bond0.21,10.200.178.110,b4:96:91:10:5b:3a,1,1500,,,,
2574 cmp010.domain.com,bond0.22,10.200.179.110,b4:96:91:10:5b:3a,1,1500,,,,
2575 cmp010.domain.com,bond1,None,3c:fd:fe:34:ad:22,0,1500,,,,
2576 cmp010.domain.com,bond1.24,10.200.181.110,3c:fd:fe:34:ad:22,0,1500,,,,
2577 cmp010.domain.com,fourty5,None,3c:fd:fe:34:ad:20,0,9000,,,,
2578 cmp010.domain.com,fourty6,None,3c:fd:fe:34:ad:22,0,9000,,,,
2579 cmp010.domain.com,one1,None,b4:96:91:10:5b:38,0,1500,,,,
2580 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
2581 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
2582 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
2583 cmp011.domain.com,bond0,None,b4:96:91:13:6c:aa,1,1500,,,,
2584 cmp011.domain.com,bond0.21,10.200.178.111,b4:96:91:13:6c:aa,1,1500,,,,
2585 cmp011.domain.com,bond0.22,10.200.179.111,b4:96:91:13:6c:aa,1,1500,,,,
2586 ...
2587
Filip Pytlounf5383a42015-10-06 16:28:32 +02002588Usage
2589=====
2590
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002591Set MTU of the eth0 network interface to 1400:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002592
2593.. code-block:: bash
2594
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002595 ip link set dev eth0 mtu 1400
Filip Pytlounf5383a42015-10-06 16:28:32 +02002596
2597Read more
2598=========
2599
2600* https://www.archlinux.org/
2601* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu