blob: 0db113f9e7cf1acd085012939ebc8843c7a4ef77 [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
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001234Possible statuses are ``dead`` (disable service by default), ``running``
1235(enable service by default), ``enabled``, ``disabled``:
Marek Celoud713e9072017-05-18 15:20:25 +02001236
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001237Linux with the ``atop`` service:
Serhiy Ovsianikov67bd56a2017-08-11 15:56:01 +03001238
1239.. code-block:: yaml
1240
1241 linux:
1242 system:
1243 atop:
1244 enabled: true
1245 interval: 20
1246 logpath: "/var/log/atop"
1247 outfile: "/var/log/atop/daily.log"
1248
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001249Linux with the ``mcelog`` service:
Oleksii Chupryn144432b2018-05-22 10:34:48 +03001250
1251.. code-block:: yaml
1252
1253 linux:
1254 system:
1255 mcelog:
1256 enabled: true
1257 logging:
1258 syslog: true
1259 syslog_error: true
1260
Filip Pytloun2f70b492016-02-19 15:55:25 +01001261RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +01001262^^^^^^^^^^^^^
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001263Currently, ``update-motd`` is not available
1264for RHEL. So there is no native support for dynamic ``motd``.
1265You can still set a static one, with a different pillar structure:
Filip Pytloun2f70b492016-02-19 15:55:25 +01001266
1267.. code-block:: yaml
1268
1269 linux:
1270 system:
1271 motd: |
1272 This is [company name] network.
1273 Unauthorized access strictly prohibited.
1274
Filip Pytloun8296bb92016-02-19 18:42:09 +01001275Haveged
1276~~~~~~~
1277
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001278If you are running headless server and are low on entropy,
1279you may set up Haveged:
Filip Pytloun8296bb92016-02-19 18:42:09 +01001280
1281.. code-block:: yaml
1282
1283 linux:
1284 system:
1285 haveged:
1286 enabled: true
1287
Filip Pytlounf5383a42015-10-06 16:28:32 +02001288Linux network
1289-------------
1290
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001291Linux with network manager:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001292
1293.. code-block:: yaml
1294
1295 linux:
1296 network:
1297 enabled: true
1298 network_manager: true
1299
Dzmitry Stremkouski00cdbe62018-10-31 16:41:54 +01001300Execute linux.network.interface state without ifupdown activity:
1301
1302.. code-block:: bash
1303
1304 salt-call linux.network.interface pillar='{"linux":{"network":{"noifupdown":True}}}'
1305
1306
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001307Linux with default static network interfaces, default gateway
1308interface and DNS servers:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001309
1310.. code-block:: yaml
1311
1312 linux:
1313 network:
1314 enabled: true
1315 interface:
1316 eth0:
1317 enabled: true
1318 type: eth
1319 address: 192.168.0.102
1320 netmask: 255.255.255.0
1321 gateway: 192.168.0.1
1322 name_servers:
1323 - 8.8.8.8
1324 - 8.8.4.4
1325 mtu: 1500
1326
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001327Linux with bonded interfaces and disabled ``NetworkManager``:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001328
1329.. code-block:: yaml
1330
1331 linux:
1332 network:
1333 enabled: true
1334 interface:
1335 eth0:
1336 type: eth
1337 ...
1338 eth1:
1339 type: eth
1340 ...
1341 bond0:
1342 enabled: true
1343 type: bond
1344 address: 192.168.0.102
1345 netmask: 255.255.255.0
1346 mtu: 1500
1347 use_in:
1348 - interface: ${linux:interface:eth0}
1349 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +01001350 network_manager:
1351 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001352
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001353Linux with VLAN ``interface_params``:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001354
1355.. code-block:: yaml
1356
1357 linux:
1358 network:
1359 enabled: true
1360 interface:
1361 vlan69:
1362 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +01001363 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001364 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001365
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001366Linux with wireless interface parameters:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001367
1368.. code-block:: yaml
1369
1370 linux:
1371 network:
1372 enabled: true
1373 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001374 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001375 interface:
1376 wlan0:
1377 type: eth
1378 wireless:
1379 essid: example
1380 key: example_key
1381 security: wpa
1382 priority: 1
1383
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001384Linux networks with routes defined:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001385
1386.. code-block:: yaml
1387
1388 linux:
1389 network:
1390 enabled: true
1391 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001392 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001393 interface:
1394 eth0:
1395 type: eth
1396 route:
1397 default:
1398 address: 192.168.0.123
1399 netmask: 255.255.255.0
1400 gateway: 192.168.0.1
1401
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001402Native Linux Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001403
1404.. code-block:: yaml
1405
1406 linux:
1407 network:
1408 interface:
1409 eth1:
1410 enabled: true
1411 type: eth
1412 proto: manual
1413 up_cmds:
1414 - ip address add 0/0 dev $IFACE
1415 - ip link set $IFACE up
1416 down_cmds:
1417 - ip link set $IFACE down
1418 br-ex:
1419 enabled: true
1420 type: bridge
1421 address: ${linux:network:host:public_local:address}
1422 netmask: 255.255.255.0
1423 use_interfaces:
1424 - eth1
1425
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001426Open vSwitch Bridges:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001427
1428.. code-block:: yaml
1429
1430 linux:
1431 network:
1432 bridge: openvswitch
1433 interface:
1434 eth1:
1435 enabled: true
1436 type: eth
1437 proto: manual
1438 up_cmds:
1439 - ip address add 0/0 dev $IFACE
1440 - ip link set $IFACE up
1441 down_cmds:
1442 - ip link set $IFACE down
1443 br-ex:
1444 enabled: true
1445 type: bridge
1446 address: ${linux:network:host:public_local:address}
1447 netmask: 255.255.255.0
1448 use_interfaces:
1449 - eth1
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001450 br-prv:
1451 enabled: true
1452 type: ovs_bridge
1453 mtu: 65000
1454 br-ens7:
1455 enabled: true
1456 name: br-ens7
1457 type: ovs_bridge
1458 proto: manual
1459 mtu: 9000
1460 use_interfaces:
1461 - ens7
1462 patch-br-ens7-br-prv:
1463 enabled: true
1464 name: ens7-prv
1465 ovs_type: ovs_port
1466 type: ovs_port
1467 bridge: br-ens7
1468 port_type: patch
1469 peer: prv-ens7
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001470 tag: 109 # [] to unset a tag
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001471 mtu: 65000
1472 patch-br-prv-br-ens7:
1473 enabled: true
1474 name: prv-ens7
1475 bridge: br-prv
1476 ovs_type: ovs_port
1477 type: ovs_port
1478 port_type: patch
1479 peer: ens7-prv
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001480 tag: 109
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001481 mtu: 65000
1482 ens7:
1483 enabled: true
1484 name: ens7
1485 proto: manual
1486 ovs_port_type: OVSPort
1487 type: ovs_port
1488 ovs_bridge: br-ens7
1489 bridge: br-ens7
Filip Pytlounf5383a42015-10-06 16:28:32 +02001490
Petr Jediný8f8ae542017-07-13 16:19:12 +02001491Debian manual proto interfaces
1492
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001493When you are changing interface proto from static in up state
1494to manual, you may need to flush ip addresses. For example,
1495if you want to use the interface and the ip on the bridge.
1496This can be done by setting the ``ipflush_onchange`` to true.
Petr Jediný8f8ae542017-07-13 16:19:12 +02001497
1498.. code-block:: yaml
1499
1500 linux:
1501 network:
1502 interface:
1503 eth1:
1504 enabled: true
1505 type: eth
1506 proto: manual
1507 mtu: 9100
1508 ipflush_onchange: true
1509
Jiri Broulik1a191e32018-01-15 15:54:21 +01001510Debian static proto interfaces
1511
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001512When you are changing interface proto from dhcp in up state to
1513static, you may need to flush ip addresses and restart interface
1514to assign ip address from a managed file. For example, if you wantto
1515use the interface and the ip on the bridge. This can be done by
1516setting the ``ipflush_onchange`` with combination ``restart_on_ipflush``
1517param set to true.
Jiri Broulik1a191e32018-01-15 15:54:21 +01001518
1519.. code-block:: yaml
1520
1521 linux:
1522 network:
1523 interface:
1524 eth1:
1525 enabled: true
1526 type: eth
1527 proto: static
1528 address: 10.1.0.22
1529 netmask: 255.255.255.0
1530 ipflush_onchange: true
1531 restart_on_ipflush: true
Petr Jediný8f8ae542017-07-13 16:19:12 +02001532
Petr Jedinýd577cb52017-06-28 20:17:49 +02001533Concatinating and removing interface files
1534
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001535Debian based distributions have ``/etc/network/interfaces.d/``
1536directory, where you can store configuration of network
1537interfaces in separate files. You can concatinate the files
1538to the defined destination when needed, this operation removes
1539the file from the ``/etc/network/interfaces.d/``. If you just need
1540to remove iface files, you can use the ``remove_iface_files`` key.
Petr Jedinýd577cb52017-06-28 20:17:49 +02001541
1542.. code-block:: yaml
1543
1544 linux:
1545 network:
1546 concat_iface_files:
1547 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
1548 dst: '/etc/network/interfaces'
1549 remove_iface_files:
1550 - '/etc/network/interfaces.d/90-custom.cfg'
1551
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001552Configure DHCP client
Petr Jedinýd577cb52017-06-28 20:17:49 +02001553
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001554None of the keys is mandatory, include only those you really need.
1555For full list of available options under send, supersede, prepend,
1556append refer to dhcp-options(5).
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001557
1558.. code-block:: yaml
1559
1560 linux:
1561 network:
1562 dhclient:
1563 enabled: true
1564 backoff_cutoff: 15
1565 initial_interval: 10
1566 reboot: 10
1567 retry: 60
1568 select_timeout: 0
1569 timeout: 120
1570 send:
1571 - option: host-name
1572 declaration: "= gethostname()"
1573 supersede:
1574 - option: host-name
1575 declaration: "spaceship"
1576 - option: domain-name
1577 declaration: "domain.home"
1578 #- option: arp-cache-timeout
1579 # declaration: 20
1580 prepend:
1581 - option: domain-name-servers
1582 declaration:
1583 - 8.8.8.8
1584 - 8.8.4.4
1585 - option: domain-search
1586 declaration:
1587 - example.com
1588 - eng.example.com
1589 #append:
1590 #- option: domain-name-servers
1591 # declaration: 127.0.0.1
1592 # ip or subnet to reject dhcp offer from
1593 reject:
1594 - 192.33.137.209
1595 - 10.0.2.0/24
1596 request:
1597 - subnet-mask
1598 - broadcast-address
1599 - time-offset
1600 - routers
1601 - domain-name
1602 - domain-name-servers
1603 - domain-search
1604 - host-name
1605 - dhcp6.name-servers
1606 - dhcp6.domain-search
1607 - dhcp6.fqdn
1608 - dhcp6.sntp-servers
1609 - netbios-name-servers
1610 - netbios-scope
1611 - interface-mtu
1612 - rfc3442-classless-static-routes
1613 - ntp-servers
1614 require:
1615 - subnet-mask
1616 - domain-name-servers
1617 # if per interface configuration required add below
1618 interface:
1619 ens2:
1620 initial_interval: 11
1621 reject:
1622 - 192.33.137.210
1623 ens3:
1624 initial_interval: 12
1625 reject:
1626 - 192.33.137.211
1627
Petr Michaleceb14b552017-06-01 10:27:05 +02001628Linux network systemd settings:
1629
1630.. code-block:: yaml
1631
1632 linux:
1633 network:
1634 ...
1635 systemd:
1636 link:
1637 10-iface-dmz:
1638 Match:
1639 MACAddress: c8:5b:67:fa:1a:af
1640 OriginalName: eth0
1641 Link:
1642 Name: dmz0
1643 netdev:
1644 20-bridge-dmz:
1645 match:
1646 name: dmz0
1647 network:
1648 mescription: bridge
1649 bridge: br-dmz0
1650 network:
1651 # works with lowercase, keys are by default capitalized
1652 40-dhcp:
1653 match:
1654 name: '*'
1655 network:
1656 DHCP: yes
1657
Petr Michalec10462bb2017-03-23 19:18:08 +01001658Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +01001659
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001660Use ``/etc/environment`` for static system wide variable assignment
1661after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001662
1663.. code-block:: yaml
1664
1665 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +01001666 system:
1667 env:
1668 BOB_VARIABLE: Alice
1669 ...
1670 BOB_PATH:
1671 - /srv/alice/bin
1672 - /srv/bob/bin
1673 ...
1674 ftp_proxy: none
1675 http_proxy: http://global-http-proxy.host.local:8080
1676 https_proxy: ${linux:system:proxy:https}
1677 no_proxy:
1678 - 192.168.0.80
1679 - 192.168.1.80
1680 - .domain.com
1681 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001682 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001683 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001684 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001685 ftp: ftp://proxy.host.local:2121
1686 http: http://proxy.host.local:3142
1687 https: https://proxy.host.local:3143
1688 noproxy:
1689 - .domain.com
1690 - .local
1691
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001692Configure the ``profile.d`` scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001693
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001694The ``profile.d`` scripts are being sourced during ``.sh`` execution
1695and support variable expansion in opposite to /etc/environment global
1696settings in ``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001697
1698.. code-block:: yaml
1699
1700 linux:
1701 system:
1702 profile:
1703 locales: |
1704 export LANG=C
1705 export LC_ALL=C
1706 ...
1707 vi_flavors.sh: |
1708 export PAGER=view
1709 export EDITOR=vim
1710 alias vi=vim
1711 shell_locales.sh: |
1712 export LANG=en_US
1713 export LC_ALL=en_US.UTF-8
1714 shell_proxies.sh: |
1715 export FTP_PROXY=ftp://127.0.3.3:2121
1716 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001717
Dmitry Teselkina0d31d12018-09-04 14:43:09 +03001718
1719Configure login.defs parameters
1720-------------------------------
1721
1722.. code-block:: yaml
1723
1724 linux:
1725 system:
1726 login_defs:
1727 <opt_name>:
1728 enabled: true
1729 value: <opt_value>
1730
1731<opt_name> is a configurational option defined in 'man login.defs'.
1732<opt_name> is case sensitive, should be UPPERCASE only!
1733
1734
Filip Pytlounf5383a42015-10-06 16:28:32 +02001735Linux with hosts
1736
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001737Parameter ``purge_hosts`` will enforce whole ``/etc/hosts file``,
1738removing entries that are not defined in model except defaults
1739for both IPv4 and IPv6 localhost and hostname as well as FQDN.
Ales Komarek417e8c52017-08-25 15:10:29 +02001740
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001741We recommend using this option to verify that ``/etc/hosts``
1742is always in a clean state. However it is not enabled by default
1743for security reasons.
Filip Pytloun86506fe2017-01-26 14:36:16 +01001744
Filip Pytlounf5383a42015-10-06 16:28:32 +02001745.. code-block:: yaml
1746
1747 linux:
1748 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001749 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001750 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001751 # No need to define this one if purge_hosts is true
1752 hostname:
1753 address: 127.0.1.1
1754 names:
1755 - ${linux:network:fqdn}
1756 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001757 node1:
1758 address: 192.168.10.200
1759 names:
1760 - node2.domain.com
1761 - service2.domain.com
1762 node2:
1763 address: 192.168.10.201
1764 names:
1765 - node2.domain.com
1766 - service2.domain.com
1767
Ales Komarek417e8c52017-08-25 15:10:29 +02001768Linux with hosts collected from mine
1769
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001770All DNS records defined within infrastrucuture
1771are passed to the local hosts records or any DNS server. Only
1772hosts with the ``grain`` parameter set to ``true`` will be propagated
1773to the mine.
Ales Komarek417e8c52017-08-25 15:10:29 +02001774
1775.. code-block:: yaml
1776
1777 linux:
1778 network:
1779 purge_hosts: true
1780 mine_dns_records: true
1781 host:
1782 node1:
1783 address: 192.168.10.200
1784 grain: true
1785 names:
1786 - node2.domain.com
1787 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01001788
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001789Set up ``resolv.conf``, nameservers, domain and search domains:
Filip Pytlounde9bea52016-01-11 15:39:10 +01001790
1791.. code-block:: yaml
1792
1793 linux:
1794 network:
1795 resolv:
1796 dns:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001797 - 8.8.4.4
1798 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01001799 domain: my.example.com
1800 search:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001801 - my.example.com
1802 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01001803 options:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001804 - ndots: 5
1805 - timeout: 2
1806 - attempts: 2
Filip Pytlounde9bea52016-01-11 15:39:10 +01001807
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001808Set up custom TX queue length for tap interfaces:
Andrii Petrenko735761d2017-03-21 17:17:35 -07001809
1810.. code-block:: yaml
1811
1812 linux:
1813 network:
1814 tap_custom_txqueuelen: 10000
1815
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001816DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001817
1818**DPDK OVS NIC**
1819
1820.. code-block:: yaml
1821
1822 linux:
1823 network:
1824 bridge: openvswitch
1825 dpdk:
1826 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001827 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001828 openvswitch:
1829 pmd_cpu_mask: "0x6"
1830 dpdk_socket_mem: "1024,1024"
1831 dpdk_lcore_mask: "0x400"
1832 memory_channels: 2
1833 interface:
1834 dpkd0:
1835 name: ${_param:dpdk_nic}
1836 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001837 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001838 enabled: true
1839 type: dpdk_ovs_port
1840 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001841 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001842 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01001843 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001844 br-prv:
1845 enabled: true
1846 type: dpdk_ovs_bridge
1847
1848**DPDK OVS Bond**
1849
1850.. code-block:: yaml
1851
1852 linux:
1853 network:
1854 bridge: openvswitch
1855 dpdk:
1856 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001857 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001858 openvswitch:
1859 pmd_cpu_mask: "0x6"
1860 dpdk_socket_mem: "1024,1024"
1861 dpdk_lcore_mask: "0x400"
1862 memory_channels: 2
1863 interface:
1864 dpdk_second_nic:
1865 name: ${_param:primary_second_nic}
1866 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001867 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001868 bond: dpdkbond0
1869 enabled: true
1870 type: dpdk_ovs_port
1871 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001872 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001873 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001874 dpdk_first_nic:
1875 name: ${_param:primary_first_nic}
1876 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001877 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001878 bond: dpdkbond0
1879 enabled: true
1880 type: dpdk_ovs_port
1881 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001882 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001883 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001884 dpdkbond0:
1885 enabled: true
1886 bridge: br-prv
1887 type: dpdk_ovs_bond
1888 mode: active-backup
1889 br-prv:
1890 enabled: true
1891 type: dpdk_ovs_bridge
1892
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01001893**DPDK OVS LACP Bond with vlan tag**
1894
1895.. code-block:: yaml
1896
1897 linux:
1898 network:
1899 bridge: openvswitch
1900 dpdk:
1901 enabled: true
1902 driver: uio
1903 openvswitch:
1904 pmd_cpu_mask: "0x6"
1905 dpdk_socket_mem: "1024,1024"
1906 dpdk_lcore_mask: "0x400"
1907 memory_channels: "2"
1908 interface:
1909 eth3:
1910 enabled: true
1911 type: eth
1912 proto: manual
1913 name: ${_param:tenant_first_nic}
1914 eth4:
1915 enabled: true
1916 type: eth
1917 proto: manual
1918 name: ${_param:tenant_second_nic}
1919 dpdk0:
1920 name: ${_param:tenant_first_nic}
1921 pci: "0000:81:00.0"
1922 driver: igb_uio
1923 bond: bond1
1924 enabled: true
1925 type: dpdk_ovs_port
1926 n_rxq: 2
1927 dpdk1:
1928 name: ${_param:tenant_second_nic}
1929 pci: "0000:81:00.1"
1930 driver: igb_uio
1931 bond: bond1
1932 enabled: true
1933 type: dpdk_ovs_port
1934 n_rxq: 2
1935 bond1:
1936 enabled: true
1937 bridge: br-prv
1938 type: dpdk_ovs_bond
1939 mode: balance-slb
1940 br-prv:
1941 enabled: true
1942 type: dpdk_ovs_bridge
1943 tag: ${_param:tenant_vlan}
1944 address: ${_param:tenant_address}
1945 netmask: ${_param:tenant_network_netmask}
1946
Jakub Pavlikaa759062017-03-13 15:57:26 +01001947**DPDK OVS bridge for VXLAN**
1948
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001949If VXLAN is used as tenant segmentation, IP address must
1950be set on ``br-prv``.
Jakub Pavlikaa759062017-03-13 15:57:26 +01001951
1952.. code-block:: yaml
1953
1954 linux:
1955 network:
1956 ...
1957 interface:
1958 br-prv:
1959 enabled: true
1960 type: dpdk_ovs_bridge
1961 address: 192.168.50.0
1962 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04001963 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01001964 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001965
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02001966**DPDK OVS bridge with Linux network interface**
1967
1968.. code-block:: yaml
1969
1970 linux:
1971 network:
1972 ...
1973 interface:
1974 eth0:
1975 type: eth
1976 ovs_bridge: br-prv
1977 ...
1978 br-prv:
1979 enabled: true
1980 type: dpdk_ovs_bridge
1981 ...
1982
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001983Linux storage
1984-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02001985
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03001986Linux with mounted Samba:
Filip Pytlounf5383a42015-10-06 16:28:32 +02001987
1988.. code-block:: yaml
1989
1990 linux:
1991 storage:
1992 enabled: true
1993 mount:
1994 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01001995 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001996 - path: /media/myuser/public/
1997 - device: //192.168.0.1/storage
1998 - file_system: cifs
1999 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
2000
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002001NFS mount:
Jiri Broulikb017f932017-03-31 13:55:36 +02002002
2003.. code-block:: yaml
2004
2005 linux:
2006 storage:
2007 enabled: true
2008 mount:
2009 nfs_glance:
2010 enabled: true
2011 path: /var/lib/glance/images
2012 device: 172.16.10.110:/var/nfs/glance
2013 file_system: nfs
2014 opts: rw,sync
2015
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002016File swap configuration:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002017
2018.. code-block:: yaml
2019
2020 linux:
2021 storage:
2022 enabled: true
2023 swap:
2024 file:
2025 enabled: true
2026 engine: file
2027 device: /swapfile
2028 size: 1024
2029
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002030Partition swap configuration:
Lachlan Evenson30676512016-01-22 15:43:28 -08002031
2032.. code-block:: yaml
2033
2034 linux:
2035 storage:
2036 enabled: true
2037 swap:
2038 partition:
2039 enabled: true
2040 engine: partition
2041 device: /dev/vg0/swap
2042
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002043LVM group ``vg1`` with one device and ``data`` volume mounted
2044into ``/mnt/data``.
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002045
2046.. code-block:: yaml
2047
2048 parameters:
2049 linux:
2050 storage:
2051 mount:
2052 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01002053 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01002054 device: /dev/vg1/data
2055 file_system: ext4
2056 path: /mnt/data
2057 lvm:
2058 vg1:
2059 enabled: true
2060 devices:
2061 - /dev/sdb
2062 volume:
2063 data:
2064 size: 40G
2065 mount: ${linux:storage:mount:data}
2066
Jakub Pavlik4f742142017-08-08 15:05:50 +02002067Create partitions on disk. Specify size in MB. It expects empty
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002068disk without any existing partitions.
2069Set ``startsector=1`` if you want to start partitions from ``2048``.
Jakub Pavlik4f742142017-08-08 15:05:50 +02002070
2071.. code-block:: yaml
2072
2073 linux:
2074 storage:
2075 disk:
2076 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01002077 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02002078 name: /dev/loop1
2079 type: gpt
2080 partitions:
2081 - size: 200 #size in MB
2082 type: fat32
2083 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02002084 mkfs: True
2085 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02002086 /dev/vda1:
2087 partitions:
2088 - size: 5
2089 type: ext2
2090 - size: 10
2091 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02002092
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002093Multipath with Fujitsu Eternus DXL:
Ales Komareka634f4b2016-10-02 13:11:04 +02002094
2095.. code-block:: yaml
2096
2097 parameters:
2098 linux:
2099 storage:
2100 multipath:
2101 enabled: true
2102 blacklist_devices:
2103 - /dev/sda
2104 - /dev/sdb
2105 backends:
2106 - fujitsu_eternus_dxl
2107
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002108Multipath with Hitachi VSP 1000:
Ales Komareka634f4b2016-10-02 13:11:04 +02002109
2110.. code-block:: yaml
2111
2112 parameters:
2113 linux:
2114 storage:
2115 multipath:
2116 enabled: true
2117 blacklist_devices:
2118 - /dev/sda
2119 - /dev/sdb
2120 backends:
2121 - hitachi_vsp1000
2122
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002123Multipath with IBM Storwize:
Ales Komareka634f4b2016-10-02 13:11:04 +02002124
2125.. code-block:: yaml
2126
2127 parameters:
2128 linux:
2129 storage:
2130 multipath:
2131 enabled: true
2132 blacklist_devices:
2133 - /dev/sda
2134 - /dev/sdb
2135 backends:
2136 - ibm_storwize
2137
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002138Multipath with multiple backends:
Ales Komareka634f4b2016-10-02 13:11:04 +02002139
2140.. code-block:: yaml
2141
2142 parameters:
2143 linux:
2144 storage:
2145 multipath:
2146 enabled: true
2147 blacklist_devices:
2148 - /dev/sda
2149 - /dev/sdb
2150 - /dev/sdc
2151 - /dev/sdd
2152 backends:
2153 - ibm_storwize
2154 - fujitsu_eternus_dxl
2155 - hitachi_vsp1000
2156
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002157PAM LDAP integration:
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002158
2159.. code-block:: yaml
2160
2161 parameters:
2162 linux:
2163 system:
2164 auth:
2165 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02002166 mkhomedir:
2167 enabled: true
2168 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03002169 ldap:
2170 enabled: true
2171 binddn: cn=bind,ou=service_users,dc=example,dc=com
2172 bindpw: secret
2173 uri: ldap://127.0.0.1
2174 base: ou=users,dc=example,dc=com
2175 ldap_version: 3
2176 pagesize: 65536
2177 referrals: off
2178 filter:
2179 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2180 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
2181 group: (&(objectClass=group)(gidNumber=*))
2182
Gleb Galkin93b9ae92018-10-18 13:57:30 +03002183PAM duo 2FA integration
2184
2185.. code-block:: yaml
2186
2187 parameters:
2188 linux:
2189 system:
2190 auth:
2191 enabled: true
2192 duo:
2193 enabled: true
2194 duo_host: localhost
2195 duo_ikey: DUO-INTEGRATION-KEY
2196 duo_skey: DUO-SECRET-KEY
2197
2198duo package version may be specified (optional)
2199
2200.. code-block:: yaml
2201
2202 linux:
2203 system:
2204 package:
2205 duo-unix:
2206 version: 1.10.1-0
2207
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002208Disabled multipath (the default setup):
Ales Komareka634f4b2016-10-02 13:11:04 +02002209
2210.. code-block:: yaml
2211
2212 parameters:
2213 linux:
2214 storage:
2215 multipath:
2216 enabled: false
2217
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002218Linux with local loopback device:
Simon Pasquier375001e2017-01-26 13:22:33 +01002219
2220.. code-block:: yaml
2221
2222 linux:
2223 storage:
2224 loopback:
2225 disk1:
2226 file: /srv/disk1
2227 size: 50G
2228
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002229External config generation
2230--------------------------
2231
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002232You are able to use config support metadata between formulas
2233and only generate configuration files for external use, for example, Docker, and so on.
Filip Pytlounb2c8f852016-11-21 17:03:43 +01002234
2235.. code-block:: yaml
2236
2237 parameters:
2238 linux:
2239 system:
2240 config:
2241 pillar:
2242 jenkins:
2243 master:
2244 home: /srv/volumes/jenkins
2245 approved_scripts:
2246 - method java.net.URL openConnection
2247 credentials:
2248 - type: username_password
2249 scope: global
2250 id: test
2251 desc: Testing credentials
2252 username: test
2253 password: test
2254
Vladimir Ereminccf28842017-04-10 23:52:10 +03002255Netconsole Remote Kernel Logging
2256--------------------------------
2257
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002258Netconsole logger can be configured for the configfs-enabled kernels
2259(``CONFIG_NETCONSOLE_DYNAMIC`` must be enabled). The configuration
2260applies both in runtime (if network is already configured),
2261and on-boot after an interface initialization.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002262
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002263.. note::
2264
2265 * Receiver can be located only on the same L3 domain
2266 (or you need to configure gateway MAC manually).
2267 * The Receiver MAC is detected only on configuration time.
2268 * Using broadcast MAC is not recommended.
Vladimir Ereminccf28842017-04-10 23:52:10 +03002269
2270.. code-block:: yaml
2271
2272 parameters:
2273 linux:
2274 system:
2275 netconsole:
2276 enabled: true
2277 port: 514 (optional)
2278 loglevel: debug (optional)
2279 target:
2280 192.168.0.1:
2281 interface: bond0
2282 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02002283
Dzmitry Stremkouskid1a268b2018-10-03 16:36:04 +02002284Check network params on the environment
2285---------------------------------------
2286
2287Grab nics and nics states
2288
2289.. code-block:: bash
2290
2291 salt osd001\* net_checks.get_nics
2292
2293**Example of system output:**
2294
2295.. code-block:: bash
2296
2297 osd001.domain.com:
2298 |_
2299 - bond0
2300 - None
2301 - 1e:c8:64:42:23:b9
2302 - 0
2303 - 1500
2304 |_
2305 - bond1
2306 - None
2307 - 3c:fd:fe:27:3b:00
2308 - 1
2309 - 9100
2310 |_
2311 - fourty1
2312 - None
2313 - 3c:fd:fe:27:3b:00
2314 - 1
2315 - 9100
2316 |_
2317 - fourty2
2318 - None
2319 - 3c:fd:fe:27:3b:02
2320 - 1
2321 - 9100
2322
2323Grab 10G nics PCI addresses for hugepages setup
2324
2325.. code-block:: bash
2326
2327 salt cmp001\* net_checks.get_ten_pci
2328
2329**Example of system output:**
2330
2331.. code-block:: bash
2332
2333 cmp001.domain.com:
2334 |_
2335 - ten1
2336 - 0000:19:00.0
2337 |_
2338 - ten2
2339 - 0000:19:00.1
2340 |_
2341 - ten3
2342 - 0000:19:00.2
2343 |_
2344 - ten4
2345 - 0000:19:00.3
2346
2347Grab ip address for an interface
2348
2349.. code-block:: bash
2350
2351 salt cmp001\* net_checks.get_ip iface=one4
2352
2353**Example of system output:**
2354
2355.. code-block:: bash
2356
2357 cmp001.domain.com:
2358 10.200.177.101
2359
2360Grab ip addresses map
2361
2362.. code-block:: bash
2363
2364 salt-call net_checks.nodes_addresses
2365
2366**Example of system output:**
2367
2368.. code-block:: bash
2369
2370 local:
2371 |_
2372 - cid01.domain.com
2373 |_
2374 |_
2375 - pxe
2376 - 10.200.177.91
2377 |_
2378 - control
2379 - 10.200.178.91
2380 |_
2381 - cmn02.domain.com
2382 |_
2383 |_
2384 - storage_access
2385 - 10.200.181.67
2386 |_
2387 - pxe
2388 - 10.200.177.67
2389 |_
2390 - control
2391 - 10.200.178.67
2392 |_
2393 - cmp010.domain.com
2394 |_
2395 |_
2396 - pxe
2397 - 10.200.177.110
2398 |_
2399 - storage_access
2400 - 10.200.181.110
2401 |_
2402 - control
2403 - 10.200.178.110
2404 |_
2405 - vxlan
2406 - 10.200.179.110
2407
2408Verify full mesh connectivity
2409
2410.. code-block:: bash
2411
2412 salt-call net_checks.ping_check
2413
2414**Example of positive system output:**
2415
2416.. code-block:: bash
2417
2418 ['PASSED']
2419 [INFO ] ['PASSED']
2420 local:
2421 True
2422
2423**Example of system output in case of failure:**
2424
2425.. code-block:: bash
2426
2427 FAILED
2428 [ERROR ] FAILED
2429 ['control: 10.0.1.92 -> 10.0.1.224: Failed']
2430 ['control: 10.0.1.93 -> 10.0.1.224: Failed']
2431 ['control: 10.0.1.51 -> 10.0.1.224: Failed']
2432 ['control: 10.0.1.102 -> 10.0.1.224: Failed']
2433 ['control: 10.0.1.13 -> 10.0.1.224: Failed']
2434 ['control: 10.0.1.81 -> 10.0.1.224: Failed']
2435 local:
2436 False
2437
2438For this feature to work, please mark addresses with some role.
2439Otherwise 'default' role is assumed and mesh would consist of all
2440addresses on the environment.
2441
2442Mesh mark is needed only for interfaces which are enabled and have
2443ip address assigned.
2444
2445Checking dhcp pxe network meaningless, as it is used for salt
2446master vs minion communications, therefore treated as checked.
2447
2448.. code-block:: yaml
2449
2450 parameters:
2451 linux:
2452 network:
2453 interface:
2454 ens3:
2455 enabled: true
2456 type: eth
2457 proto: static
2458 address: ${_param:deploy_address}
2459 netmask: ${_param:deploy_network_netmask}
2460 gateway: ${_param:deploy_network_gateway}
2461 mesh: pxe
2462
2463Check pillars for ip address duplicates
2464
2465.. code-block:: bash
2466
2467 salt-call net_checks.verify_addresses
2468
2469**Example of positive system output:**
2470
2471.. code-block:: bash
2472
2473 ['PASSED']
2474 [INFO ] ['PASSED']
2475 local:
2476 True
2477
2478**Example of system output in case of failure:**
2479
2480.. code-block:: bash
2481
2482 FAILED. Duplicates found
2483 [ERROR ] FAILED. Duplicates found
2484 ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2485 [ERROR ] ['gtw01.domain.com', 'gtw02.domain.com', '10.0.1.224']
2486 local:
2487 False
2488
2489Generate csv report for the env
2490
2491.. code-block:: bash
2492
2493 salt -C 'kvm* or cmp* or osd*' net_checks.get_nics_csv \
2494 | grep '^\ ' | sed 's/\ *//g' | grep -Ev ^server \
2495 | sed '1 i\server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr'
2496
2497**Example of system output:**
2498
2499.. code-block:: bash
2500
2501 server,nic_name,ip_addr,mac_addr,link,mtu,chassis_id,chassis_name,port_mac,port_descr
2502 cmp010.domain.com,bond0,None,b4:96:91:10:5b:3a,1,1500,,,,
2503 cmp010.domain.com,bond0.21,10.200.178.110,b4:96:91:10:5b:3a,1,1500,,,,
2504 cmp010.domain.com,bond0.22,10.200.179.110,b4:96:91:10:5b:3a,1,1500,,,,
2505 cmp010.domain.com,bond1,None,3c:fd:fe:34:ad:22,0,1500,,,,
2506 cmp010.domain.com,bond1.24,10.200.181.110,3c:fd:fe:34:ad:22,0,1500,,,,
2507 cmp010.domain.com,fourty5,None,3c:fd:fe:34:ad:20,0,9000,,,,
2508 cmp010.domain.com,fourty6,None,3c:fd:fe:34:ad:22,0,9000,,,,
2509 cmp010.domain.com,one1,None,b4:96:91:10:5b:38,0,1500,,,,
2510 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
2511 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
2512 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
2513 cmp011.domain.com,bond0,None,b4:96:91:13:6c:aa,1,1500,,,,
2514 cmp011.domain.com,bond0.21,10.200.178.111,b4:96:91:13:6c:aa,1,1500,,,,
2515 cmp011.domain.com,bond0.22,10.200.179.111,b4:96:91:13:6c:aa,1,1500,,,,
2516 ...
2517
Filip Pytlounf5383a42015-10-06 16:28:32 +02002518Usage
2519=====
2520
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002521Set MTU of the eth0 network interface to 1400:
Filip Pytlounf5383a42015-10-06 16:28:32 +02002522
2523.. code-block:: bash
2524
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002525 ip link set dev eth0 mtu 1400
Filip Pytlounf5383a42015-10-06 16:28:32 +02002526
2527Read more
2528=========
2529
2530* https://www.archlinux.org/
2531* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu
Filip Pytloun018f8712017-02-02 13:02:03 +01002532
2533Documentation and Bugs
2534======================
2535
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002536* http://salt-formulas.readthedocs.io/
2537 Learn how to install and update salt-formulas.
Filip Pytloun018f8712017-02-02 13:02:03 +01002538
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002539* https://github.com/salt-formulas/salt-formula-linux/issues
2540 In the unfortunate event that bugs are discovered, report the issue to the
2541 appropriate issue tracker. Use the Github issue tracker for a specific salt
2542 formula.
Filip Pytloun018f8712017-02-02 13:02:03 +01002543
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002544* https://launchpad.net/salt-formulas
2545 For feature requests, bug reports, or blueprints affecting the entire
2546 ecosystem, use the Launchpad salt-formulas project.
Filip Pytloun018f8712017-02-02 13:02:03 +01002547
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002548* https://launchpad.net/~salt-formulas-users
2549 Join the salt-formulas-users team and subscribe to mailing list if required.
Filip Pytloun018f8712017-02-02 13:02:03 +01002550
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002551* https://github.com/salt-formulas/salt-formula-linux
2552 Develop the salt-formulas projects in the master branch and then submit pull
2553 requests against a specific formula.
Filip Pytloun018f8712017-02-02 13:02:03 +01002554
OlgaGusarenko2828f5f2018-07-30 19:37:05 +03002555* #salt-formulas @ irc.freenode.net
2556 Use this IRC channel in case of any questions or feedback which is always
2557 welcome.
Filip Pytloun018f8712017-02-02 13:02:03 +01002558