blob: ef99718e6c2d47c9ffebc6acf9a3a8993e3a73b1 [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
azvyagintsev4494a472018-09-14 19:19:23 +0300959If you need to add multiple pin rules for one repo, please use new,ordered definition format
960('pinning' definition will be in priotity to use):
961
962.. code-block:: yaml
963
964 linux:
965 system:
966 repo:
967 mcp_saltstack:
968 source: "deb [arch=amd64] http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/ xenial main"
969 architectures: amd64
970 clean_file: true
971 pinning:
972 10:
973 enabled: true
974 pin: 'release o=SaltStack'
975 priority: 50
976 package: 'libsodium18'
977 20:
978 enabled: true
979 pin: 'release o=SaltStack'
980 priority: 1100
981 package: '*'
982
983
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300984.. note:: For old Ubuntu releases (<xenial)
azvyagintsevff089d22018-07-27 16:52:34 +0200985 extra packages for apt transport, like ``apt-transport-https``
986 may be required to be installed manually.
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300987 (Chicken-eggs issue: we need to install packages to
azvyagintsevff089d22018-07-27 16:52:34 +0200988 reach repo from where they should be installed)
989 Otherwise, you still can try 'fortune' and install prereq.packages before
990 any repo configuration, using list of requires in map.jinja.
991
992
OlgaGusarenko2828f5f2018-07-30 19:37:05 +0300993Disabling any prerequisite packages installation:
994
azvyagintsevff089d22018-07-27 16:52:34 +0200995You can simply drop any package pre-installation (before system.linux.repo
996will be processed) via cluster lvl:
997
998.. code-block:: yaml
999
1000 linux:
1001 system:
1002 pkgs: ~
1003
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001004Package manager proxy global setup:
Petr Michalec10462bb2017-03-23 19:18:08 +01001005
1006.. code-block:: yaml
1007
1008 linux:
1009 system:
1010 ...
1011 repo:
1012 apt-mk:
1013 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1014 ...
1015 proxy:
1016 pkg:
1017 enabled: true
1018 ftp: ftp://ftp-proxy-for-apt.host.local:2121
1019 ...
1020 # NOTE: Global defaults for any other componet that configure proxy on the system.
1021 # If your environment has just one simple proxy, set it on linux:system:proxy.
1022 #
1023 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
1024 # as for https and http
1025 ftp: ftp://proxy.host.local:2121
1026 http: http://proxy.host.local:3142
1027 https: https://proxy.host.local:3143
1028
1029Package manager proxy setup per repository:
1030
1031.. code-block:: yaml
1032
1033 linux:
1034 system:
1035 ...
1036 repo:
1037 debian:
1038 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1039 ...
1040 apt-mk:
1041 source: "deb http://apt-mk.mirantis.com/ stable main salt"
1042 # per repository proxy
1043 proxy:
1044 enabled: true
1045 http: http://maas-01:8080
1046 https: http://maas-01:8080
1047 ...
1048 proxy:
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001049 # package manager fallback defaults
Petr Michalec10462bb2017-03-23 19:18:08 +01001050 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
1051 pkg:
1052 enabled: true
1053 ftp: ftp://proxy.host.local:2121
1054 #http: http://proxy.host.local:3142
1055 #https: https://proxy.host.local:3143
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001056 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001057 # global system fallback system defaults
1058 ftp: ftp://proxy.host.local:2121
1059 http: http://proxy.host.local:3142
1060 https: https://proxy.host.local:3143
1061
Jiri Broulik34a29b42017-04-25 14:42:54 +02001062Remove all repositories:
1063
1064.. code-block:: yaml
1065
1066 linux:
1067 system:
1068 purge_repos: true
1069
azvyagintsevff089d22018-07-27 16:52:34 +02001070Refresh repositories metada, after configuration:
1071
1072.. code-block:: yaml
1073
1074 linux:
1075 system:
1076 refresh_repos_meta: true
1077
Filip Pytlounc512e6c2017-11-22 14:28:10 +01001078Setup custom apt config options:
1079
1080.. code-block:: yaml
1081
1082 linux:
1083 system:
1084 apt:
1085 config:
1086 compression-workaround:
1087 "Acquire::CompressionTypes::Order": "gz"
1088 docker-clean:
1089 "DPkg::Post-Invoke":
1090 - "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"
1091 "APT::Update::Post-Invoke":
1092 - "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 +02001093
Petr Michalec10462bb2017-03-23 19:18:08 +01001094RC
1095~~
1096
Jakub Pavlik78859382016-01-21 11:26:39 +01001097rc.local example
1098
1099.. code-block:: yaml
1100
1101 linux:
1102 system:
1103 rc:
1104 local: |
1105 #!/bin/sh -e
1106 #
1107 # rc.local
1108 #
1109 # This script is executed at the end of each multiuser runlevel.
1110 # Make sure that the script will "exit 0" on success or any other
1111 # value on error.
1112 #
1113 # In order to enable or disable this script just change the execution
1114 # bits.
1115 #
1116 # By default this script does nothing.
1117 exit 0
1118
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001119Prompt
1120~~~~~~
1121
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001122Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``.
1123Every user can have different prompt:
Filip Pytloun1f40dac2016-01-22 15:52:57 +01001124
1125.. code-block:: yaml
1126
1127 linux:
1128 system:
1129 prompt:
1130 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\\]
1131 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
1132
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001133On Debian systems, to set prompt system-wide, it's necessary to
1134remove setting PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc``,
1135which comes from ``/etc/skel/.bashrc``. This formula will do
1136this automatically, but will not touch existing user's
1137``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +01001138
Filip Pytlouneef11c12016-03-25 11:00:23 +01001139Bash
1140~~~~
1141
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001142Fix bash configuration to preserve history across sessions
1143like ZSH does by default:
Filip Pytlouneef11c12016-03-25 11:00:23 +01001144
1145.. code-block:: yaml
1146
1147 linux:
1148 system:
1149 bash:
1150 preserve_history: true
1151
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001152Login banner message
1153~~~~~~~~~~~~~~~~~~~~
1154
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001155``/etc/issue`` is a text file which contains a message or system
1156identification to be printed before the login prompt. It may contain
Dmitry Teselkin949398e2018-05-03 15:50:00 +03001157various @char and \char sequences, if supported by the getty-type
1158program employed on the system.
1159
1160Setting logon banner message is easy:
1161
1162.. code-block:: yaml
1163
1164 liunx:
1165 system:
1166 banner:
1167 enabled: true
1168 contents: |
1169 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1170
1171 You must have explicit, authorized permission to access or configure this
1172 device. Unauthorized attempts and actions to access or use this system may
1173 result in civil and/or criminal penalties.
1174 All activities performed on this system are logged and monitored.
1175
Filip Pytloune874dfb2016-01-22 16:57:34 +01001176Message of the day
1177~~~~~~~~~~~~~~~~~~
1178
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001179``pam_motd`` from package ``libpam-modules`` is used for dynamic
1180messages of the day. Setting custom ``motd`` will clean up existing ones.
Filip Pytloune874dfb2016-01-22 16:57:34 +01001181
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001182Setting static ``motd`` will replace existing ``/etc/motd`` and remove
1183scripts from ``/etc/update-motd.d``.
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001184
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001185Setting static ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001186
1187.. code-block:: yaml
1188
1189 linux:
1190 system:
1191 motd: |
1192 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
1193
1194 You must have explicit, authorized permission to access or configure this
1195 device. Unauthorized attempts and actions to access or use this system may
1196 result in civil and/or criminal penalties.
1197 All activities performed on this system are logged and monitored.
1198
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001199Setting dynamic ``motd``:
Dmitry Teselkin538c8242018-04-02 16:13:37 +03001200
Filip Pytloune874dfb2016-01-22 16:57:34 +01001201.. code-block:: yaml
1202
1203 linux:
1204 system:
1205 motd:
1206 - release: |
1207 #!/bin/sh
1208 [ -r /etc/lsb-release ] && . /etc/lsb-release
1209
1210 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
1211 # Fall back to using the very slow lsb_release utility
1212 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
1213 fi
1214
1215 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
1216 - warning: |
1217 #!/bin/sh
1218 printf "This is [company name] network.\n"
1219 printf "Unauthorized access strictly prohibited.\n"
1220
Marek Celoud713e9072017-05-18 15:20:25 +02001221Services
1222~~~~~~~~
1223
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001224Stop and disable the ``linux`` service:
Marek Celoud713e9072017-05-18 15:20:25 +02001225
1226.. code-block:: yaml
1227
1228 linux:
1229 system:
1230 service:
1231 apt-daily.timer:
1232 status: dead
1233
Dzmitry Stremkouski70d09782018-11-30 16:04:59 +01001234Override systemd service unit:
1235
1236.. code-block:: yaml
1237
1238 parameters:
1239
1240 linux:
1241 system:
1242 service:
1243 tgt:
1244 name: tgt
1245 status: running
1246 enabled: True
1247 override:
1248 50:
1249 target: tgt.service.d
1250 name: bind
1251 content: |
1252 [Service]
1253 ExecStart=
1254 ExecStart=/usr/sbin/tgtd -f --iscsi portal=${_param:single_address}:3260
1255
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001256Possible statuses are ``dead`` (disable service by default), ``running``
1257(enable service by default), ``enabled``, ``disabled``:
Marek Celoud713e9072017-05-18 15:20:25 +02001258
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001259Linux with the ``atop`` service:
Serhiy Ovsianikov67bd56a2017-08-11 15:56:01 +03001260
1261.. code-block:: yaml
1262
1263 linux:
1264 system:
1265 atop:
1266 enabled: true
1267 interval: 20
1268 logpath: "/var/log/atop"
1269 outfile: "/var/log/atop/daily.log"
1270
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001271Linux with the ``mcelog`` service:
Oleksii Chupryn144432b2018-05-22 10:34:48 +03001272
1273.. code-block:: yaml
1274
1275 linux:
1276 system:
1277 mcelog:
1278 enabled: true
1279 logging:
1280 syslog: true
1281 syslog_error: true
1282
Filip Pytloun2f70b492016-02-19 15:55:25 +01001283RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +01001284^^^^^^^^^^^^^
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001285Currently, ``update-motd`` is not available
1286for RHEL. So there is no native support for dynamic ``motd``.
1287You can still set a static one, with a different pillar structure:
Filip Pytloun2f70b492016-02-19 15:55:25 +01001288
1289.. code-block:: yaml
1290
1291 linux:
1292 system:
1293 motd: |
1294 This is [company name] network.
1295 Unauthorized access strictly prohibited.
1296
Filip Pytloun8296bb92016-02-19 18:42:09 +01001297Haveged
1298~~~~~~~
1299
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001300If you are running headless server and are low on entropy,
1301you may set up Haveged:
Filip Pytloun8296bb92016-02-19 18:42:09 +01001302
1303.. code-block:: yaml
1304
1305 linux:
1306 system:
1307 haveged:
1308 enabled: true
1309
Filip Pytlounf5383a42015-10-06 16:28:32 +02001310Linux network
1311-------------
1312
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001313Linux with network manager:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001314
1315.. code-block:: yaml
1316
1317 linux:
1318 network:
1319 enabled: true
1320 network_manager: true
1321
Dzmitry Stremkouski00cdbe62018-10-31 16:41:54 +01001322Execute linux.network.interface state without ifupdown activity:
1323
1324.. code-block:: bash
1325
1326 salt-call linux.network.interface pillar='{"linux":{"network":{"noifupdown":True}}}'
1327
1328
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001329Linux with default static network interfaces, default gateway
1330interface and DNS servers:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001331
1332.. code-block:: yaml
1333
1334 linux:
1335 network:
1336 enabled: true
1337 interface:
1338 eth0:
1339 enabled: true
1340 type: eth
1341 address: 192.168.0.102
1342 netmask: 255.255.255.0
1343 gateway: 192.168.0.1
1344 name_servers:
1345 - 8.8.8.8
1346 - 8.8.4.4
1347 mtu: 1500
1348
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001349Linux with bonded interfaces and disabled ``NetworkManager``:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001350
1351.. code-block:: yaml
1352
1353 linux:
1354 network:
1355 enabled: true
1356 interface:
1357 eth0:
1358 type: eth
1359 ...
1360 eth1:
1361 type: eth
1362 ...
1363 bond0:
1364 enabled: true
1365 type: bond
1366 address: 192.168.0.102
1367 netmask: 255.255.255.0
1368 mtu: 1500
1369 use_in:
1370 - interface: ${linux:interface:eth0}
1371 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +01001372 network_manager:
1373 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001374
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001375Linux with VLAN ``interface_params``:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001376
1377.. code-block:: yaml
1378
1379 linux:
1380 network:
1381 enabled: true
1382 interface:
1383 vlan69:
1384 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +01001385 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001386 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001387
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001388Linux with wireless interface parameters:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001389
1390.. code-block:: yaml
1391
1392 linux:
1393 network:
1394 enabled: true
1395 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001396 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001397 interface:
1398 wlan0:
1399 type: eth
1400 wireless:
1401 essid: example
1402 key: example_key
1403 security: wpa
1404 priority: 1
1405
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001406Linux networks with routes defined:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001407
1408.. code-block:: yaml
1409
1410 linux:
1411 network:
1412 enabled: true
1413 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001414 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001415 interface:
1416 eth0:
1417 type: eth
1418 route:
1419 default:
1420 address: 192.168.0.123
1421 netmask: 255.255.255.0
1422 gateway: 192.168.0.1
1423
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001424Native Linux Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001425
1426.. code-block:: yaml
1427
1428 linux:
1429 network:
1430 interface:
1431 eth1:
1432 enabled: true
1433 type: eth
1434 proto: manual
1435 up_cmds:
1436 - ip address add 0/0 dev $IFACE
1437 - ip link set $IFACE up
1438 down_cmds:
1439 - ip link set $IFACE down
1440 br-ex:
1441 enabled: true
1442 type: bridge
1443 address: ${linux:network:host:public_local:address}
1444 netmask: 255.255.255.0
1445 use_interfaces:
1446 - eth1
1447
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001448Open vSwitch Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001449
1450.. code-block:: yaml
1451
1452 linux:
1453 network:
1454 bridge: openvswitch
1455 interface:
1456 eth1:
1457 enabled: true
1458 type: eth
1459 proto: manual
1460 up_cmds:
1461 - ip address add 0/0 dev $IFACE
1462 - ip link set $IFACE up
1463 down_cmds:
1464 - ip link set $IFACE down
1465 br-ex:
1466 enabled: true
1467 type: bridge
1468 address: ${linux:network:host:public_local:address}
1469 netmask: 255.255.255.0
1470 use_interfaces:
1471 - eth1
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001472 br-prv:
1473 enabled: true
1474 type: ovs_bridge
1475 mtu: 65000
1476 br-ens7:
1477 enabled: true
1478 name: br-ens7
1479 type: ovs_bridge
1480 proto: manual
1481 mtu: 9000
1482 use_interfaces:
1483 - ens7
1484 patch-br-ens7-br-prv:
1485 enabled: true
1486 name: ens7-prv
1487 ovs_type: ovs_port
1488 type: ovs_port
1489 bridge: br-ens7
1490 port_type: patch
1491 peer: prv-ens7
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001492 tag: 109 # [] to unset a tag
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001493 mtu: 65000
1494 patch-br-prv-br-ens7:
1495 enabled: true
1496 name: prv-ens7
1497 bridge: br-prv
1498 ovs_type: ovs_port
1499 type: ovs_port
1500 port_type: patch
1501 peer: ens7-prv
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001502 tag: 109
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001503 mtu: 65000
1504 ens7:
1505 enabled: true
1506 name: ens7
1507 proto: manual
1508 ovs_port_type: OVSPort
1509 type: ovs_port
1510 ovs_bridge: br-ens7
1511 bridge: br-ens7
Filip Pytlounf5383a42015-10-06 16:28:32 +02001512
Petr Jediný8f8ae542017-07-13 16:19:12 +02001513Debian manual proto interfaces
1514
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001515When you are changing interface proto from static in up state
1516to manual, you may need to flush ip addresses. For example,
1517if you want to use the interface and the ip on the bridge.
1518This can be done by setting the ``ipflush_onchange`` to true.
Petr Jediný8f8ae542017-07-13 16:19:12 +02001519
1520.. code-block:: yaml
1521
1522 linux:
1523 network:
1524 interface:
1525 eth1:
1526 enabled: true
1527 type: eth
1528 proto: manual
1529 mtu: 9100
1530 ipflush_onchange: true
1531
Jiri Broulik1a191e32018-01-15 15:54:21 +01001532Debian static proto interfaces
1533
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001534When you are changing interface proto from dhcp in up state to
1535static, you may need to flush ip addresses and restart interface
1536to assign ip address from a managed file. For example, if you wantto
1537use the interface and the ip on the bridge. This can be done by
1538setting the ``ipflush_onchange`` with combination ``restart_on_ipflush``
1539param set to true.
Jiri Broulik1a191e32018-01-15 15:54:21 +01001540
1541.. code-block:: yaml
1542
1543 linux:
1544 network:
1545 interface:
1546 eth1:
1547 enabled: true
1548 type: eth
1549 proto: static
1550 address: 10.1.0.22
1551 netmask: 255.255.255.0
1552 ipflush_onchange: true
1553 restart_on_ipflush: true
Petr Jediný8f8ae542017-07-13 16:19:12 +02001554
Petr Jedinýd577cb52017-06-28 20:17:49 +02001555Concatinating and removing interface files
1556
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001557Debian based distributions have ``/etc/network/interfaces.d/``
1558directory, where you can store configuration of network
1559interfaces in separate files. You can concatinate the files
1560to the defined destination when needed, this operation removes
1561the file from the ``/etc/network/interfaces.d/``. If you just need
1562to remove iface files, you can use the ``remove_iface_files`` key.
Petr Jedinýd577cb52017-06-28 20:17:49 +02001563
1564.. code-block:: yaml
1565
1566 linux:
1567 network:
1568 concat_iface_files:
1569 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
1570 dst: '/etc/network/interfaces'
1571 remove_iface_files:
1572 - '/etc/network/interfaces.d/90-custom.cfg'
1573
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001574Configure DHCP client
Petr Jedinýd577cb52017-06-28 20:17:49 +02001575
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001576None of the keys is mandatory, include only those you really need.
1577For full list of available options under send, supersede, prepend,
1578append refer to dhcp-options(5).
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001579
1580.. code-block:: yaml
1581
1582 linux:
1583 network:
1584 dhclient:
1585 enabled: true
1586 backoff_cutoff: 15
1587 initial_interval: 10
1588 reboot: 10
1589 retry: 60
1590 select_timeout: 0
1591 timeout: 120
1592 send:
1593 - option: host-name
1594 declaration: "= gethostname()"
1595 supersede:
1596 - option: host-name
1597 declaration: "spaceship"
1598 - option: domain-name
1599 declaration: "domain.home"
1600 #- option: arp-cache-timeout
1601 # declaration: 20
1602 prepend:
1603 - option: domain-name-servers
1604 declaration:
1605 - 8.8.8.8
1606 - 8.8.4.4
1607 - option: domain-search
1608 declaration:
1609 - example.com
1610 - eng.example.com
1611 #append:
1612 #- option: domain-name-servers
1613 # declaration: 127.0.0.1
1614 # ip or subnet to reject dhcp offer from
1615 reject:
1616 - 192.33.137.209
1617 - 10.0.2.0/24
1618 request:
1619 - subnet-mask
1620 - broadcast-address
1621 - time-offset
1622 - routers
1623 - domain-name
1624 - domain-name-servers
1625 - domain-search
1626 - host-name
1627 - dhcp6.name-servers
1628 - dhcp6.domain-search
1629 - dhcp6.fqdn
1630 - dhcp6.sntp-servers
1631 - netbios-name-servers
1632 - netbios-scope
1633 - interface-mtu
1634 - rfc3442-classless-static-routes
1635 - ntp-servers
1636 require:
1637 - subnet-mask
1638 - domain-name-servers
1639 # if per interface configuration required add below
1640 interface:
1641 ens2:
1642 initial_interval: 11
1643 reject:
1644 - 192.33.137.210
1645 ens3:
1646 initial_interval: 12
1647 reject:
1648 - 192.33.137.211
1649
Petr Michaleceb14b552017-06-01 10:27:05 +02001650Linux network systemd settings:
1651
1652.. code-block:: yaml
1653
1654 linux:
1655 network:
1656 ...
1657 systemd:
1658 link:
1659 10-iface-dmz:
1660 Match:
1661 MACAddress: c8:5b:67:fa:1a:af
1662 OriginalName: eth0
1663 Link:
1664 Name: dmz0
1665 netdev:
1666 20-bridge-dmz:
1667 match:
1668 name: dmz0
1669 network:
1670 mescription: bridge
1671 bridge: br-dmz0
1672 network:
1673 # works with lowercase, keys are by default capitalized
1674 40-dhcp:
1675 match:
1676 name: '*'
1677 network:
1678 DHCP: yes
1679
Petr Michalec10462bb2017-03-23 19:18:08 +01001680Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +01001681
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001682Use ``/etc/environment`` for static system wide variable assignment
1683after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001684
1685.. code-block:: yaml
1686
1687 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +01001688 system:
1689 env:
1690 BOB_VARIABLE: Alice
1691 ...
1692 BOB_PATH:
1693 - /srv/alice/bin
1694 - /srv/bob/bin
1695 ...
1696 ftp_proxy: none
1697 http_proxy: http://global-http-proxy.host.local:8080
1698 https_proxy: ${linux:system:proxy:https}
1699 no_proxy:
1700 - 192.168.0.80
1701 - 192.168.1.80
1702 - .domain.com
1703 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001704 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001705 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001706 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001707 ftp: ftp://proxy.host.local:2121
1708 http: http://proxy.host.local:3142
1709 https: https://proxy.host.local:3143
1710 noproxy:
1711 - .domain.com
1712 - .local
1713
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001714Configure the ``profile.d`` scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001715
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001716The ``profile.d`` scripts are being sourced during ``.sh`` execution
1717and support variable expansion in opposite to /etc/environment global
1718settings in ``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001719
1720.. code-block:: yaml
1721
1722 linux:
1723 system:
1724 profile:
1725 locales: |
1726 export LANG=C
1727 export LC_ALL=C
1728 ...
1729 vi_flavors.sh: |
1730 export PAGER=view
1731 export EDITOR=vim
1732 alias vi=vim
1733 shell_locales.sh: |
1734 export LANG=en_US
1735 export LC_ALL=en_US.UTF-8
1736 shell_proxies.sh: |
1737 export FTP_PROXY=ftp://127.0.3.3:2121
1738 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001739
Dmitry Teselkina0d31d12018-09-04 14:43:09 +03001740
1741Configure login.defs parameters
1742-------------------------------
1743
1744.. code-block:: yaml
1745
1746 linux:
1747 system:
1748 login_defs:
1749 <opt_name>:
1750 enabled: true
1751 value: <opt_value>
1752
1753<opt_name> is a configurational option defined in 'man login.defs'.
1754<opt_name> is case sensitive, should be UPPERCASE only!
1755
1756
Filip Pytlounf5383a42015-10-06 16:28:32 +02001757Linux with hosts
1758
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001759Parameter ``purge_hosts`` will enforce whole ``/etc/hosts file``,
1760removing entries that are not defined in model except defaults
1761for both IPv4 and IPv6 localhost and hostname as well as FQDN.
Ales Komarek417e8c52017-08-25 15:10:29 +02001762
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001763We recommend using this option to verify that ``/etc/hosts``
1764is always in a clean state. However it is not enabled by default
1765for security reasons.
Filip Pytloun86506fe2017-01-26 14:36:16 +01001766
Filip Pytlounf5383a42015-10-06 16:28:32 +02001767.. code-block:: yaml
1768
1769 linux:
1770 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001771 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001772 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001773 # No need to define this one if purge_hosts is true
1774 hostname:
1775 address: 127.0.1.1
1776 names:
1777 - ${linux:network:fqdn}
1778 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001779 node1:
1780 address: 192.168.10.200
1781 names:
1782 - node2.domain.com
1783 - service2.domain.com
1784 node2:
1785 address: 192.168.10.201
1786 names:
1787 - node2.domain.com
1788 - service2.domain.com
1789
Ales Komarek417e8c52017-08-25 15:10:29 +02001790Linux with hosts collected from mine
1791
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001792All DNS records defined within infrastrucuture
1793are passed to the local hosts records or any DNS server. Only
1794hosts with the ``grain`` parameter set to ``true`` will be propagated
1795to the mine.
Ales Komarek417e8c52017-08-25 15:10:29 +02001796
1797.. code-block:: yaml
1798
1799 linux:
1800 network:
1801 purge_hosts: true
1802 mine_dns_records: true
1803 host:
1804 node1:
1805 address: 192.168.10.200
1806 grain: true
1807 names:
1808 - node2.domain.com
1809 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01001810
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001811Set up ``resolv.conf``, nameservers, domain and search domains:
Filip Pytlounde9bea52016-01-11 15:39:10 +01001812
1813.. code-block:: yaml
1814
1815 linux:
1816 network:
1817 resolv:
1818 dns:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001819 - 8.8.4.4
1820 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01001821 domain: my.example.com
1822 search:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001823 - my.example.com
1824 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01001825 options:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001826 - ndots: 5
1827 - timeout: 2
1828 - attempts: 2
Filip Pytlounde9bea52016-01-11 15:39:10 +01001829
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001830Set up custom TX queue length for tap interfaces:
Andrii Petrenko735761d2017-03-21 17:17:35 -07001831
1832.. code-block:: yaml
1833
1834 linux:
1835 network:
1836 tap_custom_txqueuelen: 10000
1837
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001838DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001839
1840**DPDK OVS NIC**
1841
1842.. code-block:: yaml
1843
1844 linux:
1845 network:
1846 bridge: openvswitch
1847 dpdk:
1848 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001849 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001850 openvswitch:
1851 pmd_cpu_mask: "0x6"
1852 dpdk_socket_mem: "1024,1024"
1853 dpdk_lcore_mask: "0x400"
1854 memory_channels: 2
1855 interface:
1856 dpkd0:
1857 name: ${_param:dpdk_nic}
1858 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001859 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001860 enabled: true
1861 type: dpdk_ovs_port
1862 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001863 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001864 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01001865 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001866 br-prv:
1867 enabled: true
1868 type: dpdk_ovs_bridge
1869
1870**DPDK OVS Bond**
1871
1872.. code-block:: yaml
1873
1874 linux:
1875 network:
1876 bridge: openvswitch
1877 dpdk:
1878 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001879 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001880 openvswitch:
1881 pmd_cpu_mask: "0x6"
1882 dpdk_socket_mem: "1024,1024"
1883 dpdk_lcore_mask: "0x400"
1884 memory_channels: 2
1885 interface:
1886 dpdk_second_nic:
1887 name: ${_param:primary_second_nic}
1888 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001889 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001890 bond: dpdkbond0
1891 enabled: true
1892 type: dpdk_ovs_port
1893 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001894 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001895 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001896 dpdk_first_nic:
1897 name: ${_param:primary_first_nic}
1898 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001899 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001900 bond: dpdkbond0
1901 enabled: true
1902 type: dpdk_ovs_port
1903 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001904 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001905 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001906 dpdkbond0:
1907 enabled: true
1908 bridge: br-prv
1909 type: dpdk_ovs_bond
1910 mode: active-backup
1911 br-prv:
1912 enabled: true
1913 type: dpdk_ovs_bridge
1914
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01001915**DPDK OVS LACP Bond with vlan tag**
1916
1917.. code-block:: yaml
1918
1919 linux:
1920 network:
1921 bridge: openvswitch
1922 dpdk:
1923 enabled: true
1924 driver: uio
1925 openvswitch:
1926 pmd_cpu_mask: "0x6"
1927 dpdk_socket_mem: "1024,1024"
1928 dpdk_lcore_mask: "0x400"
1929 memory_channels: "2"
1930 interface:
1931 eth3:
1932 enabled: true
1933 type: eth
1934 proto: manual
1935 name: ${_param:tenant_first_nic}
1936 eth4:
1937 enabled: true
1938 type: eth
1939 proto: manual
1940 name: ${_param:tenant_second_nic}
1941 dpdk0:
1942 name: ${_param:tenant_first_nic}
1943 pci: "0000:81:00.0"
1944 driver: igb_uio
1945 bond: bond1
1946 enabled: true
1947 type: dpdk_ovs_port
1948 n_rxq: 2
1949 dpdk1:
1950 name: ${_param:tenant_second_nic}
1951 pci: "0000:81:00.1"
1952 driver: igb_uio
1953 bond: bond1
1954 enabled: true
1955 type: dpdk_ovs_port
1956 n_rxq: 2
1957 bond1:
1958 enabled: true
1959 bridge: br-prv
1960 type: dpdk_ovs_bond
1961 mode: balance-slb
1962 br-prv:
1963 enabled: true
1964 type: dpdk_ovs_bridge
1965 tag: ${_param:tenant_vlan}
1966 address: ${_param:tenant_address}
1967 netmask: ${_param:tenant_network_netmask}
1968
Jakub Pavlikaa759062017-03-13 15:57:26 +01001969**DPDK OVS bridge for VXLAN**
1970
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001971If VXLAN is used as tenant segmentation, IP address must
1972be set on ``br-prv``.
Jakub Pavlikaa759062017-03-13 15:57:26 +01001973
1974.. code-block:: yaml
1975
1976 linux:
1977 network:
1978 ...
1979 interface:
1980 br-prv:
1981 enabled: true
1982 type: dpdk_ovs_bridge
1983 address: 192.168.50.0
1984 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04001985 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01001986 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001987
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02001988**DPDK OVS bridge with Linux network interface**
1989
1990.. code-block:: yaml
1991
1992 linux:
1993 network:
1994 ...
1995 interface:
1996 eth0:
1997 type: eth
1998 ovs_bridge: br-prv
1999 ...
2000 br-prv:
2001 enabled: true
2002 type: dpdk_ovs_bridge
2003 ...
2004
Jakub Pavlik21ca2152017-02-27 22:21:09 +01002005Linux storage
2006-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02002007
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002008Linux with mounted Samba:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002009
2010.. code-block:: yaml
2011
2012 linux:
2013 storage:
2014 enabled: true
2015 mount:
2016 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01002017 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02002018 - path: /media/myuser/public/
2019 - device: //192.168.0.1/storage
2020 - file_system: cifs
2021 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
2022
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002023NFS mount:
Jiri Broulikb017f932017-03-31 13:55:36 +02002024
2025.. code-block:: yaml
2026
2027 linux:
2028 storage:
2029 enabled: true
2030 mount:
2031 nfs_glance:
2032 enabled: true
2033 path: /var/lib/glance/images
2034 device: 172.16.10.110:/var/nfs/glance
2035 file_system: nfs
2036 opts: rw,sync
2037
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002038File swap configuration:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002039
2040.. code-block:: yaml
2041
2042 linux:
2043 storage:
2044 enabled: true
2045 swap:
2046 file:
2047 enabled: true
2048 engine: file
2049 device: /swapfile
2050 size: 1024
2051
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002052Partition swap configuration:
Lachlan Evenson30676512016-01-22 15:43:28 -08002053
2054.. code-block:: yaml
2055
2056 linux:
2057 storage:
2058 enabled: true
2059 swap:
2060 partition:
2061 enabled: true
2062 engine: partition
2063 device: /dev/vg0/swap
2064
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002065LVM group ``vg1`` with one device and ``data`` volume mounted
2066into ``/mnt/data``.
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002067
2068.. code-block:: yaml
2069
2070 parameters:
2071 linux:
2072 storage:
2073 mount:
2074 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01002075 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002076 device: /dev/vg1/data
2077 file_system: ext4
2078 path: /mnt/data
2079 lvm:
2080 vg1:
2081 enabled: true
2082 devices:
2083 - /dev/sdb
2084 volume:
2085 data:
2086 size: 40G
2087 mount: ${linux:storage:mount:data}
2088
Jakub Pavlik4f742142017-08-08 15:05:50 +02002089Create partitions on disk. Specify size in MB. It expects empty
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002090disk without any existing partitions.
2091Set ``startsector=1`` if you want to start partitions from ``2048``.
Jakub Pavlik4f742142017-08-08 15:05:50 +02002092
2093.. code-block:: yaml
2094
2095 linux:
2096 storage:
2097 disk:
2098 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01002099 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02002100 name: /dev/loop1
2101 type: gpt
2102 partitions:
2103 - size: 200 #size in MB
2104 type: fat32
2105 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02002106 mkfs: True
2107 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02002108 /dev/vda1:
2109 partitions:
2110 - size: 5
2111 type: ext2
2112 - size: 10
2113 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02002114
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002115Multipath with Fujitsu Eternus DXL:
Ales Komareka634f4b2016-10-02 13:11:04 +02002116
2117.. code-block:: yaml
2118
2119 parameters:
2120 linux:
2121 storage:
2122 multipath:
2123 enabled: true
2124 blacklist_devices:
2125 - /dev/sda
2126 - /dev/sdb
2127 backends:
2128 - fujitsu_eternus_dxl
2129
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002130Multipath with Hitachi VSP 1000:
Ales Komareka634f4b2016-10-02 13:11:04 +02002131
2132.. code-block:: yaml
2133
2134 parameters:
2135 linux:
2136 storage:
2137 multipath:
2138 enabled: true
2139 blacklist_devices:
2140 - /dev/sda
2141 - /dev/sdb
2142 backends:
2143 - hitachi_vsp1000
2144
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002145Multipath with IBM Storwize:
Ales Komareka634f4b2016-10-02 13:11:04 +02002146
2147.. code-block:: yaml
2148
2149 parameters:
2150 linux:
2151 storage:
2152 multipath:
2153 enabled: true
2154 blacklist_devices:
2155 - /dev/sda
2156 - /dev/sdb
2157 backends:
2158 - ibm_storwize
2159
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002160Multipath with multiple backends:
Ales Komareka634f4b2016-10-02 13:11:04 +02002161
2162.. code-block:: yaml
2163
2164 parameters:
2165 linux:
2166 storage:
2167 multipath:
2168 enabled: true
2169 blacklist_devices:
2170 - /dev/sda
2171 - /dev/sdb
2172 - /dev/sdc
2173 - /dev/sdd
2174 backends:
2175 - ibm_storwize
2176 - fujitsu_eternus_dxl
2177 - hitachi_vsp1000
2178
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002179PAM LDAP integration:
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002180
2181.. code-block:: yaml
2182
2183 parameters:
2184 linux:
2185 system:
2186 auth:
2187 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02002188 mkhomedir:
2189 enabled: true
2190 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002191 ldap:
2192 enabled: true
2193 binddn: cn=bind,ou=service_users,dc=example,dc=com
2194 bindpw: secret
2195 uri: ldap://127.0.0.1
2196 base: ou=users,dc=example,dc=com
2197 ldap_version: 3
2198 pagesize: 65536
2199 referrals: off
2200 filter:
2201 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2202 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2203 group: (&(objectClass=group)(gidNumber=*))
2204
Gleb Galkin93b9ae92018-10-18 13:57:30 +03002205PAM duo 2FA integration
2206
2207.. code-block:: yaml
2208
2209 parameters:
2210 linux:
2211 system:
2212 auth:
2213 enabled: true
2214 duo:
2215 enabled: true
2216 duo_host: localhost
2217 duo_ikey: DUO-INTEGRATION-KEY
2218 duo_skey: DUO-SECRET-KEY
2219
2220duo package version may be specified (optional)
2221
2222.. code-block:: yaml
2223
2224 linux:
2225 system:
2226 package:
2227 duo-unix:
2228 version: 1.10.1-0
2229
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002230Disabled multipath (the default setup):
Ales Komareka634f4b2016-10-02 13:11:04 +02002231
2232.. code-block:: yaml
2233
2234 parameters:
2235 linux:
2236 storage:
2237 multipath:
2238 enabled: false
2239
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002240Linux with local loopback device:
Simon Pasquier375001e2017-01-26 13:22:33 +01002241
2242.. code-block:: yaml
2243
2244 linux:
2245 storage:
2246 loopback:
2247 disk1:
2248 file: /srv/disk1
2249 size: 50G
2250
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002251External config generation
2252--------------------------
2253
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002254You are able to use config support metadata between formulas
2255and only generate configuration files for external use, for example, Docker, and so on.
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002256
2257.. code-block:: yaml
2258
2259 parameters:
2260 linux:
2261 system:
2262 config:
2263 pillar:
2264 jenkins:
2265 master:
2266 home: /srv/volumes/jenkins
2267 approved_scripts:
2268 - method java.net.URL openConnection
2269 credentials:
2270 - type: username_password
2271 scope: global
2272 id: test
2273 desc: Testing credentials
2274 username: test
2275 password: test
2276
Vladimir Ereminccf28842017-04-10 23:52:10 +03002277Netconsole Remote Kernel Logging
2278--------------------------------
2279
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002280Netconsole logger can be configured for the configfs-enabled kernels
2281(``CONFIG_NETCONSOLE_DYNAMIC`` must be enabled). The configuration
2282applies both in runtime (if network is already configured),
2283and on-boot after an interface initialization.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002284
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002285.. note::
2286
2287 * Receiver can be located only on the same L3 domain
2288 (or you need to configure gateway MAC manually).
2289 * The Receiver MAC is detected only on configuration time.
2290 * Using broadcast MAC is not recommended.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002291
2292.. code-block:: yaml
2293
2294 parameters:
2295 linux:
2296 system:
2297 netconsole:
2298 enabled: true
2299 port: 514 (optional)
2300 loglevel: debug (optional)
2301 target:
2302 192.168.0.1:
2303 interface: bond0
2304 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02002305
Dzmitry Stremkouskid1a268b2018-10-03 16:36:04 +02002306Check network params on the environment
2307---------------------------------------
2308
2309Grab nics and nics states
2310
2311.. code-block:: bash
2312
2313 salt osd001\* net_checks.get_nics
2314
2315**Example of system output:**
2316
2317.. code-block:: bash
2318
2319 osd001.domain.com:
2320 |_
2321 - bond0
2322 - None
2323 - 1e:c8:64:42:23:b9
2324 - 0
2325 - 1500
2326 |_
2327 - bond1
2328 - None
2329 - 3c:fd:fe:27:3b:00
2330 - 1
2331 - 9100
2332 |_
2333 - fourty1
2334 - None
2335 - 3c:fd:fe:27:3b:00
2336 - 1
2337 - 9100
2338 |_
2339 - fourty2
2340 - None
2341 - 3c:fd:fe:27:3b:02
2342 - 1
2343 - 9100
2344
2345Grab 10G nics PCI addresses for hugepages setup
2346
2347.. code-block:: bash
2348
2349 salt cmp001\* net_checks.get_ten_pci
2350
2351**Example of system output:**
2352
2353.. code-block:: bash
2354
2355 cmp001.domain.com:
2356 |_
2357 - ten1
2358 - 0000:19:00.0
2359 |_
2360 - ten2
2361 - 0000:19:00.1
2362 |_
2363 - ten3
2364 - 0000:19:00.2
2365 |_
2366 - ten4
2367 - 0000:19:00.3
2368
2369Grab ip address for an interface
2370
2371.. code-block:: bash
2372
2373 salt cmp001\* net_checks.get_ip iface=one4
2374
2375**Example of system output:**
2376
2377.. code-block:: bash
2378
2379 cmp001.domain.com:
2380 10.200.177.101
2381
2382Grab ip addresses map
2383
2384.. code-block:: bash
2385
2386 salt-call net_checks.nodes_addresses
2387
2388**Example of system output:**
2389
2390.. code-block:: bash
2391
2392 local:
2393 |_
2394 - cid01.domain.com
2395 |_
2396 |_
2397 - pxe
2398 - 10.200.177.91
2399 |_
2400 - control
2401 - 10.200.178.91
2402 |_
2403 - cmn02.domain.com
2404 |_
2405 |_
2406 - storage_access
2407 - 10.200.181.67
2408 |_
2409 - pxe
2410 - 10.200.177.67
2411 |_
2412 - control
2413 - 10.200.178.67
2414 |_
2415 - cmp010.domain.com
2416 |_
2417 |_
2418 - pxe
2419 - 10.200.177.110
2420 |_
2421 - storage_access
2422 - 10.200.181.110
2423 |_
2424 - control
2425 - 10.200.178.110
2426 |_
2427 - vxlan
2428 - 10.200.179.110
2429
2430Verify full mesh connectivity
2431
2432.. code-block:: bash
2433
2434 salt-call net_checks.ping_check
2435
2436**Example of positive system output:**
2437
2438.. code-block:: bash
2439
2440 ['PASSED']
2441 [INFO ] ['PASSED']
2442 local:
2443 True
2444
2445**Example of system output in case of failure:**
2446
2447.. code-block:: bash
2448
2449 FAILED
2450 [ERROR ] FAILED
2451 ['control: 10.0.1.92 -> 10.0.1.224: Failed']
2452 ['control: 10.0.1.93 -> 10.0.1.224: Failed']
2453 ['control: 10.0.1.51 -> 10.0.1.224: Failed']
2454 ['control: 10.0.1.102 -> 10.0.1.224: Failed']
2455 ['control: 10.0.1.13 -> 10.0.1.224: Failed']
2456 ['control: 10.0.1.81 -> 10.0.1.224: Failed']
2457 local:
2458 False
2459
2460For this feature to work, please mark addresses with some role.
2461Otherwise 'default' role is assumed and mesh would consist of all
2462addresses on the environment.
2463
2464Mesh mark is needed only for interfaces which are enabled and have
2465ip address assigned.
2466
2467Checking dhcp pxe network meaningless, as it is used for salt
2468master vs minion communications, therefore treated as checked.
2469
2470.. code-block:: yaml
2471
2472 parameters:
2473 linux:
2474 network:
2475 interface:
2476 ens3:
2477 enabled: true
2478 type: eth
2479 proto: static
2480 address: ${_param:deploy_address}
2481 netmask: ${_param:deploy_network_netmask}
2482 gateway: ${_param:deploy_network_gateway}
2483 mesh: pxe
2484
2485Check pillars for ip address duplicates
2486
2487.. code-block:: bash
2488
2489 salt-call net_checks.verify_addresses
2490
2491**Example of positive system output:**
2492
2493.. code-block:: bash
2494
2495 ['PASSED']
2496 [INFO ] ['PASSED']
2497 local:
2498 True
2499
2500**Example of system output in case of failure:**
2501
2502.. code-block:: bash
2503
2504 FAILED. Duplicates found
2505 [ERROR ] FAILED. Duplicates found
2506 ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2507 [ERROR ] ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2508 local:
2509 False
2510
2511Generate csv report for the env
2512
2513.. code-block:: bash
2514
2515 salt -C 'kvm* or cmp* or osd*' net_checks.get_nics_csv \
2516 | grep '^\ ' | sed 's/\ *//g' | grep -Ev ^server \
2517 | sed '1 i\server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr'
2518
2519**Example of system output:**
2520
2521.. code-block:: bash
2522
2523 server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr
2524 cmp010.domain.com,bond0,None,b4:96:91:10:5b:3a,1,1500,,,,
2525 cmp010.domain.com,bond0.21,10.200.178.110,b4:96:91:10:5b:3a,1,1500,,,,
2526 cmp010.domain.com,bond0.22,10.200.179.110,b4:96:91:10:5b:3a,1,1500,,,,
2527 cmp010.domain.com,bond1,None,3c:fd:fe:34:ad:22,0,1500,,,,
2528 cmp010.domain.com,bond1.24,10.200.181.110,3c:fd:fe:34:ad:22,0,1500,,,,
2529 cmp010.domain.com,fourty5,None,3c:fd:fe:34:ad:20,0,9000,,,,
2530 cmp010.domain.com,fourty6,None,3c:fd:fe:34:ad:22,0,9000,,,,
2531 cmp010.domain.com,one1,None,b4:96:91:10:5b:38,0,1500,,,,
2532 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
2533 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
2534 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
2535 cmp011.domain.com,bond0,None,b4:96:91:13:6c:aa,1,1500,,,,
2536 cmp011.domain.com,bond0.21,10.200.178.111,b4:96:91:13:6c:aa,1,1500,,,,
2537 cmp011.domain.com,bond0.22,10.200.179.111,b4:96:91:13:6c:aa,1,1500,,,,
2538 ...
2539
Filip Pytlounf5383a42015-10-06 16:28:32 +02002540Usage
2541=====
2542
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002543Set MTU of the eth0 network interface to 1400:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002544
2545.. code-block:: bash
2546
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002547 ip link set dev eth0 mtu 1400
Filip Pytlounf5383a42015-10-06 16:28:32 +02002548
2549Read more
2550=========
2551
2552* https://www.archlinux.org/
2553* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu