blob: 5fdc1fa99d70294ca817b664c62be7e88e935249 [file] [log] [blame]
Aleš Komárek63572992017-04-11 13:16:44 +02001============
2Linux Fomula
3============
Filip Pytlounf5383a42015-10-06 16:28:32 +02004
5Linux Operating Systems.
6
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 +020016
17Linux System
Filip Pytlounf5383a42015-10-06 16:28:32 +020018------------
19
20Basic Linux box
21
22.. code-block:: yaml
23
24 linux:
25 system:
26 enabled: true
27 name: 'node1'
28 domain: 'domain.com'
29 cluster: 'system'
30 environment: prod
31 timezone: 'Europe/Prague'
32 utc: true
33
azvyagintsev967af132017-06-12 12:25:24 +030034Linux with system users, some with password set:
35.. WARNING::
36If no 'password' variable has been passed - any predifined password
37will be removed.
Filip Pytlounf5383a42015-10-06 16:28:32 +020038
39.. code-block:: yaml
40
41 linux:
42 system:
43 ...
44 user:
45 jdoe:
46 name: 'jdoe'
47 enabled: true
48 sudo: true
49 shell: /bin/bash
50 full_name: 'Jonh Doe'
51 home: '/home/jdoe'
Martin Polreich4fcd5c02018-07-16 09:41:51 +020052 home_dir_mode: 755
Filip Pytlounf5383a42015-10-06 16:28:32 +020053 email: 'jonh@doe.com'
54 jsmith:
55 name: 'jsmith'
56 enabled: true
azvyagintsev967af132017-06-12 12:25:24 +030057 full_name: 'With clear password'
Filip Pytlounf5383a42015-10-06 16:28:32 +020058 home: '/home/jsmith'
azvyagintsev967af132017-06-12 12:25:24 +030059 hash_password: true
60 password: "userpassword"
61 mark:
62 name: 'mark'
63 enabled: true
64 full_name: "unchange password'
65 home: '/home/mark'
66 password: false
67 elizabeth:
68 name: 'elizabeth'
69 enabled: true
70 full_name: 'With hased password'
71 home: '/home/elizabeth'
72 password: "$6$nUI7QEz3$dFYjzQqK5cJ6HQ38KqG4gTWA9eJu3aKx6TRVDFh6BVJxJgFWg2akfAA7f1fCxcSUeOJ2arCO6EEI6XXnHXxG10"
Filip Pytlounf5383a42015-10-06 16:28:32 +020073
Petr Michalec1c4c8d82017-02-28 19:09:21 +010074Configure sudo for users and groups under ``/etc/sudoers.d/``.
75This ways ``linux.system.sudo`` pillar map to actual sudo attributes:
76
77.. code-block:: jinja
Aleš Komárek63572992017-04-11 13:16:44 +020078
Petr Michalec1c4c8d82017-02-28 19:09:21 +010079 # simplified template:
80 Cmds_Alias {{ alias }}={{ commands }}
81 {{ user }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
82 %{{ group }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
83
84 # when rendered:
85 saltuser1 ALL=(ALL) NOPASSWD: ALL
86
Petr Michalec1c4c8d82017-02-28 19:09:21 +010087.. code-block:: yaml
Aleš Komárek63572992017-04-11 13:16:44 +020088
Petr Michalec1c4c8d82017-02-28 19:09:21 +010089 linux:
90 system:
91 sudo:
92 enabled: true
Tomas Kammd8eb3002017-05-08 19:30:29 +020093 aliases:
Petr Michalec1c4c8d82017-02-28 19:09:21 +010094 host:
95 LOCAL:
96 - localhost
97 PRODUCTION:
98 - db1
99 - db2
100 runas:
101 DBA:
102 - postgres
103 - mysql
104 SALT:
105 - root
106 command:
107 # Note: This is not 100% safe when ALL keyword is used, user still may modify configs and hide his actions.
108 # Best practice is to specify full list of commands user is allowed to run.
109 SUPPORT_RESTRICTED:
110 - /bin/vi /etc/sudoers*
111 - /bin/vim /etc/sudoers*
112 - /bin/nano /etc/sudoers*
113 - /bin/emacs /etc/sudoers*
114 - /bin/su - root
115 - /bin/su -
116 - /bin/su
117 - /usr/sbin/visudo
118 SUPPORT_SHELLS:
119 - /bin/sh
120 - /bin/ksh
121 - /bin/bash
122 - /bin/rbash
123 - /bin/dash
124 - /bin/zsh
125 - /bin/csh
126 - /bin/fish
127 - /bin/tcsh
128 - /usr/bin/login
129 - /usr/bin/su
130 - /usr/su
131 ALL_SALT_SAFE:
132 - /usr/bin/salt state*
133 - /usr/bin/salt service*
134 - /usr/bin/salt pillar*
135 - /usr/bin/salt grains*
136 - /usr/bin/salt saltutil*
137 - /usr/bin/salt-call state*
138 - /usr/bin/salt-call service*
139 - /usr/bin/salt-call pillar*
140 - /usr/bin/salt-call grains*
141 - /usr/bin/salt-call saltutil*
142 SALT_TRUSTED:
143 - /usr/bin/salt*
144 users:
145 # saltuser1 with default values: saltuser1 ALL=(ALL) NOPASSWD: ALL
146 saltuser1: {}
147 saltuser2:
148 hosts:
149 - LOCAL
150 # User Alias DBA
151 DBA:
152 hosts:
153 - ALL
154 commands:
155 - ALL_SALT_SAFE
156 groups:
157 db-ops:
158 hosts:
159 - ALL
160 - '!PRODUCTION'
161 runas:
162 - DBA
163 commands:
164 - /bin/cat *
165 - /bin/less *
166 - /bin/ls *
167 salt-ops:
168 hosts:
169 - 'ALL'
170 runas:
171 - SALT
172 commands:
173 - SUPPORT_SHELLS
174 salt-ops-2nd:
175 name: salt-ops
176 nopasswd: false
Jakub Josef7a9d9b92017-05-16 11:39:01 +0200177 setenv: true # Enable sudo -E option
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100178 runas:
179 - DBA
180 commands:
181 - ALL
182 - '!SUPPORT_SHELLS'
183 - '!SUPPORT_RESTRICTED'
184
Filip Pytlounf5383a42015-10-06 16:28:32 +0200185Linux with package, latest version
186
187.. code-block:: yaml
188
189 linux:
190 system:
191 ...
192 package:
193 package-name:
194 version: latest
195
196Linux with package from certail repo, version with no upgrades
197
198.. code-block:: yaml
199
200 linux:
201 system:
202 ...
203 package:
204 package-name:
205 version: 2132.323
206 repo: 'custom-repo'
207 hold: true
208
209Linux with package from certail repo, version with no GPG verification
210
211.. code-block:: yaml
212
213 linux:
214 system:
215 ...
216 package:
217 package-name:
218 version: 2132.323
219 repo: 'custom-repo'
220 verify: false
221
Bruno Binet69a9d8d2017-02-16 22:34:32 +0100222Linux with autoupdates (automatically install security package updates)
223
224.. code-block:: yaml
225
226 linux:
227 system:
228 ...
229 autoupdates:
230 enabled: true
231 mail: root@localhost
232 mail_only_on_error: true
233 remove_unused_dependencies: false
234 automatic_reboot: true
235 automatic_reboot_time: "02:00"
236
Filip Pytlounf5383a42015-10-06 16:28:32 +0200237Linux with cron jobs
Filip Pytloun91222222017-08-04 10:55:27 +0200238By default it will use name as an identifier, unless identifier key is
239explicitly set or False (then it will use Salt's default behavior which is
240identifier same as command resulting in not being able to change it)
Filip Pytlounf5383a42015-10-06 16:28:32 +0200241
242.. code-block:: yaml
243
244 linux:
245 system:
246 ...
247 job:
248 cmd1:
249 command: '/cmd/to/run'
Filip Pytloun91222222017-08-04 10:55:27 +0200250 identifier: cmd1
Filip Pytlounf5383a42015-10-06 16:28:32 +0200251 enabled: true
252 user: 'root'
253 hour: 2
254 minute: 0
255
Filip Pytlound0a29e72015-11-30 15:23:34 +0100256Linux security limits (limit sensu user memory usage to max 1GB):
257
258.. code-block:: yaml
259
260 linux:
261 system:
262 ...
263 limit:
264 sensu:
265 enabled: true
266 domain: sensu
267 limits:
268 - type: hard
269 item: as
270 value: 1000000
271
Filip Pytloun7fee0542015-10-15 11:19:24 +0200272Enable autologin on tty1 (may work only for Ubuntu 14.04):
273
274.. code-block:: yaml
275
276 linux:
277 system:
278 console:
279 tty1:
280 autologin: root
Filip Pytloun281d0202016-01-29 14:03:51 +0100281 # Enable serial console
282 ttyS0:
283 autologin: root
284 rate: 115200
285 term: xterm
Filip Pytloun7fee0542015-10-15 11:19:24 +0200286
287To disable set autologin to `false`.
288
Filip Pytloun7731b852016-02-01 11:13:47 +0100289Set ``policy-rc.d`` on Debian-based systems. Action can be any available
290command in ``while true`` loop and ``case`` context.
291Following will disallow dpkg to stop/start services for cassandra package automatically:
292
293.. code-block:: yaml
294
295 linux:
296 system:
297 policyrcd:
298 - package: cassandra
299 action: exit 101
300 - package: '*'
301 action: switch
302
Filip Pytlounc49445a2016-04-04 14:23:20 +0200303Set system locales:
304
305.. code-block:: yaml
306
307 linux:
308 system:
309 locale:
310 en_US.UTF-8:
311 default: true
Filip Pytlounee1745f2016-04-04 17:39:41 +0200312 "cs_CZ.UTF-8 UTF-8":
Filip Pytlounc49445a2016-04-04 14:23:20 +0200313 enabled: true
314
Andrey Shestakove7cca052017-05-24 23:06:24 +0300315Systemd settings:
316
317.. code-block:: yaml
318
319 linux:
320 system:
321 ...
322 systemd:
323 system:
324 Manager:
325 DefaultLimitNOFILE: 307200
326 DefaultLimitNPROC: 307200
327 user:
328 Manager:
329 DefaultLimitCPU: 2
330 DefaultLimitNPROC: 4
331
Filip Pytloun8b2131e2017-11-08 13:29:03 +0100332Ensure presence of directory:
333
334.. code-block:: yaml
335
336 linux:
337 system:
338 directory:
339 /tmp/test:
340 user: root
341 group: root
342 mode: 700
343 makedirs: true
344
Richard Felkl2e07d652018-01-19 10:19:06 +0100345Ensure presence of file by specifying it's source:
346
347.. code-block:: yaml
348
349 linux:
350 system:
351 file:
352 /tmp/test.txt:
353 source: http://example.com/test.txt
Richard Felklf40599a2018-02-06 22:56:41 +0100354 user: root #optional
355 group: root #optional
356 mode: 700 #optional
357 dir_mode: 700 #optional
358 encoding: utf-8 #optional
359 hash: <<hash>> or <<URI to hash>> #optional
360 makedirs: true #optional
361
362 linux:
363 system:
364 file:
365 test.txt:
366 name: /tmp/test.txt
367 source: http://example.com/test.txt
Richard Felkl2e07d652018-01-19 10:19:06 +0100368
369Ensure presence of file by specifying it's contents:
370
371.. code-block:: yaml
372
373 linux:
374 system:
375 file:
376 /tmp/test.txt:
377 contents: |
378 line1
379 line2
Richard Felklf40599a2018-02-06 22:56:41 +0100380
381 linux:
382 system:
383 file:
384 /tmp/test.txt:
385 contents_pillar: linux:network:hostname
386
387 linux:
388 system:
389 file:
390 /tmp/test.txt:
391 contents_grains: motd
392
Bruno Binet9c2fe222018-06-08 16:57:32 +0200393Ensure presence of file to be serialized through one of the serializer modules
394(see: https://docs.saltstack.com/en/latest/ref/serializers/all/index.html):
395
396.. code-block:: yaml
397
398 linux:
399 system:
400 file:
401 /tmp/test.json:
402 serialize: json
403 contents:
404 foo: 1
405 bar: 'bar'
406
Filip Pytloun281034a2016-01-04 18:06:22 +0100407Kernel
408~~~~~~
409
410Install always up to date LTS kernel and headers from Ubuntu trusty:
411
412.. code-block:: yaml
413
414 linux:
415 system:
416 kernel:
417 type: generic
418 lts: trusty
419 headers: true
420
Tomáš Kukrálba35b212017-02-15 17:59:46 +0100421Load kernel modules and add them to `/etc/modules`:
422
423.. code-block:: yaml
424
425 linux:
426 system:
427 kernel:
428 modules:
429 - nf_conntrack
430 - tp_smapi
431 - 8021q
432
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200433Configure or blacklist kernel modules with additional options to `/etc/modprobe.d` following example
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300434will add `/etc/modprobe.d/nf_conntrack.conf` file with line `options nf_conntrack hashsize=262144`:
435
436.. code-block:: yaml
437
438 linux:
439 system:
440 kernel:
441 module:
442 nf_conntrack:
443 option:
444 hashsize: 262144
445
446
447
Filip Pytloun281034a2016-01-04 18:06:22 +0100448Install specific kernel version and ensure all other kernel packages are
449not present. Also install extra modules and headers for this kernel:
450
451.. code-block:: yaml
452
453 linux:
454 system:
455 kernel:
456 type: generic
457 extra: true
458 headers: true
459 version: 4.2.0-22
460
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100461Systcl kernel parameters
462
463.. code-block:: yaml
464
465 linux:
466 system:
467 kernel:
468 sysctl:
469 net.ipv4.tcp_keepalive_intvl: 3
470 net.ipv4.tcp_keepalive_time: 30
471 net.ipv4.tcp_keepalive_probes: 8
472
Michael Polenchukebf55522018-01-25 13:22:39 +0400473Configure kernel boot options:
474
475.. code-block:: yaml
476
477 linux:
478 system:
479 kernel:
480 boot_options:
481 - elevator=deadline
482 - spectre_v2=off
483 - nopti
484
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100485
486CPU
487~~~
488
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300489Enable cpufreq governor for every cpu:
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100490
491.. code-block:: yaml
492
493 linux:
494 system:
495 cpu:
496 governor: performance
497
Nick Metzf04f5f32018-01-08 15:25:04 +0100498
Jiri Broulik303905d2018-01-11 14:12:48 +0100499CGROUPS
500~~~~~~~
501
502Setup linux cgroups:
503
504.. code-block:: yaml
505
506 linux:
507 system:
508 cgroup:
509 enabled: true
510 group:
511 ceph_group_1:
512 controller:
513 cpu:
514 shares:
515 value: 250
516 cpuacct:
517 usage:
518 value: 0
519 cpuset:
520 cpus:
521 value: 1,2,3
522 memory:
523 limit_in_bytes:
524 value: 2G
525 memsw.limit_in_bytes:
526 value: 3G
527 mapping:
528 subjects:
529 - '@ceph'
530 generic_group_1:
531 controller:
532 cpu:
533 shares:
534 value: 250
535 cpuacct:
536 usage:
537 value: 0
538 mapping:
539 subjects:
540 - '*:firefox'
541 - 'student:cp'
542
543
Nick Metzf04f5f32018-01-08 15:25:04 +0100544Shared Libraries
545~~~~~~~~~~~~~~~~
546
547Set additional shared library to Linux system library path
548
549.. code-block:: yaml
550
551 linux:
552 system:
553 ld:
554 library:
555 java:
556 - /usr/lib/jvm/jre-openjdk/lib/amd64/server
557 - /opt/java/jre/lib/amd64/server
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200558
Nick Metzf04f5f32018-01-08 15:25:04 +0100559
Filip Pytloun2fde88b2017-10-05 10:30:29 +0200560Certificates
561~~~~~~~~~~~~
562
563Add certificate authority into system trusted CA bundle
564
565.. code-block:: yaml
566
567 linux:
568 system:
569 ca_certificates:
570 mycert: |
571 -----BEGIN CERTIFICATE-----
572 MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
573 A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
574 cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
575 MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
576 BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
577 YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
578 ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
579 BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
580 I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
581 CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
582 lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
583 AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
584 -----END CERTIFICATE-----
585
Filip Pytloun361096c2017-08-23 10:57:20 +0200586Sysfs
587~~~~~
588
589Install sysfsutils and set sysfs attributes:
590
591.. code-block:: yaml
592
593 linux:
594 system:
595 sysfs:
596 scheduler:
597 block/sda/queue/scheduler: deadline
598 power:
599 mode:
600 power/state: 0660
601 owner:
602 power/state: "root:power"
603 devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
604
Ondrej Smolaef9bd762018-07-11 14:26:02 +0200605Optional: You can also use list that will ensure order of items.
606
607.. code-block:: yaml
608
609 linux:
610 system:
611 sysfs:
612 scheduler:
613 block/sda/queue/scheduler: deadline
614 power:
615 - mode:
616 power/state: 0660
617 - owner:
618 power/state: "root:power"
619 - devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
620
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100621Huge Pages
622~~~~~~~~~~~~
623
624Huge Pages give a performance boost to applications that intensively deal
625with memory allocation/deallocation by decreasing memory fragmentation.
626
627.. code-block:: yaml
628
629 linux:
630 system:
631 kernel:
632 hugepages:
633 small:
634 size: 2M
635 count: 107520
636 mount_point: /mnt/hugepages_2MB
Michael Polenchukd9369fe2018-05-08 17:53:08 +0400637 mount: false/true # default is true (mount immediately) / false (just save in the fstab)
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100638 large:
639 default: true # default automatically mounted
640 size: 1G
641 count: 210
642 mount_point: /mnt/hugepages_1GB
643
644Note: not recommended to use both pagesizes in concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100645
Jakub Pavlik5398d872017-02-13 22:30:47 +0100646Intel SR-IOV
647~~~~~~~~~~~~
648
649PCI-SIG Single Root I/O Virtualization and Sharing (SR-IOV) specification defines a standardized mechanism to virtualize PCIe devices. The mechanism can virtualize a single PCIe Ethernet controller to appear as multiple PCIe devices.
650
651.. code-block:: yaml
652
653 linux:
654 system:
655 kernel:
656 sriov: True
657 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
658 rc:
659 local: |
660 #!/bin/sh -e
661 # Enable 7 VF on eth1
662 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
663 exit 0
664
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100665Isolate CPU options
666~~~~~~~~~~~~~~~~~~~
667
668Remove the specified CPUs, as defined by the cpu_number values, from the general kernel
669SMP balancing and scheduler algroithms. The only way to move a process onto or off an
670"isolated" CPU is via the CPU affinity syscalls. cpu_number begins at 0, so the
671maximum value is 1 less than the number of CPUs on the system.
672
673.. code-block:: yaml
674
675 linux:
676 system:
677 kernel:
678 isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100679
Filip Pytlounf5383a42015-10-06 16:28:32 +0200680Repositories
681~~~~~~~~~~~~
682
683RedHat based Linux with additional OpenStack repo
684
685.. code-block:: yaml
686
687 linux:
688 system:
689 ...
690 repo:
691 rdo-icehouse:
692 enabled: true
693 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
694 pgpcheck: 0
695
696Ensure system repository to use czech Debian mirror (``default: true``)
697Also pin it's packages with priority 900.
698
699.. code-block:: yaml
700
701 linux:
702 system:
703 repo:
704 debian:
705 default: true
706 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
707 # Import signing key from URL if needed
708 key_url: "http://dummy.com/public.gpg"
709 pin:
710 - pin: 'origin "ftp.cz.debian.org"'
711 priority: 900
712 package: '*'
713
Petr Michalec10462bb2017-03-23 19:18:08 +0100714
715Package manager proxy setup globally:
716
717.. code-block:: yaml
718
719 linux:
720 system:
721 ...
722 repo:
723 apt-mk:
724 source: "deb http://apt-mk.mirantis.com/ stable main salt"
725 ...
726 proxy:
727 pkg:
728 enabled: true
729 ftp: ftp://ftp-proxy-for-apt.host.local:2121
730 ...
731 # NOTE: Global defaults for any other componet that configure proxy on the system.
732 # If your environment has just one simple proxy, set it on linux:system:proxy.
733 #
734 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
735 # as for https and http
736 ftp: ftp://proxy.host.local:2121
737 http: http://proxy.host.local:3142
738 https: https://proxy.host.local:3143
739
740Package manager proxy setup per repository:
741
742.. code-block:: yaml
743
744 linux:
745 system:
746 ...
747 repo:
748 debian:
749 source: "deb http://apt-mk.mirantis.com/ stable main salt"
750 ...
751 apt-mk:
752 source: "deb http://apt-mk.mirantis.com/ stable main salt"
753 # per repository proxy
754 proxy:
755 enabled: true
756 http: http://maas-01:8080
757 https: http://maas-01:8080
758 ...
759 proxy:
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600760 # package manager fallback defaults
Petr Michalec10462bb2017-03-23 19:18:08 +0100761 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
762 pkg:
763 enabled: true
764 ftp: ftp://proxy.host.local:2121
765 #http: http://proxy.host.local:3142
766 #https: https://proxy.host.local:3143
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600767 ...
Petr Michalec10462bb2017-03-23 19:18:08 +0100768 # global system fallback system defaults
769 ftp: ftp://proxy.host.local:2121
770 http: http://proxy.host.local:3142
771 https: https://proxy.host.local:3143
772
773
Jiri Broulik34a29b42017-04-25 14:42:54 +0200774Remove all repositories:
775
776.. code-block:: yaml
777
778 linux:
779 system:
780 purge_repos: true
781
Filip Pytlounc512e6c2017-11-22 14:28:10 +0100782Setup custom apt config options:
783
784.. code-block:: yaml
785
786 linux:
787 system:
788 apt:
789 config:
790 compression-workaround:
791 "Acquire::CompressionTypes::Order": "gz"
792 docker-clean:
793 "DPkg::Post-Invoke":
794 - "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"
795 "APT::Update::Post-Invoke":
796 - "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 +0200797
Petr Michalec10462bb2017-03-23 19:18:08 +0100798RC
799~~
800
Jakub Pavlik78859382016-01-21 11:26:39 +0100801rc.local example
802
803.. code-block:: yaml
804
805 linux:
806 system:
807 rc:
808 local: |
809 #!/bin/sh -e
810 #
811 # rc.local
812 #
813 # This script is executed at the end of each multiuser runlevel.
814 # Make sure that the script will "exit 0" on success or any other
815 # value on error.
816 #
817 # In order to enable or disable this script just change the execution
818 # bits.
819 #
820 # By default this script does nothing.
821 exit 0
822
Petr Michalec10462bb2017-03-23 19:18:08 +0100823
Filip Pytloun1f40dac2016-01-22 15:52:57 +0100824Prompt
825~~~~~~
826
827Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
828user can have different prompt.
829
830.. code-block:: yaml
831
832 linux:
833 system:
834 prompt:
835 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\\]
836 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
837
838On Debian systems to set prompt system-wide it's necessary to remove setting
839PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
840``/etc/skel/.bashrc``). This formula will do this automatically, but will not
Filip Pytlound9b68da2016-01-22 15:58:41 +0100841touch existing user's ``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +0100842
Filip Pytlouneef11c12016-03-25 11:00:23 +0100843Bash
844~~~~
845
846Fix bash configuration to preserve history across sessions (like ZSH does by
847default).
848
849.. code-block:: yaml
850
851 linux:
852 system:
853 bash:
854 preserve_history: true
855
Dmitry Teselkin949398e2018-05-03 15:50:00 +0300856Login banner message
857~~~~~~~~~~~~~~~~~~~~
858
859/etc/issue is a text file which contains a message or system
860identification to be printed before the login prompt. It may contain
861various @char and \char sequences, if supported by the getty-type
862program employed on the system.
863
864Setting logon banner message is easy:
865
866.. code-block:: yaml
867
868 liunx:
869 system:
870 banner:
871 enabled: true
872 contents: |
873 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
874
875 You must have explicit, authorized permission to access or configure this
876 device. Unauthorized attempts and actions to access or use this system may
877 result in civil and/or criminal penalties.
878 All activities performed on this system are logged and monitored.
879
Filip Pytloune874dfb2016-01-22 16:57:34 +0100880Message of the day
881~~~~~~~~~~~~~~~~~~
882
Dmitry Teselkin538c8242018-04-02 16:13:37 +0300883``pam_motd`` from package ``libpam-modules`` is used for dynamic messages of the
Filip Pytloune874dfb2016-01-22 16:57:34 +0100884day. Setting custom motd will cleanup existing ones.
885
Dmitry Teselkin538c8242018-04-02 16:13:37 +0300886Setting static motd will replace existing ``/etc/motd`` and remove scripts from
887``/etc/update-motd.d``.
888
889Setting static motd:
890
891.. code-block:: yaml
892
893 linux:
894 system:
895 motd: |
896 UNAUTHORIZED ACCESS TO THIS SYSTEM IS PROHIBITED
897
898 You must have explicit, authorized permission to access or configure this
899 device. Unauthorized attempts and actions to access or use this system may
900 result in civil and/or criminal penalties.
901 All activities performed on this system are logged and monitored.
902
903Setting dynamic motd:
904
Filip Pytloune874dfb2016-01-22 16:57:34 +0100905.. code-block:: yaml
906
907 linux:
908 system:
909 motd:
910 - release: |
911 #!/bin/sh
912 [ -r /etc/lsb-release ] && . /etc/lsb-release
913
914 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
915 # Fall back to using the very slow lsb_release utility
916 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
917 fi
918
919 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
920 - warning: |
921 #!/bin/sh
922 printf "This is [company name] network.\n"
923 printf "Unauthorized access strictly prohibited.\n"
924
Marek Celoud713e9072017-05-18 15:20:25 +0200925Services
926~~~~~~~~
927
928Stop and disable linux service:
929
930.. code-block:: yaml
931
932 linux:
933 system:
934 service:
935 apt-daily.timer:
936 status: dead
937
938Possible status is dead (disable service by default), running (enable service by default), enabled, disabled.
939
Serhiy Ovsianikov67bd56a2017-08-11 15:56:01 +0300940Linux with atop service:
941
942.. code-block:: yaml
943
944 linux:
945 system:
946 atop:
947 enabled: true
948 interval: 20
949 logpath: "/var/log/atop"
950 outfile: "/var/log/atop/daily.log"
951
Oleksii Chupryn144432b2018-05-22 10:34:48 +0300952Linux with mcelog service:
953
954.. code-block:: yaml
955
956 linux:
957 system:
958 mcelog:
959 enabled: true
960 logging:
961 syslog: true
962 syslog_error: true
963
Filip Pytloun2f70b492016-02-19 15:55:25 +0100964RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +0100965^^^^^^^^^^^^^
Filip Pytloun2f70b492016-02-19 15:55:25 +0100966
967Unfortunately ``update-motd`` is currently not available for RHEL so there's
968no native support for dynamic motd.
969You can still set static one, only pillar structure differs:
970
971.. code-block:: yaml
972
973 linux:
974 system:
975 motd: |
976 This is [company name] network.
977 Unauthorized access strictly prohibited.
978
Filip Pytloun8296bb92016-02-19 18:42:09 +0100979Haveged
980~~~~~~~
981
982If you are running headless server and are low on entropy, it may be a good
983idea to setup Haveged.
984
985.. code-block:: yaml
986
987 linux:
988 system:
989 haveged:
990 enabled: true
991
Filip Pytlounf5383a42015-10-06 16:28:32 +0200992Linux network
993-------------
994
995Linux with network manager
996
997.. code-block:: yaml
998
999 linux:
1000 network:
1001 enabled: true
1002 network_manager: true
1003
1004Linux with default static network interfaces, default gateway interface and DNS servers
1005
1006.. code-block:: yaml
1007
1008 linux:
1009 network:
1010 enabled: true
1011 interface:
1012 eth0:
1013 enabled: true
1014 type: eth
1015 address: 192.168.0.102
1016 netmask: 255.255.255.0
1017 gateway: 192.168.0.1
1018 name_servers:
1019 - 8.8.8.8
1020 - 8.8.4.4
1021 mtu: 1500
1022
jan kaufman6d30adf2016-01-18 17:30:12 +01001023Linux with bonded interfaces and disabled NetworkManager
Filip Pytlounf5383a42015-10-06 16:28:32 +02001024
1025.. code-block:: yaml
1026
1027 linux:
1028 network:
1029 enabled: true
1030 interface:
1031 eth0:
1032 type: eth
1033 ...
1034 eth1:
1035 type: eth
1036 ...
1037 bond0:
1038 enabled: true
1039 type: bond
1040 address: 192.168.0.102
1041 netmask: 255.255.255.0
1042 mtu: 1500
1043 use_in:
1044 - interface: ${linux:interface:eth0}
1045 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +01001046 network_manager:
1047 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001048
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001049Linux with vlan interface_params
1050
1051.. code-block:: yaml
1052
1053 linux:
1054 network:
1055 enabled: true
1056 interface:
1057 vlan69:
1058 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +01001059 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001060 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001061
Filip Pytlounf5383a42015-10-06 16:28:32 +02001062Linux with wireless interface parameters
1063
1064.. code-block:: yaml
1065
1066 linux:
1067 network:
1068 enabled: true
1069 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001070 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001071 interface:
1072 wlan0:
1073 type: eth
1074 wireless:
1075 essid: example
1076 key: example_key
1077 security: wpa
1078 priority: 1
1079
1080Linux networks with routes defined
1081
1082.. code-block:: yaml
1083
1084 linux:
1085 network:
1086 enabled: true
1087 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +01001088 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +02001089 interface:
1090 eth0:
1091 type: eth
1092 route:
1093 default:
1094 address: 192.168.0.123
1095 netmask: 255.255.255.0
1096 gateway: 192.168.0.1
1097
1098Native Linux Bridges
1099
1100.. code-block:: yaml
1101
1102 linux:
1103 network:
1104 interface:
1105 eth1:
1106 enabled: true
1107 type: eth
1108 proto: manual
1109 up_cmds:
1110 - ip address add 0/0 dev $IFACE
1111 - ip link set $IFACE up
1112 down_cmds:
1113 - ip link set $IFACE down
1114 br-ex:
1115 enabled: true
1116 type: bridge
1117 address: ${linux:network:host:public_local:address}
1118 netmask: 255.255.255.0
1119 use_interfaces:
1120 - eth1
1121
1122OpenVswitch Bridges
1123
1124.. code-block:: yaml
1125
1126 linux:
1127 network:
1128 bridge: openvswitch
1129 interface:
1130 eth1:
1131 enabled: true
1132 type: eth
1133 proto: manual
1134 up_cmds:
1135 - ip address add 0/0 dev $IFACE
1136 - ip link set $IFACE up
1137 down_cmds:
1138 - ip link set $IFACE down
1139 br-ex:
1140 enabled: true
1141 type: bridge
1142 address: ${linux:network:host:public_local:address}
1143 netmask: 255.255.255.0
1144 use_interfaces:
1145 - eth1
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001146 br-prv:
1147 enabled: true
1148 type: ovs_bridge
1149 mtu: 65000
1150 br-ens7:
1151 enabled: true
1152 name: br-ens7
1153 type: ovs_bridge
1154 proto: manual
1155 mtu: 9000
1156 use_interfaces:
1157 - ens7
1158 patch-br-ens7-br-prv:
1159 enabled: true
1160 name: ens7-prv
1161 ovs_type: ovs_port
1162 type: ovs_port
1163 bridge: br-ens7
1164 port_type: patch
1165 peer: prv-ens7
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001166 tag: 109 # [] to unset a tag
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001167 mtu: 65000
1168 patch-br-prv-br-ens7:
1169 enabled: true
1170 name: prv-ens7
1171 bridge: br-prv
1172 ovs_type: ovs_port
1173 type: ovs_port
1174 port_type: patch
1175 peer: ens7-prv
Oleksii Chupryn694ee722018-06-13 14:08:58 +03001176 tag: 109
Dmitry Stremkouskia581ea72017-10-18 14:24:16 +03001177 mtu: 65000
1178 ens7:
1179 enabled: true
1180 name: ens7
1181 proto: manual
1182 ovs_port_type: OVSPort
1183 type: ovs_port
1184 ovs_bridge: br-ens7
1185 bridge: br-ens7
Filip Pytlounf5383a42015-10-06 16:28:32 +02001186
Petr Jediný8f8ae542017-07-13 16:19:12 +02001187Debian manual proto interfaces
1188
1189When you are changing interface proto from static in up state to manual, you
1190may need to flush ip addresses. For example, if you want to use the interface
1191and the ip on the bridge. This can be done by setting the ``ipflush_onchange``
1192to true.
1193
1194.. code-block:: yaml
1195
1196 linux:
1197 network:
1198 interface:
1199 eth1:
1200 enabled: true
1201 type: eth
1202 proto: manual
1203 mtu: 9100
1204 ipflush_onchange: true
1205
Jiri Broulik1a191e32018-01-15 15:54:21 +01001206Debian static proto interfaces
1207
1208When you are changing interface proto from dhcp in up state to static, you
1209may need to flush ip addresses and restart interface to assign ip address from a managed file.
1210For example, if you want to use the interface and the ip on the bridge.
1211This can be done by setting the ``ipflush_onchange`` with combination
1212``restart_on_ipflush`` param set to to true.
1213
1214.. code-block:: yaml
1215
1216 linux:
1217 network:
1218 interface:
1219 eth1:
1220 enabled: true
1221 type: eth
1222 proto: static
1223 address: 10.1.0.22
1224 netmask: 255.255.255.0
1225 ipflush_onchange: true
1226 restart_on_ipflush: true
Petr Jediný8f8ae542017-07-13 16:19:12 +02001227
Petr Jedinýd577cb52017-06-28 20:17:49 +02001228Concatinating and removing interface files
1229
1230Debian based distributions have `/etc/network/interfaces.d/` directory, where
1231you can store configuration of network interfaces in separate files. You can
1232concatinate the files to the defined destination when needed, this operation
1233removes the file from the `/etc/network/interfaces.d/`. If you just need to
1234remove iface files, you can use the `remove_iface_files` key.
1235
1236.. code-block:: yaml
1237
1238 linux:
1239 network:
1240 concat_iface_files:
1241 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
1242 dst: '/etc/network/interfaces'
1243 remove_iface_files:
1244 - '/etc/network/interfaces.d/90-custom.cfg'
1245
1246
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001247DHCP client configuration
1248
1249None of the keys is mandatory, include only those you really need. For full list
1250of available options under send, supersede, prepend, append refer to dhcp-options(5)
1251
1252.. code-block:: yaml
1253
1254 linux:
1255 network:
1256 dhclient:
1257 enabled: true
1258 backoff_cutoff: 15
1259 initial_interval: 10
1260 reboot: 10
1261 retry: 60
1262 select_timeout: 0
1263 timeout: 120
1264 send:
1265 - option: host-name
1266 declaration: "= gethostname()"
1267 supersede:
1268 - option: host-name
1269 declaration: "spaceship"
1270 - option: domain-name
1271 declaration: "domain.home"
1272 #- option: arp-cache-timeout
1273 # declaration: 20
1274 prepend:
1275 - option: domain-name-servers
1276 declaration:
1277 - 8.8.8.8
1278 - 8.8.4.4
1279 - option: domain-search
1280 declaration:
1281 - example.com
1282 - eng.example.com
1283 #append:
1284 #- option: domain-name-servers
1285 # declaration: 127.0.0.1
1286 # ip or subnet to reject dhcp offer from
1287 reject:
1288 - 192.33.137.209
1289 - 10.0.2.0/24
1290 request:
1291 - subnet-mask
1292 - broadcast-address
1293 - time-offset
1294 - routers
1295 - domain-name
1296 - domain-name-servers
1297 - domain-search
1298 - host-name
1299 - dhcp6.name-servers
1300 - dhcp6.domain-search
1301 - dhcp6.fqdn
1302 - dhcp6.sntp-servers
1303 - netbios-name-servers
1304 - netbios-scope
1305 - interface-mtu
1306 - rfc3442-classless-static-routes
1307 - ntp-servers
1308 require:
1309 - subnet-mask
1310 - domain-name-servers
1311 # if per interface configuration required add below
1312 interface:
1313 ens2:
1314 initial_interval: 11
1315 reject:
1316 - 192.33.137.210
1317 ens3:
1318 initial_interval: 12
1319 reject:
1320 - 192.33.137.211
1321
Petr Michaleceb14b552017-06-01 10:27:05 +02001322Linux network systemd settings:
1323
1324.. code-block:: yaml
1325
1326 linux:
1327 network:
1328 ...
1329 systemd:
1330 link:
1331 10-iface-dmz:
1332 Match:
1333 MACAddress: c8:5b:67:fa:1a:af
1334 OriginalName: eth0
1335 Link:
1336 Name: dmz0
1337 netdev:
1338 20-bridge-dmz:
1339 match:
1340 name: dmz0
1341 network:
1342 mescription: bridge
1343 bridge: br-dmz0
1344 network:
1345 # works with lowercase, keys are by default capitalized
1346 40-dhcp:
1347 match:
1348 name: '*'
1349 network:
1350 DHCP: yes
1351
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -06001352
Petr Michalec10462bb2017-03-23 19:18:08 +01001353Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +01001354
Ales Komarek417e8c52017-08-25 15:10:29 +02001355Use ``/etc/environment`` for static system wide variable assignment after
1356boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001357
1358.. code-block:: yaml
1359
1360 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +01001361 system:
1362 env:
1363 BOB_VARIABLE: Alice
1364 ...
1365 BOB_PATH:
1366 - /srv/alice/bin
1367 - /srv/bob/bin
1368 ...
1369 ftp_proxy: none
1370 http_proxy: http://global-http-proxy.host.local:8080
1371 https_proxy: ${linux:system:proxy:https}
1372 no_proxy:
1373 - 192.168.0.80
1374 - 192.168.1.80
1375 - .domain.com
1376 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001377 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001378 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001379 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001380 ftp: ftp://proxy.host.local:2121
1381 http: http://proxy.host.local:3142
1382 https: https://proxy.host.local:3143
1383 noproxy:
1384 - .domain.com
1385 - .local
1386
1387Configure profile.d scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001388
Ales Komarek417e8c52017-08-25 15:10:29 +02001389The profile.d scripts are being sourced during .sh execution and support
1390variable expansion in opposite to /etc/environment global settings in
1391``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001392
1393.. code-block:: yaml
1394
1395 linux:
1396 system:
1397 profile:
1398 locales: |
1399 export LANG=C
1400 export LC_ALL=C
1401 ...
1402 vi_flavors.sh: |
1403 export PAGER=view
1404 export EDITOR=vim
1405 alias vi=vim
1406 shell_locales.sh: |
1407 export LANG=en_US
1408 export LC_ALL=en_US.UTF-8
1409 shell_proxies.sh: |
1410 export FTP_PROXY=ftp://127.0.3.3:2121
1411 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001412
1413Linux with hosts
1414
Filip Pytloun86506fe2017-01-26 14:36:16 +01001415Parameter purge_hosts will enforce whole /etc/hosts file, removing entries
1416that are not defined in model except defaults for both IPv4 and IPv6 localhost
1417and hostname + fqdn.
Ales Komarek417e8c52017-08-25 15:10:29 +02001418
Filip Pytloun86506fe2017-01-26 14:36:16 +01001419It's good to use this option if you want to ensure /etc/hosts is always in a
1420clean state however it's not enabled by default for safety.
1421
Filip Pytlounf5383a42015-10-06 16:28:32 +02001422.. code-block:: yaml
1423
1424 linux:
1425 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001426 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001427 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001428 # No need to define this one if purge_hosts is true
1429 hostname:
1430 address: 127.0.1.1
1431 names:
1432 - ${linux:network:fqdn}
1433 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001434 node1:
1435 address: 192.168.10.200
1436 names:
1437 - node2.domain.com
1438 - service2.domain.com
1439 node2:
1440 address: 192.168.10.201
1441 names:
1442 - node2.domain.com
1443 - service2.domain.com
1444
Ales Komarek417e8c52017-08-25 15:10:29 +02001445Linux with hosts collected from mine
1446
1447In this case all dns records defined within infrastrucuture will be passed to
1448local hosts records or any DNS server. Only hosts with `grain` parameter to
1449true will be propagated to the mine.
1450
1451.. code-block:: yaml
1452
1453 linux:
1454 network:
1455 purge_hosts: true
1456 mine_dns_records: true
1457 host:
1458 node1:
1459 address: 192.168.10.200
1460 grain: true
1461 names:
1462 - node2.domain.com
1463 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01001464
Filip Pytlounde9bea52016-01-11 15:39:10 +01001465Setup resolv.conf, nameservers, domain and search domains
1466
1467.. code-block:: yaml
1468
1469 linux:
1470 network:
1471 resolv:
1472 dns:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001473 - 8.8.4.4
1474 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01001475 domain: my.example.com
1476 search:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001477 - my.example.com
1478 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01001479 options:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001480 - ndots: 5
1481 - timeout: 2
1482 - attempts: 2
Filip Pytlounde9bea52016-01-11 15:39:10 +01001483
Ales Komarek417e8c52017-08-25 15:10:29 +02001484setting custom TX queue length for tap interfaces
Andrii Petrenko735761d2017-03-21 17:17:35 -07001485
1486.. code-block:: yaml
1487
1488 linux:
1489 network:
1490 tap_custom_txqueuelen: 10000
1491
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001492DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001493
1494**DPDK OVS NIC**
1495
1496.. code-block:: yaml
1497
1498 linux:
1499 network:
1500 bridge: openvswitch
1501 dpdk:
1502 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001503 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001504 openvswitch:
1505 pmd_cpu_mask: "0x6"
1506 dpdk_socket_mem: "1024,1024"
1507 dpdk_lcore_mask: "0x400"
1508 memory_channels: 2
1509 interface:
1510 dpkd0:
1511 name: ${_param:dpdk_nic}
1512 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001513 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001514 enabled: true
1515 type: dpdk_ovs_port
1516 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001517 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001518 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01001519 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001520 br-prv:
1521 enabled: true
1522 type: dpdk_ovs_bridge
1523
1524**DPDK OVS Bond**
1525
1526.. code-block:: yaml
1527
1528 linux:
1529 network:
1530 bridge: openvswitch
1531 dpdk:
1532 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001533 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001534 openvswitch:
1535 pmd_cpu_mask: "0x6"
1536 dpdk_socket_mem: "1024,1024"
1537 dpdk_lcore_mask: "0x400"
1538 memory_channels: 2
1539 interface:
1540 dpdk_second_nic:
1541 name: ${_param:primary_second_nic}
1542 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001543 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001544 bond: dpdkbond0
1545 enabled: true
1546 type: dpdk_ovs_port
1547 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001548 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001549 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001550 dpdk_first_nic:
1551 name: ${_param:primary_first_nic}
1552 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001553 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001554 bond: dpdkbond0
1555 enabled: true
1556 type: dpdk_ovs_port
1557 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001558 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001559 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001560 dpdkbond0:
1561 enabled: true
1562 bridge: br-prv
1563 type: dpdk_ovs_bond
1564 mode: active-backup
1565 br-prv:
1566 enabled: true
1567 type: dpdk_ovs_bridge
1568
Dzmitry Stremkouskif619b072018-03-15 20:13:42 +01001569**DPDK OVS LACP Bond with vlan tag**
1570
1571.. code-block:: yaml
1572
1573 linux:
1574 network:
1575 bridge: openvswitch
1576 dpdk:
1577 enabled: true
1578 driver: uio
1579 openvswitch:
1580 pmd_cpu_mask: "0x6"
1581 dpdk_socket_mem: "1024,1024"
1582 dpdk_lcore_mask: "0x400"
1583 memory_channels: "2"
1584 interface:
1585 eth3:
1586 enabled: true
1587 type: eth
1588 proto: manual
1589 name: ${_param:tenant_first_nic}
1590 eth4:
1591 enabled: true
1592 type: eth
1593 proto: manual
1594 name: ${_param:tenant_second_nic}
1595 dpdk0:
1596 name: ${_param:tenant_first_nic}
1597 pci: "0000:81:00.0"
1598 driver: igb_uio
1599 bond: bond1
1600 enabled: true
1601 type: dpdk_ovs_port
1602 n_rxq: 2
1603 dpdk1:
1604 name: ${_param:tenant_second_nic}
1605 pci: "0000:81:00.1"
1606 driver: igb_uio
1607 bond: bond1
1608 enabled: true
1609 type: dpdk_ovs_port
1610 n_rxq: 2
1611 bond1:
1612 enabled: true
1613 bridge: br-prv
1614 type: dpdk_ovs_bond
1615 mode: balance-slb
1616 br-prv:
1617 enabled: true
1618 type: dpdk_ovs_bridge
1619 tag: ${_param:tenant_vlan}
1620 address: ${_param:tenant_address}
1621 netmask: ${_param:tenant_network_netmask}
1622
Jakub Pavlikaa759062017-03-13 15:57:26 +01001623**DPDK OVS bridge for VXLAN**
1624
1625If VXLAN is used as tenant segmentation then ip address must be set on br-prv
1626
1627.. code-block:: yaml
1628
1629 linux:
1630 network:
1631 ...
1632 interface:
1633 br-prv:
1634 enabled: true
1635 type: dpdk_ovs_bridge
1636 address: 192.168.50.0
1637 netmask: 255.255.255.0
Michael Polenchukd173d552018-01-22 15:22:47 +04001638 tag: 101
Jakub Pavlikaa759062017-03-13 15:57:26 +01001639 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001640
Oleksii Chupryne2151ff2018-03-13 16:01:12 +02001641
1642
1643**DPDK OVS bridge with Linux network interface**
1644
1645.. code-block:: yaml
1646
1647 linux:
1648 network:
1649 ...
1650 interface:
1651 eth0:
1652 type: eth
1653 ovs_bridge: br-prv
1654 ...
1655 br-prv:
1656 enabled: true
1657 type: dpdk_ovs_bridge
1658 ...
1659
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001660Linux storage
1661-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02001662
1663Linux with mounted Samba
1664
1665.. code-block:: yaml
1666
1667 linux:
1668 storage:
1669 enabled: true
1670 mount:
1671 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01001672 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001673 - path: /media/myuser/public/
1674 - device: //192.168.0.1/storage
1675 - file_system: cifs
1676 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
1677
Jiri Broulikb017f932017-03-31 13:55:36 +02001678NFS mount
1679
1680.. code-block:: yaml
1681
1682 linux:
1683 storage:
1684 enabled: true
1685 mount:
1686 nfs_glance:
1687 enabled: true
1688 path: /var/lib/glance/images
1689 device: 172.16.10.110:/var/nfs/glance
1690 file_system: nfs
1691 opts: rw,sync
1692
1693
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001694File swap configuration
Filip Pytlounf5383a42015-10-06 16:28:32 +02001695
1696.. code-block:: yaml
1697
1698 linux:
1699 storage:
1700 enabled: true
1701 swap:
1702 file:
1703 enabled: true
1704 engine: file
1705 device: /swapfile
1706 size: 1024
1707
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001708Partition swap configuration
Lachlan Evenson30676512016-01-22 15:43:28 -08001709
1710.. code-block:: yaml
1711
1712 linux:
1713 storage:
1714 enabled: true
1715 swap:
1716 partition:
1717 enabled: true
1718 engine: partition
1719 device: /dev/vg0/swap
1720
Filip Pytlounc8a001a2015-12-15 14:09:19 +01001721LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
1722
1723.. code-block:: yaml
1724
1725 parameters:
1726 linux:
1727 storage:
1728 mount:
1729 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01001730 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01001731 device: /dev/vg1/data
1732 file_system: ext4
1733 path: /mnt/data
1734 lvm:
1735 vg1:
1736 enabled: true
1737 devices:
1738 - /dev/sdb
1739 volume:
1740 data:
1741 size: 40G
1742 mount: ${linux:storage:mount:data}
1743
Jakub Pavlik4f742142017-08-08 15:05:50 +02001744Create partitions on disk. Specify size in MB. It expects empty
Piotr Krukd51911b2017-12-04 11:27:08 +01001745disk without any existing partitions. (set startsector=1, if you want to start partitions from 2048)
Jakub Pavlik4f742142017-08-08 15:05:50 +02001746
1747.. code-block:: yaml
1748
1749 linux:
1750 storage:
1751 disk:
1752 first_drive:
Piotr Krukd51911b2017-12-04 11:27:08 +01001753 startsector: 1
Jakub Pavlik4f742142017-08-08 15:05:50 +02001754 name: /dev/loop1
1755 type: gpt
1756 partitions:
1757 - size: 200 #size in MB
1758 type: fat32
1759 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02001760 mkfs: True
1761 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02001762 /dev/vda1:
1763 partitions:
1764 - size: 5
1765 type: ext2
1766 - size: 10
1767 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02001768
1769Multipath with Fujitsu Eternus DXL
1770
1771.. code-block:: yaml
1772
1773 parameters:
1774 linux:
1775 storage:
1776 multipath:
1777 enabled: true
1778 blacklist_devices:
1779 - /dev/sda
1780 - /dev/sdb
1781 backends:
1782 - fujitsu_eternus_dxl
1783
1784Multipath with Hitachi VSP 1000
1785
1786.. code-block:: yaml
1787
1788 parameters:
1789 linux:
1790 storage:
1791 multipath:
1792 enabled: true
1793 blacklist_devices:
1794 - /dev/sda
1795 - /dev/sdb
1796 backends:
1797 - hitachi_vsp1000
1798
1799Multipath with IBM Storwize
1800
1801.. code-block:: yaml
1802
1803 parameters:
1804 linux:
1805 storage:
1806 multipath:
1807 enabled: true
1808 blacklist_devices:
1809 - /dev/sda
1810 - /dev/sdb
1811 backends:
1812 - ibm_storwize
1813
1814Multipath with multiple backends
1815
1816.. code-block:: yaml
1817
1818 parameters:
1819 linux:
1820 storage:
1821 multipath:
1822 enabled: true
1823 blacklist_devices:
1824 - /dev/sda
1825 - /dev/sdb
1826 - /dev/sdc
1827 - /dev/sdd
1828 backends:
1829 - ibm_storwize
1830 - fujitsu_eternus_dxl
1831 - hitachi_vsp1000
1832
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03001833PAM LDAP integration
1834
1835.. code-block:: yaml
1836
1837 parameters:
1838 linux:
1839 system:
1840 auth:
1841 enabled: true
Dzmitry Stremkouski602735d2018-05-09 22:31:39 +02001842 mkhomedir:
1843 enabled: true
1844 umask: 0027
Dmitry Stremkouski7d8d67a2017-11-15 13:08:19 +03001845 ldap:
1846 enabled: true
1847 binddn: cn=bind,ou=service_users,dc=example,dc=com
1848 bindpw: secret
1849 uri: ldap://127.0.0.1
1850 base: ou=users,dc=example,dc=com
1851 ldap_version: 3
1852 pagesize: 65536
1853 referrals: off
1854 filter:
1855 passwd: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
1856 shadow: (&(&(objectClass=person)(uidNumber=*))(unixHomeDirectory=*))
1857 group: (&(objectClass=group)(gidNumber=*))
1858
Ales Komareka634f4b2016-10-02 13:11:04 +02001859Disabled multipath (the default setup)
1860
1861.. code-block:: yaml
1862
1863 parameters:
1864 linux:
1865 storage:
1866 multipath:
1867 enabled: false
1868
Simon Pasquier375001e2017-01-26 13:22:33 +01001869Linux with local loopback device
1870
1871.. code-block:: yaml
1872
1873 linux:
1874 storage:
1875 loopback:
1876 disk1:
1877 file: /srv/disk1
1878 size: 50G
1879
Filip Pytlounb2c8f852016-11-21 17:03:43 +01001880External config generation
1881--------------------------
1882
1883You are able to use config support metadata between formulas and only generate
1884config files for external use, eg. docker, etc.
1885
1886.. code-block:: yaml
1887
1888 parameters:
1889 linux:
1890 system:
1891 config:
1892 pillar:
1893 jenkins:
1894 master:
1895 home: /srv/volumes/jenkins
1896 approved_scripts:
1897 - method java.net.URL openConnection
1898 credentials:
1899 - type: username_password
1900 scope: global
1901 id: test
1902 desc: Testing credentials
1903 username: test
1904 password: test
1905
Vladimir Ereminccf28842017-04-10 23:52:10 +03001906Netconsole Remote Kernel Logging
1907--------------------------------
1908
1909Netconsole logger could be configured for configfs-enabled kernels
1910(`CONFIG_NETCONSOLE_DYNAMIC` should be enabled). Configuration applies both in
1911runtime (if network is already configured), and on-boot after interface
1912initialization. Notes:
1913
1914 * receiver could be located only in same L3 domain
1915 (or you need to configure gateway MAC manually)
1916 * receiver's MAC is detected only on configuration time
1917 * using broadcast MAC is not recommended
1918
1919.. code-block:: yaml
1920
1921 parameters:
1922 linux:
1923 system:
1924 netconsole:
1925 enabled: true
1926 port: 514 (optional)
1927 loglevel: debug (optional)
1928 target:
1929 192.168.0.1:
1930 interface: bond0
1931 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02001932
Filip Pytlounf5383a42015-10-06 16:28:32 +02001933Usage
1934=====
1935
1936Set mtu of network interface eth0 to 1400
1937
1938.. code-block:: bash
1939
1940 ip link set dev eth0 mtu 1400
1941
1942Read more
1943=========
1944
1945* https://www.archlinux.org/
1946* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu
Filip Pytloun018f8712017-02-02 13:02:03 +01001947
1948Documentation and Bugs
1949======================
1950
1951To learn how to install and update salt-formulas, consult the documentation
1952available online at:
1953
1954 http://salt-formulas.readthedocs.io/
1955
1956In the unfortunate event that bugs are discovered, they should be reported to
1957the appropriate issue tracker. Use Github issue tracker for specific salt
1958formula:
1959
1960 https://github.com/salt-formulas/salt-formula-linux/issues
1961
1962For feature requests, bug reports or blueprints affecting entire ecosystem,
1963use Launchpad salt-formulas project:
1964
1965 https://launchpad.net/salt-formulas
1966
1967You can also join salt-formulas-users team and subscribe to mailing list:
1968
1969 https://launchpad.net/~salt-formulas-users
1970
1971Developers wishing to work on the salt-formulas projects should always base
1972their work on master branch and submit pull request against specific formula.
1973
1974 https://github.com/salt-formulas/salt-formula-linux
1975
1976Any questions or feedback is always welcome so feel free to join our IRC
1977channel:
1978
1979 #salt-formulas @ irc.freenode.net