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