blob: dad1aaa6c46b0ff1666de1f75b2f612dff0e4204 [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
Filip Pytloun281034a2016-01-04 18:06:22 +0100522Kernel
523~~~~~~
524
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300525Install always up to date LTS kernel and headers from Ubuntu Trusty:
Filip Pytloun281034a2016-01-04 18:06:22 +0100526
527.. code-block:: yaml
528
529 linux:
530 system:
531 kernel:
532 type: generic
533 lts: trusty
534 headers: true
535
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300536Load kernel modules and add them to ``/etc/modules``:
Tomáš Kukrálba35b212017-02-15 17:59:46 +0100537
538.. code-block:: yaml
539
540 linux:
541 system:
542 kernel:
543 modules:
544 - nf_conntrack
545 - tp_smapi
546 - 8021q
547
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300548Configure or blacklist kernel modules with additional options to
549``/etc/modprobe.d`` following example will add
550``/etc/modprobe.d/nf_conntrack.conf`` file with line
551``options nf_conntrack hashsize=262144``:
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300552
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300553'option' can be a mapping (with 'enabled' and 'value' keys) or a scalar.
554
555Example for 'scalar' option value:
556
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300557.. code-block:: yaml
558
559 linux:
560 system:
561 kernel:
562 module:
563 nf_conntrack:
564 option:
565 hashsize: 262144
566
Dmitry Teselkin809834c2018-08-13 19:14:42 +0300567Example for 'mapping' option value:
568
569.. code-block:: yaml
570
571 linux:
572 system:
573 kernel:
574 module:
575 nf_conntrack:
576 option:
577 hashsize:
578 enabled: true
579 value: 262144
580
581NOTE: 'enabled' key is optional and is True by default.
582
583Blacklist a module:
584
585.. code-block:: yaml
586
587 linux:
588 system:
589 kernel:
590 module:
591 nf_conntrack:
592 blacklist: true
593
594A module can have a number of aliases, wildcards are allowed.
595Define an alias for a module:
596
597.. code-block:: yaml
598
599 linux:
600 system:
601 kernel:
602 module:
603 nf_conntrack:
604 alias:
605 nfct:
606 enabled: true
607 "nf_conn*":
608 enabled: true
609
610NOTE: 'enabled' key is mandatory as there are no other keys exist.
611
612Execute custom command instead of 'insmod' when inserting a module:
613
614.. code-block:: yaml
615
616 linux:
617 system:
618 kernel:
619 module:
620 nf_conntrack:
621 install:
622 enabled: true
623 command: /bin/true
624
625NOTE: 'enabled' key is optional and is True by default.
626
627Execute custom command instead of 'rmmod' when removing a module:
628
629.. code-block:: yaml
630
631 linux:
632 system:
633 kernel:
634 module:
635 nf_conntrack:
636 remove:
637 enabled: true
638 command: /bin/true
639
640NOTE: 'enabled' key is optional and is True by default.
641
642Define module dependencies:
643
644.. code-block:: yaml
645
646 linux:
647 system:
648 kernel:
649 module:
650 nf_conntrack:
651 softdep:
652 pre:
653 1:
654 enabled: true
655 value: a
656 2:
657 enabled: true
658 value: b
659 3:
660 enabled: true
661 value: c
662 post:
663 1:
664 enabled: true
665 value: x
666 2:
667 enabled: true
668 value: y
669 3:
670 enabled: true
671 value: z
672
673NOTE: 'enabled' key is optional and is True by default.
674
675
Filip Pytloun281034a2016-01-04 18:06:22 +0100676Install specific kernel version and ensure all other kernel packages are
677not present. Also install extra modules and headers for this kernel:
678
679.. code-block:: yaml
680
681 linux:
682 system:
683 kernel:
684 type: generic
685 extra: true
686 headers: true
687 version: 4.2.0-22
688
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300689Systcl kernel parameters:
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100690
691.. code-block:: yaml
692
693 linux:
694 system:
695 kernel:
696 sysctl:
697 net.ipv4.tcp_keepalive_intvl: 3
698 net.ipv4.tcp_keepalive_time: 30
699 net.ipv4.tcp_keepalive_probes: 8
700
Michael Polenchukebf55522018-01-25 13:22:39 +0400701Configure kernel boot options:
702
703.. code-block:: yaml
704
705 linux:
706 system:
707 kernel:
708 boot_options:
709 - elevator=deadline
710 - spectre_v2=off
711 - nopti
712
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100713CPU
714~~~
715
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300716Enable cpufreq governor for every cpu:
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100717
718.. code-block:: yaml
719
720 linux:
721 system:
722 cpu:
723 governor: performance
724
Nick Metzf04f5f32018-01-08 15:25:04 +0100725
Jiri Broulik303905d2018-01-11 14:12:48 +0100726CGROUPS
727~~~~~~~
728
729Setup linux cgroups:
730
731.. code-block:: yaml
732
733 linux:
734 system:
735 cgroup:
736 enabled: true
737 group:
738 ceph_group_1:
739 controller:
740 cpu:
741 shares:
742 value: 250
743 cpuacct:
744 usage:
745 value: 0
746 cpuset:
747 cpus:
748 value: 1,2,3
749 memory:
750 limit_in_bytes:
751 value: 2G
752 memsw.limit_in_bytes:
753 value: 3G
754 mapping:
755 subjects:
756 - '@ceph'
757 generic_group_1:
758 controller:
759 cpu:
760 shares:
761 value: 250
762 cpuacct:
763 usage:
764 value: 0
765 mapping:
766 subjects:
767 - '*:firefox'
768 - 'student:cp'
769
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300770Shared libraries
Nick Metzf04f5f32018-01-08 15:25:04 +0100771~~~~~~~~~~~~~~~~
772
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300773Set additional shared library to Linux system library path:
Nick Metzf04f5f32018-01-08 15:25:04 +0100774
775.. code-block:: yaml
776
777 linux:
778 system:
779 ld:
780 library:
781 java:
782 - /usr/lib/jvm/jre-openjdk/lib/amd64/server
783 - /opt/java/jre/lib/amd64/server
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200784
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200785Certificates
786~~~~~~~~~~~~
787
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300788Add certificate authority into system trusted CA bundle:
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200789
790.. code-block:: yaml
791
792 linux:
793 system:
794 ca_certificates:
795 mycert: |
796 -----BEGIN CERTIFICATE-----
797 MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
798 A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
799 cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
800 MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
801 BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
802 YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
803 ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
804 BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
805 I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
806 CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
807 lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
808 AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
809 -----END CERTIFICATE-----
810
Filip Pytloun361096c2017-08-23 10:57:20 +0200811Sysfs
812~~~~~
813
814Install sysfsutils and set sysfs attributes:
815
816.. code-block:: yaml
817
818 linux:
819 system:
820 sysfs:
821 scheduler:
822 block/sda/queue/scheduler: deadline
823 power:
824 mode:
825 power/state: 0660
826 owner:
827 power/state: "root:power"
828 devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
829
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200830Optional: You can also use list that will ensure order of items.
831
832.. code-block:: yaml
833
834 linux:
835 system:
836 sysfs:
837 scheduler:
838 block/sda/queue/scheduler: deadline
839 power:
840 - mode:
841 power/state: 0660
842 - owner:
843 power/state: "root:power"
844 - devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
845
Martin Polreich148e1b82018-09-13 15:54:25 +0200846Sysfs definition with disabled automatic write. Attributes are saved
847to configuration, but are not applied during the run.
848Thay will be applied automatically after the reboot.
849
850
851.. code-block:: yaml
852
853 linux:
854 system:
855 sysfs:
856 enable_apply: false
857 scheduler:
858 block/sda/queue/scheduler: deadline
859
860.. note:: The `enable_apply` parameter defaults to `True` if not defined.
861
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100862Huge Pages
863~~~~~~~~~~~~
864
865Huge Pages give a performance boost to applications that intensively deal
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300866with memory allocation/deallocation by decreasing memory fragmentation:
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100867
868.. code-block:: yaml
869
870 linux:
871 system:
872 kernel:
873 hugepages:
874 small:
875 size: 2M
876 count: 107520
877 mount_point: /mnt/hugepages_2MB
Michael Polenchukd9369fe2018-05-08 17:53:08 +0400878 mount: false/true # default is true (mount immediately) / false (just save in the fstab)
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100879 large:
880 default: true # default automatically mounted
881 size: 1G
882 count: 210
883 mount_point: /mnt/hugepages_1GB
884
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300885.. note:: Not recommended to use both pagesizes concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100886
Jakub Pavlik5398d872017-02-13 22:30:47 +0100887Intel SR-IOV
888~~~~~~~~~~~~
889
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300890PCI-SIG Single Root I/O Virtualization and Sharing (SR-IOV)
891specification defines a standardized mechanism to virtualize
892PCIe devices. The mechanism can virtualize a single PCIe
893Ethernet controller to appear as multiple PCIe devices:
Jakub Pavlik5398d872017-02-13 22:30:47 +0100894
895.. code-block:: yaml
896
897 linux:
898 system:
899 kernel:
900 sriov: True
901 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
902 rc:
903 local: |
904 #!/bin/sh -e
905 # Enable 7 VF on eth1
906 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
907 exit 0
908
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100909Isolate CPU options
910~~~~~~~~~~~~~~~~~~~
911
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300912Remove the specified CPUs, as defined by the cpu_number values, from
913the general kernel SMP balancing and scheduler algroithms. The only
914way to move a process onto or off an *isolated* CPU is via the CPU
915affinity syscalls. ``cpu_number begins`` at ``0``, so the
916maximum value is ``1`` less than the number of CPUs on the system.:
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100917
918.. code-block:: yaml
919
920 linux:
921 system:
922 kernel:
923 isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100924
Filip Pytlounf5383a42015-10-06 16:28:32 +0200925Repositories
926~~~~~~~~~~~~
927
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300928RedHat-based Linux with additional OpenStack repo:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200929
930.. code-block:: yaml
931
932 linux:
933 system:
934 ...
935 repo:
936 rdo-icehouse:
937 enabled: true
938 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
939 pgpcheck: 0
940
941Ensure system repository to use czech Debian mirror (``default: true``)
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300942Also pin it's packages with priority ``900``:
Filip Pytlounf5383a42015-10-06 16:28:32 +0200943
944.. code-block:: yaml
945
946 linux:
947 system:
948 repo:
949 debian:
950 default: true
951 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
952 # Import signing key from URL if needed
953 key_url: "http://dummy.com/public.gpg"
954 pin:
955 - pin: 'origin "ftp.cz.debian.org"'
956 priority: 900
957 package: '*'
958
azvyagintseva3a73d02018-12-06 14:49:58 +0200959Sometimes better to use one pining rule file, to decrease mistaken
960ordering. You can use those option ``system:apt:preferences``, which would add opts into
961``/etc/apt/preferences`` file:
962
963.. code-block:: yaml
964
965 parameters:
966 linux:
967 system:
968 apt:
969 preferences:
970 enabled: true
971 rules:
972 100:
973 enabled: true
974 name: 'some origin pin'
975 pin: 'release o=Debian'
976 priority: 1100
977 package: '*'
978
979
azvyagintsev4494a472018-09-14 19:19:23 +0300980If you need to add multiple pin rules for one repo, please use new,ordered definition format
981('pinning' definition will be in priotity to use):
982
983.. code-block:: yaml
984
985 linux:
986 system:
987 repo:
988 mcp_saltstack:
989 source: "deb [arch=amd64] http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/ xenial main"
990 architectures: amd64
991 clean_file: true
992 pinning:
993 10:
994 enabled: true
995 pin: 'release o=SaltStack'
996 priority: 50
997 package: 'libsodium18'
998 20:
999 enabled: true
1000 pin: 'release o=SaltStack'
1001 priority: 1100
1002 package: '*'
1003
1004
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001005.. note:: For old Ubuntu releases (<xenial)
azvyagintsevff089d22018-07-27 16:52:34 +02001006 extra packages for apt transport, like ``apt-transport-https``
1007 may be required to be installed manually.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001008 (Chicken-eggs issue: we need to install packages to
azvyagintsevff089d22018-07-27 16:52:34 +02001009 reach repo from where they should be installed)
1010 Otherwise, you still can try 'fortune' and install prereq.packages before
1011 any repo configuration, using list of requires in map.jinja.
1012
1013
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001014Disabling any prerequisite packages installation:
1015
azvyagintsevff089d22018-07-27 16:52:34 +02001016You can simply drop any package pre-installation (before system.linux.repo
1017will be processed) via cluster lvl:
1018
1019.. code-block:: yaml
1020
1021 linux:
1022 system:
1023 pkgs: ~
1024
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001025Package manager proxy global setup:
Petr Michalec10462bb2017-03-23 19:18:08 +01001026
1027.. code-block:: yaml
1028
1029 linux:
1030 system:
1031 ...
1032 repo:
1033 apt-mk:
1034 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1035 ...
1036 proxy:
1037 pkg:
1038 enabled: true
1039 ftp: ftp://ftp-proxy-for-apt.host.local:2121
1040 ...
1041 # NOTE: Global defaults for any other componet that configure proxy on the system.
1042 # If your environment has just one simple proxy, set it on linux:system:proxy.
1043 #
1044 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
1045 # as for https and http
1046 ftp: ftp://proxy.host.local:2121
1047 http: http://proxy.host.local:3142
1048 https: https://proxy.host.local:3143
1049
1050Package manager proxy setup per repository:
1051
1052.. code-block:: yaml
1053
1054 linux:
1055 system:
1056 ...
1057 repo:
1058 debian:
1059 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1060 ...
1061 apt-mk:
1062 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1063 # per repository proxy
1064 proxy:
1065 enabled: true
1066 http: http://maas-01:8080
1067 https: http://maas-01:8080
1068 ...
1069 proxy:
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001070 # package manager fallback defaults
Petr Michalec10462bb2017-03-23 19:18:08 +01001071 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
1072 pkg:
1073 enabled: true
1074 ftp: ftp://proxy.host.local:2121
1075 #http: http://proxy.host.local:3142
1076 #https: https://proxy.host.local:3143
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001077 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001078 # global system fallback system defaults
1079 ftp: ftp://proxy.host.local:2121
1080 http: http://proxy.host.local:3142
1081 https: https://proxy.host.local:3143
1082
Jiri Broulik34a29b42017-04-25 14:42:54 +02001083Remove all repositories:
1084
1085.. code-block:: yaml
1086
1087 linux:
1088 system:
1089 purge_repos: true
1090
azvyagintsevff089d22018-07-27 16:52:34 +02001091Refresh repositories metada, after configuration:
1092
1093.. code-block:: yaml
1094
1095 linux:
1096 system:
1097 refresh_repos_meta: true
1098
Filip Pytlounc512e6c2017-11-22 14:28:10 +01001099Setup custom apt config options:
1100
1101.. code-block:: yaml
1102
1103 linux:
1104 system:
1105 apt:
1106 config:
1107 compression-workaround:
1108 "Acquire::CompressionTypes::Order": "gz"
1109 docker-clean:
1110 "DPkg::Post-Invoke":
1111 - "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"
1112 "APT::Update::Post-Invoke":
1113 - "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 +02001114
Petr Michalec10462bb2017-03-23 19:18:08 +01001115RC
1116~~
1117
Jakub Pavlik78859382016-01-21 11:26:39 +01001118rc.local example
1119
1120.. code-block:: yaml
1121
1122 linux:
1123 system:
1124 rc:
1125 local: |
1126 #!/bin/sh -e
1127 #
1128 # rc.local
1129 #
1130 # This script is executed at the end of each multiuser runlevel.
1131 # Make sure that the script will "exit 0" on success or any other
1132 # value on error.
1133 #
1134 # In order to enable or disable this script just change the execution
1135 # bits.
1136 #
1137 # By default this script does nothing.
1138 exit 0
1139
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001140Prompt
1141~~~~~~
1142
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001143Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``.
1144Every user can have different prompt:
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001145
1146.. code-block:: yaml
1147
1148 linux:
1149 system:
1150 prompt:
1151 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\\]
1152 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
1153
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001154On Debian systems, to set prompt system-wide, it's necessary to
1155remove setting PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc``,
1156which comes from ``/etc/skel/.bashrc``. This formula will do
1157this automatically, but will not touch existing user's
1158``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +01001159
Filip Pytlouneef11c12016-03-25 11:00:23 +01001160Bash
1161~~~~
1162
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001163Fix bash configuration to preserve history across sessions
1164like ZSH does by default:
Filip Pytlouneef11c12016-03-25 11:00:23 +01001165
1166.. code-block:: yaml
1167
1168 linux:
1169 system:
1170 bash:
1171 preserve_history: true
1172
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001173Login banner message
1174~~~~~~~~~~~~~~~~~~~~
1175
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001176``/etc/issue`` is a text file which contains a message or system
1177identification to be printed before the login prompt. It may contain
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001178various @char and \char sequences, if supported by the getty-type
1179program employed on the system.
1180
1181Setting logon banner message is easy:
1182
1183.. code-block:: yaml
1184
1185 liunx:
1186 system:
1187 banner:
1188 enabled: true
1189 contents: |
1190 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1191
1192 You must have explicit, authorized permission to access or configure this
1193 device. Unauthorized attempts and actions to access or use this system may
1194 result in civil and/or criminal penalties.
1195 All activities performed on this system are logged and monitored.
1196
Filip Pytloune874dfb2016-01-22 16:57:34 +01001197Message of the day
1198~~~~~~~~~~~~~~~~~~
1199
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001200``pam_motd`` from package ``libpam-modules`` is used for dynamic
1201messages of the day. Setting custom ``motd`` will clean up existing ones.
Filip Pytloune874dfb2016-01-22 16:57:34 +01001202
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001203Setting static ``motd`` will replace existing ``/etc/motd`` and remove
1204scripts from ``/etc/update-motd.d``.
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001205
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001206Setting static ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001207
1208.. code-block:: yaml
1209
1210 linux:
1211 system:
1212 motd: |
1213 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1214
1215 You must have explicit, authorized permission to access or configure this
1216 device. Unauthorized attempts and actions to access or use this system may
1217 result in civil and/or criminal penalties.
1218 All activities performed on this system are logged and monitored.
1219
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001220Setting dynamic ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001221
Filip Pytloune874dfb2016-01-22 16:57:34 +01001222.. code-block:: yaml
1223
1224 linux:
1225 system:
1226 motd:
1227 - release: |
1228 #!/bin/sh
1229 [ -r /etc/lsb-release ] && . /etc/lsb-release
1230
1231 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
1232 # Fall back to using the very slow lsb_release utility
1233 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
1234 fi
1235
1236 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
1237 - warning: |
1238 #!/bin/sh
1239 printf "This is [company name] network.\n"
1240 printf "Unauthorized access strictly prohibited.\n"
1241
Marek Celoud713e9072017-05-18 15:20:25 +02001242Services
1243~~~~~~~~
1244
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001245Stop and disable the ``linux`` service:
Marek Celoud713e9072017-05-18 15:20:25 +02001246
1247.. code-block:: yaml
1248
1249 linux:
1250 system:
1251 service:
1252 apt-daily.timer:
1253 status: dead
1254
Dzmitry Stremkouski70d09782018-11-30 16:04:59 +01001255Override systemd service unit:
1256
1257.. code-block:: yaml
1258
1259 parameters:
1260
1261 linux:
1262 system:
1263 service:
1264 tgt:
1265 name: tgt
1266 status: running
1267 enabled: True
1268 override:
1269 50:
1270 target: tgt.service.d
1271 name: bind
1272 content: |
1273 [Service]
1274 ExecStart=
1275 ExecStart=/usr/sbin/tgtd -f --iscsi portal=${_param:single_address}:3260
1276
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001277Possible statuses are ``dead`` (disable service by default), ``running``
1278(enable service by default), ``enabled``, ``disabled``:
Marek Celoud713e9072017-05-18 15:20:25 +02001279
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001280Linux with the ``atop`` service:
Serhiy Ovsianikov67bd56a2017-08-11 15:56:01 +03001281
1282.. code-block:: yaml
1283
1284 linux:
1285 system:
1286 atop:
1287 enabled: true
1288 interval: 20
1289 logpath: "/var/log/atop"
1290 outfile: "/var/log/atop/daily.log"
1291
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001292Linux with the ``mcelog`` service:
Oleksii Chupryn144432b2018-05-22 10:34:48 +03001293
1294.. code-block:: yaml
1295
1296 linux:
1297 system:
1298 mcelog:
1299 enabled: true
1300 logging:
1301 syslog: true
1302 syslog_error: true
1303
Filip Pytloun2f70b492016-02-19 15:55:25 +01001304RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +01001305^^^^^^^^^^^^^
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001306Currently, ``update-motd`` is not available
1307for RHEL. So there is no native support for dynamic ``motd``.
1308You can still set a static one, with a different pillar structure:
Filip Pytloun2f70b492016-02-19 15:55:25 +01001309
1310.. code-block:: yaml
1311
1312 linux:
1313 system:
1314 motd: |
1315 This is [company name] network.
1316 Unauthorized access strictly prohibited.
1317
Filip Pytloun8296bb92016-02-19 18:42:09 +01001318Haveged
1319~~~~~~~
1320
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001321If you are running headless server and are low on entropy,
1322you may set up Haveged:
Filip Pytloun8296bb92016-02-19 18:42:09 +01001323
1324.. code-block:: yaml
1325
1326 linux:
1327 system:
1328 haveged:
1329 enabled: true
1330
Filip Pytlounf5383a42015-10-06 16:28:32 +02001331Linux network
1332-------------
1333
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001334Linux with network manager:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001335
1336.. code-block:: yaml
1337
1338 linux:
1339 network:
1340 enabled: true
1341 network_manager: true
1342
Dzmitry Stremkouski00cdbe62018-10-31 16:41:54 +01001343Execute linux.network.interface state without ifupdown activity:
1344
1345.. code-block:: bash
1346
1347 salt-call linux.network.interface pillar='{"linux":{"network":{"noifupdown":True}}}'
1348
1349
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001350Linux with default static network interfaces, default gateway
1351interface and DNS servers:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001352
1353.. code-block:: yaml
1354
1355 linux:
1356 network:
1357 enabled: true
1358 interface:
1359 eth0:
1360 enabled: true
1361 type: eth
1362 address: 192.168.0.102
1363 netmask: 255.255.255.0
1364 gateway: 192.168.0.1
1365 name_servers:
1366 - 8.8.8.8
1367 - 8.8.4.4
1368 mtu: 1500
1369
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001370Linux with bonded interfaces and disabled ``NetworkManager``:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001371
1372.. code-block:: yaml
1373
1374 linux:
1375 network:
1376 enabled: true
1377 interface:
1378 eth0:
1379 type: eth
1380 ...
1381 eth1:
1382 type: eth
1383 ...
1384 bond0:
1385 enabled: true
1386 type: bond
1387 address: 192.168.0.102
1388 netmask: 255.255.255.0
1389 mtu: 1500
1390 use_in:
1391 - interface: ${linux:interface:eth0}
1392 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +01001393 network_manager:
1394 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001395
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001396Linux with VLAN ``interface_params``:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001397
1398.. code-block:: yaml
1399
1400 linux:
1401 network:
1402 enabled: true
1403 interface:
1404 vlan69:
1405 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +01001406 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001407 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001408
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001409Linux with wireless interface parameters:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001410
1411.. code-block:: yaml
1412
1413 linux:
1414 network:
1415 enabled: true
1416 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001417 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001418 interface:
1419 wlan0:
1420 type: eth
1421 wireless:
1422 essid: example
1423 key: example_key
1424 security: wpa
1425 priority: 1
1426
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001427Linux networks with routes defined:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001428
1429.. code-block:: yaml
1430
1431 linux:
1432 network:
1433 enabled: true
1434 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001435 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001436 interface:
1437 eth0:
1438 type: eth
1439 route:
1440 default:
1441 address: 192.168.0.123
1442 netmask: 255.255.255.0
1443 gateway: 192.168.0.1
1444
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001445Native Linux Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001446
1447.. code-block:: yaml
1448
1449 linux:
1450 network:
1451 interface:
1452 eth1:
1453 enabled: true
1454 type: eth
1455 proto: manual
1456 up_cmds:
1457 - ip address add 0/0 dev $IFACE
1458 - ip link set $IFACE up
1459 down_cmds:
1460 - ip link set $IFACE down
1461 br-ex:
1462 enabled: true
1463 type: bridge
1464 address: ${linux:network:host:public_local:address}
1465 netmask: 255.255.255.0
1466 use_interfaces:
1467 - eth1
1468
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001469Open vSwitch Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001470
1471.. code-block:: yaml
1472
1473 linux:
1474 network:
1475 bridge: openvswitch
1476 interface:
1477 eth1:
1478 enabled: true
1479 type: eth
1480 proto: manual
1481 up_cmds:
1482 - ip address add 0/0 dev $IFACE
1483 - ip link set $IFACE up
1484 down_cmds:
1485 - ip link set $IFACE down
1486 br-ex:
1487 enabled: true
1488 type: bridge
1489 address: ${linux:network:host:public_local:address}
1490 netmask: 255.255.255.0
1491 use_interfaces:
1492 - eth1
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001493 br-prv:
1494 enabled: true
1495 type: ovs_bridge
1496 mtu: 65000
1497 br-ens7:
1498 enabled: true
1499 name: br-ens7
1500 type: ovs_bridge
1501 proto: manual
1502 mtu: 9000
1503 use_interfaces:
1504 - ens7
1505 patch-br-ens7-br-prv:
1506 enabled: true
1507 name: ens7-prv
1508 ovs_type: ovs_port
1509 type: ovs_port
1510 bridge: br-ens7
1511 port_type: patch
1512 peer: prv-ens7
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001513 tag: 109 # [] to unset a tag
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001514 mtu: 65000
1515 patch-br-prv-br-ens7:
1516 enabled: true
1517 name: prv-ens7
1518 bridge: br-prv
1519 ovs_type: ovs_port
1520 type: ovs_port
1521 port_type: patch
1522 peer: ens7-prv
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001523 tag: 109
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001524 mtu: 65000
1525 ens7:
1526 enabled: true
1527 name: ens7
1528 proto: manual
1529 ovs_port_type: OVSPort
1530 type: ovs_port
1531 ovs_bridge: br-ens7
1532 bridge: br-ens7
Filip Pytlounf5383a42015-10-06 16:28:32 +02001533
Petr Jediný8f8ae542017-07-13 16:19:12 +02001534Debian manual proto interfaces
1535
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001536When you are changing interface proto from static in up state
1537to manual, you may need to flush ip addresses. For example,
1538if you want to use the interface and the ip on the bridge.
1539This can be done by setting the ``ipflush_onchange`` to true.
Petr Jediný8f8ae542017-07-13 16:19:12 +02001540
1541.. code-block:: yaml
1542
1543 linux:
1544 network:
1545 interface:
1546 eth1:
1547 enabled: true
1548 type: eth
1549 proto: manual
1550 mtu: 9100
1551 ipflush_onchange: true
1552
Jiri Broulik1a191e32018-01-15 15:54:21 +01001553Debian static proto interfaces
1554
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001555When you are changing interface proto from dhcp in up state to
1556static, you may need to flush ip addresses and restart interface
1557to assign ip address from a managed file. For example, if you wantto
1558use the interface and the ip on the bridge. This can be done by
1559setting the ``ipflush_onchange`` with combination ``restart_on_ipflush``
1560param set to true.
Jiri Broulik1a191e32018-01-15 15:54:21 +01001561
1562.. code-block:: yaml
1563
1564 linux:
1565 network:
1566 interface:
1567 eth1:
1568 enabled: true
1569 type: eth
1570 proto: static
1571 address: 10.1.0.22
1572 netmask: 255.255.255.0
1573 ipflush_onchange: true
1574 restart_on_ipflush: true
Petr Jediný8f8ae542017-07-13 16:19:12 +02001575
Petr Jedinýd577cb52017-06-28 20:17:49 +02001576Concatinating and removing interface files
1577
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001578Debian based distributions have ``/etc/network/interfaces.d/``
1579directory, where you can store configuration of network
1580interfaces in separate files. You can concatinate the files
1581to the defined destination when needed, this operation removes
1582the file from the ``/etc/network/interfaces.d/``. If you just need
1583to remove iface files, you can use the ``remove_iface_files`` key.
Petr Jedinýd577cb52017-06-28 20:17:49 +02001584
1585.. code-block:: yaml
1586
1587 linux:
1588 network:
1589 concat_iface_files:
1590 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
1591 dst: '/etc/network/interfaces'
1592 remove_iface_files:
1593 - '/etc/network/interfaces.d/90-custom.cfg'
1594
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001595Configure DHCP client
Petr Jedinýd577cb52017-06-28 20:17:49 +02001596
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001597None of the keys is mandatory, include only those you really need.
1598For full list of available options under send, supersede, prepend,
1599append refer to dhcp-options(5).
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001600
1601.. code-block:: yaml
1602
1603 linux:
1604 network:
1605 dhclient:
1606 enabled: true
1607 backoff_cutoff: 15
1608 initial_interval: 10
1609 reboot: 10
1610 retry: 60
1611 select_timeout: 0
1612 timeout: 120
1613 send:
1614 - option: host-name
1615 declaration: "= gethostname()"
1616 supersede:
1617 - option: host-name
1618 declaration: "spaceship"
1619 - option: domain-name
1620 declaration: "domain.home"
1621 #- option: arp-cache-timeout
1622 # declaration: 20
1623 prepend:
1624 - option: domain-name-servers
1625 declaration:
1626 - 8.8.8.8
1627 - 8.8.4.4
1628 - option: domain-search
1629 declaration:
1630 - example.com
1631 - eng.example.com
1632 #append:
1633 #- option: domain-name-servers
1634 # declaration: 127.0.0.1
1635 # ip or subnet to reject dhcp offer from
1636 reject:
1637 - 192.33.137.209
1638 - 10.0.2.0/24
1639 request:
1640 - subnet-mask
1641 - broadcast-address
1642 - time-offset
1643 - routers
1644 - domain-name
1645 - domain-name-servers
1646 - domain-search
1647 - host-name
1648 - dhcp6.name-servers
1649 - dhcp6.domain-search
1650 - dhcp6.fqdn
1651 - dhcp6.sntp-servers
1652 - netbios-name-servers
1653 - netbios-scope
1654 - interface-mtu
1655 - rfc3442-classless-static-routes
1656 - ntp-servers
1657 require:
1658 - subnet-mask
1659 - domain-name-servers
1660 # if per interface configuration required add below
1661 interface:
1662 ens2:
1663 initial_interval: 11
1664 reject:
1665 - 192.33.137.210
1666 ens3:
1667 initial_interval: 12
1668 reject:
1669 - 192.33.137.211
1670
Petr Michaleceb14b552017-06-01 10:27:05 +02001671Linux network systemd settings:
1672
1673.. code-block:: yaml
1674
1675 linux:
1676 network:
1677 ...
1678 systemd:
1679 link:
1680 10-iface-dmz:
1681 Match:
1682 MACAddress: c8:5b:67:fa:1a:af
1683 OriginalName: eth0
1684 Link:
1685 Name: dmz0
1686 netdev:
1687 20-bridge-dmz:
1688 match:
1689 name: dmz0
1690 network:
1691 mescription: bridge
1692 bridge: br-dmz0
1693 network:
1694 # works with lowercase, keys are by default capitalized
1695 40-dhcp:
1696 match:
1697 name: '*'
1698 network:
1699 DHCP: yes
1700
Petr Michalec10462bb2017-03-23 19:18:08 +01001701Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +01001702
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001703Use ``/etc/environment`` for static system wide variable assignment
1704after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001705
1706.. code-block:: yaml
1707
1708 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +01001709 system:
1710 env:
1711 BOB_VARIABLE: Alice
1712 ...
1713 BOB_PATH:
1714 - /srv/alice/bin
1715 - /srv/bob/bin
1716 ...
1717 ftp_proxy: none
1718 http_proxy: http://global-http-proxy.host.local:8080
1719 https_proxy: ${linux:system:proxy:https}
1720 no_proxy:
1721 - 192.168.0.80
1722 - 192.168.1.80
1723 - .domain.com
1724 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001725 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001726 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001727 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001728 ftp: ftp://proxy.host.local:2121
1729 http: http://proxy.host.local:3142
1730 https: https://proxy.host.local:3143
1731 noproxy:
1732 - .domain.com
1733 - .local
1734
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001735Configure the ``profile.d`` scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001736
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001737The ``profile.d`` scripts are being sourced during ``.sh`` execution
1738and support variable expansion in opposite to /etc/environment global
1739settings in ``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001740
1741.. code-block:: yaml
1742
1743 linux:
1744 system:
1745 profile:
1746 locales: |
1747 export LANG=C
1748 export LC_ALL=C
1749 ...
1750 vi_flavors.sh: |
1751 export PAGER=view
1752 export EDITOR=vim
1753 alias vi=vim
1754 shell_locales.sh: |
1755 export LANG=en_US
1756 export LC_ALL=en_US.UTF-8
1757 shell_proxies.sh: |
1758 export FTP_PROXY=ftp://127.0.3.3:2121
1759 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001760
Dmitry Teselkina0d31d12018-09-04 14:43:09 +03001761
1762Configure login.defs parameters
1763-------------------------------
1764
1765.. code-block:: yaml
1766
1767 linux:
1768 system:
1769 login_defs:
1770 <opt_name>:
1771 enabled: true
1772 value: <opt_value>
1773
1774<opt_name> is a configurational option defined in 'man login.defs'.
1775<opt_name> is case sensitive, should be UPPERCASE only!
1776
1777
Filip Pytlounf5383a42015-10-06 16:28:32 +02001778Linux with hosts
1779
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001780Parameter ``purge_hosts`` will enforce whole ``/etc/hosts file``,
1781removing entries that are not defined in model except defaults
1782for both IPv4 and IPv6 localhost and hostname as well as FQDN.
Ales Komarek417e8c52017-08-25 15:10:29 +02001783
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001784We recommend using this option to verify that ``/etc/hosts``
1785is always in a clean state. However it is not enabled by default
1786for security reasons.
Filip Pytloun86506fe2017-01-26 14:36:16 +01001787
Filip Pytlounf5383a42015-10-06 16:28:32 +02001788.. code-block:: yaml
1789
1790 linux:
1791 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001792 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001793 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001794 # No need to define this one if purge_hosts is true
1795 hostname:
1796 address: 127.0.1.1
1797 names:
1798 - ${linux:network:fqdn}
1799 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001800 node1:
1801 address: 192.168.10.200
1802 names:
1803 - node2.domain.com
1804 - service2.domain.com
1805 node2:
1806 address: 192.168.10.201
1807 names:
1808 - node2.domain.com
1809 - service2.domain.com
1810
Ales Komarek417e8c52017-08-25 15:10:29 +02001811Linux with hosts collected from mine
1812
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001813All DNS records defined within infrastrucuture
1814are passed to the local hosts records or any DNS server. Only
1815hosts with the ``grain`` parameter set to ``true`` will be propagated
1816to the mine.
Ales Komarek417e8c52017-08-25 15:10:29 +02001817
1818.. code-block:: yaml
1819
1820 linux:
1821 network:
1822 purge_hosts: true
1823 mine_dns_records: true
1824 host:
1825 node1:
1826 address: 192.168.10.200
1827 grain: true
1828 names:
1829 - node2.domain.com
1830 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01001831
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001832Set up ``resolvconf's basic resolver info``, e.g. nameservers, search/domain and options:
Filip Pytlounde9bea52016-01-11 15:39:10 +01001833
1834.. code-block:: yaml
1835
1836 linux:
1837 network:
1838 resolv:
1839 dns:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001840 - 8.8.4.4
1841 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01001842 domain: my.example.com
1843 search:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001844 - my.example.com
1845 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01001846 options:
Michael Polenchuk95bc83a2019-01-15 18:47:48 +04001847 - ndots:5
1848 - timeout:2
1849 - attempts:2
Filip Pytlounde9bea52016-01-11 15:39:10 +01001850
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001851Set up custom TX queue length for tap interfaces:
Andrii Petrenko735761d2017-03-21 17:17:35 -07001852
1853.. code-block:: yaml
1854
1855 linux:
1856 network:
1857 tap_custom_txqueuelen: 10000
1858
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001859DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001860
1861**DPDK OVS NIC**
1862
1863.. code-block:: yaml
1864
1865 linux:
1866 network:
1867 bridge: openvswitch
1868 dpdk:
1869 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001870 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001871 openvswitch:
1872 pmd_cpu_mask: "0x6"
1873 dpdk_socket_mem: "1024,1024"
1874 dpdk_lcore_mask: "0x400"
1875 memory_channels: 2
1876 interface:
1877 dpkd0:
1878 name: ${_param:dpdk_nic}
1879 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001880 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001881 enabled: true
1882 type: dpdk_ovs_port
1883 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001884 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001885 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01001886 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001887 br-prv:
1888 enabled: true
1889 type: dpdk_ovs_bridge
Michael Polenchukd3378db2018-12-29 16:46:50 +04001890 br-floating:
1891 enabled: true
1892 type: ovs_bridge
1893 name_servers:
1894 - 1.1.1.1
1895 - 9.9.9.9
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001896
1897**DPDK OVS Bond**
1898
1899.. code-block:: yaml
1900
1901 linux:
1902 network:
1903 bridge: openvswitch
1904 dpdk:
1905 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001906 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001907 openvswitch:
1908 pmd_cpu_mask: "0x6"
1909 dpdk_socket_mem: "1024,1024"
1910 dpdk_lcore_mask: "0x400"
1911 memory_channels: 2
1912 interface:
1913 dpdk_second_nic:
1914 name: ${_param:primary_second_nic}
1915 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001916 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001917 bond: dpdkbond0
1918 enabled: true
1919 type: dpdk_ovs_port
1920 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001921 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001922 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001923 dpdk_first_nic:
1924 name: ${_param:primary_first_nic}
1925 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001926 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001927 bond: dpdkbond0
1928 enabled: true
1929 type: dpdk_ovs_port
1930 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001931 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001932 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001933 dpdkbond0:
1934 enabled: true
1935 bridge: br-prv
1936 type: dpdk_ovs_bond
1937 mode: active-backup
1938 br-prv:
1939 enabled: true
1940 type: dpdk_ovs_bridge
1941
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01001942**DPDK OVS LACP Bond with vlan tag**
1943
1944.. code-block:: yaml
1945
1946 linux:
1947 network:
1948 bridge: openvswitch
1949 dpdk:
1950 enabled: true
1951 driver: uio
1952 openvswitch:
1953 pmd_cpu_mask: "0x6"
1954 dpdk_socket_mem: "1024,1024"
1955 dpdk_lcore_mask: "0x400"
1956 memory_channels: "2"
1957 interface:
1958 eth3:
1959 enabled: true
1960 type: eth
1961 proto: manual
1962 name: ${_param:tenant_first_nic}
1963 eth4:
1964 enabled: true
1965 type: eth
1966 proto: manual
1967 name: ${_param:tenant_second_nic}
1968 dpdk0:
1969 name: ${_param:tenant_first_nic}
1970 pci: "0000:81:00.0"
1971 driver: igb_uio
1972 bond: bond1
1973 enabled: true
1974 type: dpdk_ovs_port
1975 n_rxq: 2
1976 dpdk1:
1977 name: ${_param:tenant_second_nic}
1978 pci: "0000:81:00.1"
1979 driver: igb_uio
1980 bond: bond1
1981 enabled: true
1982 type: dpdk_ovs_port
1983 n_rxq: 2
1984 bond1:
1985 enabled: true
1986 bridge: br-prv
1987 type: dpdk_ovs_bond
1988 mode: balance-slb
1989 br-prv:
1990 enabled: true
1991 type: dpdk_ovs_bridge
1992 tag: ${_param:tenant_vlan}
1993 address: ${_param:tenant_address}
1994 netmask: ${_param:tenant_network_netmask}
1995
Jakub Pavlikaa759062017-03-13 15:57:26 +01001996**DPDK OVS bridge for VXLAN**
1997
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001998If VXLAN is used as tenant segmentation, IP address must
1999be set on ``br-prv``.
Jakub Pavlikaa759062017-03-13 15:57:26 +01002000
2001.. code-block:: yaml
2002
2003 linux:
2004 network:
2005 ...
2006 interface:
2007 br-prv:
2008 enabled: true
2009 type: dpdk_ovs_bridge
2010 address: 192.168.50.0
2011 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04002012 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01002013 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002014
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02002015**DPDK OVS bridge with Linux network interface**
2016
2017.. code-block:: yaml
2018
2019 linux:
2020 network:
2021 ...
2022 interface:
2023 eth0:
2024 type: eth
2025 ovs_bridge: br-prv
2026 ...
2027 br-prv:
2028 enabled: true
2029 type: dpdk_ovs_bridge
2030 ...
2031
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002032Linux storage
2033-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02002034
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002035Linux with mounted Samba:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002036
2037.. code-block:: yaml
2038
2039 linux:
2040 storage:
2041 enabled: true
2042 mount:
2043 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01002044 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02002045 - path: /media/myuser/public/
2046 - device: //192.168.0.1/storage
2047 - file_system: cifs
2048 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
2049
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002050NFS mount:
Jiri Broulikb017f932017-03-31 13:55:36 +02002051
2052.. code-block:: yaml
2053
2054 linux:
2055 storage:
2056 enabled: true
2057 mount:
2058 nfs_glance:
2059 enabled: true
2060 path: /var/lib/glance/images
2061 device: 172.16.10.110:/var/nfs/glance
2062 file_system: nfs
2063 opts: rw,sync
2064
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002065File swap configuration:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002066
2067.. code-block:: yaml
2068
2069 linux:
2070 storage:
2071 enabled: true
2072 swap:
2073 file:
2074 enabled: true
2075 engine: file
2076 device: /swapfile
2077 size: 1024
2078
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002079Partition swap configuration:
Lachlan Evenson30676512016-01-22 15:43:28 -08002080
2081.. code-block:: yaml
2082
2083 linux:
2084 storage:
2085 enabled: true
2086 swap:
2087 partition:
2088 enabled: true
2089 engine: partition
2090 device: /dev/vg0/swap
2091
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002092LVM group ``vg1`` with one device and ``data`` volume mounted
2093into ``/mnt/data``.
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002094
2095.. code-block:: yaml
2096
2097 parameters:
2098 linux:
2099 storage:
2100 mount:
2101 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01002102 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002103 device: /dev/vg1/data
2104 file_system: ext4
2105 path: /mnt/data
2106 lvm:
2107 vg1:
2108 enabled: true
2109 devices:
2110 - /dev/sdb
2111 volume:
2112 data:
2113 size: 40G
2114 mount: ${linux:storage:mount:data}
root40bb5e72019-01-11 08:55:32 +00002115 # When set they will take precedence over filters aget from volume groups.
2116 lvm_filters:
2117 10:
2118 enabled: True
2119 value: "a|loop|"
2120 20:
2121 enabled: True
2122 value: "r|/dev/hdc|"
2123 30:
2124 enabled: True
2125 value: "a|/dev/ide|"
2126 40:
2127 enabled: True
2128 value: "r|.*|"
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002129
Jakub Pavlik4f742142017-08-08 15:05:50 +02002130Create partitions on disk. Specify size in MB. It expects empty
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002131disk without any existing partitions.
2132Set ``startsector=1`` if you want to start partitions from ``2048``.
Jakub Pavlik4f742142017-08-08 15:05:50 +02002133
2134.. code-block:: yaml
2135
2136 linux:
2137 storage:
2138 disk:
2139 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01002140 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02002141 name: /dev/loop1
2142 type: gpt
2143 partitions:
2144 - size: 200 #size in MB
2145 type: fat32
2146 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02002147 mkfs: True
2148 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02002149 /dev/vda1:
2150 partitions:
2151 - size: 5
2152 type: ext2
2153 - size: 10
2154 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02002155
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002156Multipath with Fujitsu Eternus DXL:
Ales Komareka634f4b2016-10-02 13:11:04 +02002157
2158.. code-block:: yaml
2159
2160 parameters:
2161 linux:
2162 storage:
2163 multipath:
2164 enabled: true
2165 blacklist_devices:
2166 - /dev/sda
2167 - /dev/sdb
2168 backends:
2169 - fujitsu_eternus_dxl
2170
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002171Multipath with Hitachi VSP 1000:
Ales Komareka634f4b2016-10-02 13:11:04 +02002172
2173.. code-block:: yaml
2174
2175 parameters:
2176 linux:
2177 storage:
2178 multipath:
2179 enabled: true
2180 blacklist_devices:
2181 - /dev/sda
2182 - /dev/sdb
2183 backends:
2184 - hitachi_vsp1000
2185
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002186Multipath with IBM Storwize:
Ales Komareka634f4b2016-10-02 13:11:04 +02002187
2188.. code-block:: yaml
2189
2190 parameters:
2191 linux:
2192 storage:
2193 multipath:
2194 enabled: true
2195 blacklist_devices:
2196 - /dev/sda
2197 - /dev/sdb
2198 backends:
2199 - ibm_storwize
2200
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002201Multipath with multiple backends:
Ales Komareka634f4b2016-10-02 13:11:04 +02002202
2203.. code-block:: yaml
2204
2205 parameters:
2206 linux:
2207 storage:
2208 multipath:
2209 enabled: true
2210 blacklist_devices:
2211 - /dev/sda
2212 - /dev/sdb
2213 - /dev/sdc
2214 - /dev/sdd
2215 backends:
2216 - ibm_storwize
2217 - fujitsu_eternus_dxl
2218 - hitachi_vsp1000
2219
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002220PAM LDAP integration:
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002221
2222.. code-block:: yaml
2223
2224 parameters:
2225 linux:
2226 system:
2227 auth:
2228 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02002229 mkhomedir:
2230 enabled: true
2231 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002232 ldap:
2233 enabled: true
2234 binddn: cn=bind,ou=service_users,dc=example,dc=com
2235 bindpw: secret
2236 uri: ldap://127.0.0.1
2237 base: ou=users,dc=example,dc=com
2238 ldap_version: 3
2239 pagesize: 65536
2240 referrals: off
2241 filter:
2242 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2243 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2244 group: (&(objectClass=group)(gidNumber=*))
2245
Gleb Galkin93b9ae92018-10-18 13:57:30 +03002246PAM duo 2FA integration
2247
2248.. code-block:: yaml
2249
2250 parameters:
2251 linux:
2252 system:
2253 auth:
2254 enabled: true
2255 duo:
2256 enabled: true
2257 duo_host: localhost
2258 duo_ikey: DUO-INTEGRATION-KEY
2259 duo_skey: DUO-SECRET-KEY
2260
2261duo package version may be specified (optional)
2262
2263.. code-block:: yaml
2264
2265 linux:
2266 system:
2267 package:
2268 duo-unix:
2269 version: 1.10.1-0
2270
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002271Disabled multipath (the default setup):
Ales Komareka634f4b2016-10-02 13:11:04 +02002272
2273.. code-block:: yaml
2274
2275 parameters:
2276 linux:
2277 storage:
2278 multipath:
2279 enabled: false
2280
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002281Linux with local loopback device:
Simon Pasquier375001e2017-01-26 13:22:33 +01002282
2283.. code-block:: yaml
2284
2285 linux:
2286 storage:
2287 loopback:
2288 disk1:
2289 file: /srv/disk1
2290 size: 50G
2291
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002292External config generation
2293--------------------------
2294
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002295You are able to use config support metadata between formulas
2296and only generate configuration files for external use, for example, Docker, and so on.
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002297
2298.. code-block:: yaml
2299
2300 parameters:
2301 linux:
2302 system:
2303 config:
2304 pillar:
2305 jenkins:
2306 master:
2307 home: /srv/volumes/jenkins
2308 approved_scripts:
2309 - method java.net.URL openConnection
2310 credentials:
2311 - type: username_password
2312 scope: global
2313 id: test
2314 desc: Testing credentials
2315 username: test
2316 password: test
2317
Vladimir Ereminccf28842017-04-10 23:52:10 +03002318Netconsole Remote Kernel Logging
2319--------------------------------
2320
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002321Netconsole logger can be configured for the configfs-enabled kernels
2322(``CONFIG_NETCONSOLE_DYNAMIC`` must be enabled). The configuration
2323applies both in runtime (if network is already configured),
2324and on-boot after an interface initialization.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002325
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002326.. note::
2327
2328 * Receiver can be located only on the same L3 domain
2329 (or you need to configure gateway MAC manually).
2330 * The Receiver MAC is detected only on configuration time.
2331 * Using broadcast MAC is not recommended.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002332
2333.. code-block:: yaml
2334
2335 parameters:
2336 linux:
2337 system:
2338 netconsole:
2339 enabled: true
2340 port: 514 (optional)
2341 loglevel: debug (optional)
2342 target:
2343 192.168.0.1:
2344 interface: bond0
2345 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02002346
Dzmitry Stremkouskid1a268b2018-10-03 16:36:04 +02002347Check network params on the environment
2348---------------------------------------
2349
2350Grab nics and nics states
2351
2352.. code-block:: bash
2353
2354 salt osd001\* net_checks.get_nics
2355
2356**Example of system output:**
2357
2358.. code-block:: bash
2359
2360 osd001.domain.com:
2361 |_
2362 - bond0
2363 - None
2364 - 1e:c8:64:42:23:b9
2365 - 0
2366 - 1500
2367 |_
2368 - bond1
2369 - None
2370 - 3c:fd:fe:27:3b:00
2371 - 1
2372 - 9100
2373 |_
2374 - fourty1
2375 - None
2376 - 3c:fd:fe:27:3b:00
2377 - 1
2378 - 9100
2379 |_
2380 - fourty2
2381 - None
2382 - 3c:fd:fe:27:3b:02
2383 - 1
2384 - 9100
2385
2386Grab 10G nics PCI addresses for hugepages setup
2387
2388.. code-block:: bash
2389
2390 salt cmp001\* net_checks.get_ten_pci
2391
2392**Example of system output:**
2393
2394.. code-block:: bash
2395
2396 cmp001.domain.com:
2397 |_
2398 - ten1
2399 - 0000:19:00.0
2400 |_
2401 - ten2
2402 - 0000:19:00.1
2403 |_
2404 - ten3
2405 - 0000:19:00.2
2406 |_
2407 - ten4
2408 - 0000:19:00.3
2409
2410Grab ip address for an interface
2411
2412.. code-block:: bash
2413
2414 salt cmp001\* net_checks.get_ip iface=one4
2415
2416**Example of system output:**
2417
2418.. code-block:: bash
2419
2420 cmp001.domain.com:
2421 10.200.177.101
2422
2423Grab ip addresses map
2424
2425.. code-block:: bash
2426
2427 salt-call net_checks.nodes_addresses
2428
2429**Example of system output:**
2430
2431.. code-block:: bash
2432
2433 local:
2434 |_
2435 - cid01.domain.com
2436 |_
2437 |_
2438 - pxe
2439 - 10.200.177.91
2440 |_
2441 - control
2442 - 10.200.178.91
2443 |_
2444 - cmn02.domain.com
2445 |_
2446 |_
2447 - storage_access
2448 - 10.200.181.67
2449 |_
2450 - pxe
2451 - 10.200.177.67
2452 |_
2453 - control
2454 - 10.200.178.67
2455 |_
2456 - cmp010.domain.com
2457 |_
2458 |_
2459 - pxe
2460 - 10.200.177.110
2461 |_
2462 - storage_access
2463 - 10.200.181.110
2464 |_
2465 - control
2466 - 10.200.178.110
2467 |_
2468 - vxlan
2469 - 10.200.179.110
2470
2471Verify full mesh connectivity
2472
2473.. code-block:: bash
2474
2475 salt-call net_checks.ping_check
2476
2477**Example of positive system output:**
2478
2479.. code-block:: bash
2480
2481 ['PASSED']
2482 [INFO ] ['PASSED']
2483 local:
2484 True
2485
2486**Example of system output in case of failure:**
2487
2488.. code-block:: bash
2489
2490 FAILED
2491 [ERROR ] FAILED
2492 ['control: 10.0.1.92 -> 10.0.1.224: Failed']
2493 ['control: 10.0.1.93 -> 10.0.1.224: Failed']
2494 ['control: 10.0.1.51 -> 10.0.1.224: Failed']
2495 ['control: 10.0.1.102 -> 10.0.1.224: Failed']
2496 ['control: 10.0.1.13 -> 10.0.1.224: Failed']
2497 ['control: 10.0.1.81 -> 10.0.1.224: Failed']
2498 local:
2499 False
2500
2501For this feature to work, please mark addresses with some role.
2502Otherwise 'default' role is assumed and mesh would consist of all
2503addresses on the environment.
2504
2505Mesh mark is needed only for interfaces which are enabled and have
2506ip address assigned.
2507
2508Checking dhcp pxe network meaningless, as it is used for salt
2509master vs minion communications, therefore treated as checked.
2510
2511.. code-block:: yaml
2512
2513 parameters:
2514 linux:
2515 network:
2516 interface:
2517 ens3:
2518 enabled: true
2519 type: eth
2520 proto: static
2521 address: ${_param:deploy_address}
2522 netmask: ${_param:deploy_network_netmask}
2523 gateway: ${_param:deploy_network_gateway}
2524 mesh: pxe
2525
2526Check pillars for ip address duplicates
2527
2528.. code-block:: bash
2529
2530 salt-call net_checks.verify_addresses
2531
2532**Example of positive system output:**
2533
2534.. code-block:: bash
2535
2536 ['PASSED']
2537 [INFO ] ['PASSED']
2538 local:
2539 True
2540
2541**Example of system output in case of failure:**
2542
2543.. code-block:: bash
2544
2545 FAILED. Duplicates found
2546 [ERROR ] FAILED. Duplicates found
2547 ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2548 [ERROR ] ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2549 local:
2550 False
2551
2552Generate csv report for the env
2553
2554.. code-block:: bash
2555
2556 salt -C 'kvm* or cmp* or osd*' net_checks.get_nics_csv \
2557 | grep '^\ ' | sed 's/\ *//g' | grep -Ev ^server \
2558 | sed '1 i\server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr'
2559
2560**Example of system output:**
2561
2562.. code-block:: bash
2563
2564 server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr
2565 cmp010.domain.com,bond0,None,b4:96:91:10:5b:3a,1,1500,,,,
2566 cmp010.domain.com,bond0.21,10.200.178.110,b4:96:91:10:5b:3a,1,1500,,,,
2567 cmp010.domain.com,bond0.22,10.200.179.110,b4:96:91:10:5b:3a,1,1500,,,,
2568 cmp010.domain.com,bond1,None,3c:fd:fe:34:ad:22,0,1500,,,,
2569 cmp010.domain.com,bond1.24,10.200.181.110,3c:fd:fe:34:ad:22,0,1500,,,,
2570 cmp010.domain.com,fourty5,None,3c:fd:fe:34:ad:20,0,9000,,,,
2571 cmp010.domain.com,fourty6,None,3c:fd:fe:34:ad:22,0,9000,,,,
2572 cmp010.domain.com,one1,None,b4:96:91:10:5b:38,0,1500,,,,
2573 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
2574 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
2575 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
2576 cmp011.domain.com,bond0,None,b4:96:91:13:6c:aa,1,1500,,,,
2577 cmp011.domain.com,bond0.21,10.200.178.111,b4:96:91:13:6c:aa,1,1500,,,,
2578 cmp011.domain.com,bond0.22,10.200.179.111,b4:96:91:13:6c:aa,1,1500,,,,
2579 ...
2580
Filip Pytlounf5383a42015-10-06 16:28:32 +02002581Usage
2582=====
2583
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002584Set MTU of the eth0 network interface to 1400:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002585
2586.. code-block:: bash
2587
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002588 ip link set dev eth0 mtu 1400
Filip Pytlounf5383a42015-10-06 16:28:32 +02002589
2590Read more
2591=========
2592
2593* https://www.archlinux.org/
2594* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu