blob: 9a3a5a5c850c630933255447b3645f3322cd2dce [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 Pytloun281034a2016-01-04 18:06:22 +0100331Kernel
332~~~~~~
333
334Install always up to date LTS kernel and headers from Ubuntu trusty:
335
336.. code-block:: yaml
337
338 linux:
339 system:
340 kernel:
341 type: generic
342 lts: trusty
343 headers: true
344
Tomáš Kukrálba35b212017-02-15 17:59:46 +0100345Load kernel modules and add them to `/etc/modules`:
346
347.. code-block:: yaml
348
349 linux:
350 system:
351 kernel:
352 modules:
353 - nf_conntrack
354 - tp_smapi
355 - 8021q
356
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300357Configure or blacklist kernel modules with additional options to `/etc/modprobe.d` following example
358will add `/etc/modprobe.d/nf_conntrack.conf` file with line `options nf_conntrack hashsize=262144`:
359
360.. code-block:: yaml
361
362 linux:
363 system:
364 kernel:
365 module:
366 nf_conntrack:
367 option:
368 hashsize: 262144
369
370
371
Filip Pytloun281034a2016-01-04 18:06:22 +0100372Install specific kernel version and ensure all other kernel packages are
373not present. Also install extra modules and headers for this kernel:
374
375.. code-block:: yaml
376
377 linux:
378 system:
379 kernel:
380 type: generic
381 extra: true
382 headers: true
383 version: 4.2.0-22
384
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100385Systcl kernel parameters
386
387.. code-block:: yaml
388
389 linux:
390 system:
391 kernel:
392 sysctl:
393 net.ipv4.tcp_keepalive_intvl: 3
394 net.ipv4.tcp_keepalive_time: 30
395 net.ipv4.tcp_keepalive_probes: 8
396
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100397
398CPU
399~~~
400
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300401Enable cpufreq governor for every cpu:
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100402
403.. code-block:: yaml
404
405 linux:
406 system:
407 cpu:
408 governor: performance
409
Filip Pytloun361096c2017-08-23 10:57:20 +0200410Sysfs
411~~~~~
412
413Install sysfsutils and set sysfs attributes:
414
415.. code-block:: yaml
416
417 linux:
418 system:
419 sysfs:
420 scheduler:
421 block/sda/queue/scheduler: deadline
422 power:
423 mode:
424 power/state: 0660
425 owner:
426 power/state: "root:power"
427 devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
428
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100429Huge Pages
430~~~~~~~~~~~~
431
432Huge Pages give a performance boost to applications that intensively deal
433with memory allocation/deallocation by decreasing memory fragmentation.
434
435.. code-block:: yaml
436
437 linux:
438 system:
439 kernel:
440 hugepages:
441 small:
442 size: 2M
443 count: 107520
444 mount_point: /mnt/hugepages_2MB
445 mount: false/true # default false
446 large:
447 default: true # default automatically mounted
448 size: 1G
449 count: 210
450 mount_point: /mnt/hugepages_1GB
451
452Note: not recommended to use both pagesizes in concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100453
Jakub Pavlik5398d872017-02-13 22:30:47 +0100454Intel SR-IOV
455~~~~~~~~~~~~
456
457PCI-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.
458
459.. code-block:: yaml
460
461 linux:
462 system:
463 kernel:
464 sriov: True
465 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
466 rc:
467 local: |
468 #!/bin/sh -e
469 # Enable 7 VF on eth1
470 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
471 exit 0
472
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100473Isolate CPU options
474~~~~~~~~~~~~~~~~~~~
475
476Remove the specified CPUs, as defined by the cpu_number values, from the general kernel
477SMP balancing and scheduler algroithms. The only way to move a process onto or off an
478"isolated" CPU is via the CPU affinity syscalls. cpu_number begins at 0, so the
479maximum value is 1 less than the number of CPUs on the system.
480
481.. code-block:: yaml
482
483 linux:
484 system:
485 kernel:
486 isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100487
Filip Pytlounf5383a42015-10-06 16:28:32 +0200488Repositories
489~~~~~~~~~~~~
490
491RedHat based Linux with additional OpenStack repo
492
493.. code-block:: yaml
494
495 linux:
496 system:
497 ...
498 repo:
499 rdo-icehouse:
500 enabled: true
501 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
502 pgpcheck: 0
503
504Ensure system repository to use czech Debian mirror (``default: true``)
505Also pin it's packages with priority 900.
506
507.. code-block:: yaml
508
509 linux:
510 system:
511 repo:
512 debian:
513 default: true
514 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
515 # Import signing key from URL if needed
516 key_url: "http://dummy.com/public.gpg"
517 pin:
518 - pin: 'origin "ftp.cz.debian.org"'
519 priority: 900
520 package: '*'
521
Petr Michalec10462bb2017-03-23 19:18:08 +0100522
523Package manager proxy setup globally:
524
525.. code-block:: yaml
526
527 linux:
528 system:
529 ...
530 repo:
531 apt-mk:
532 source: "deb http://apt-mk.mirantis.com/ stable main salt"
533 ...
534 proxy:
535 pkg:
536 enabled: true
537 ftp: ftp://ftp-proxy-for-apt.host.local:2121
538 ...
539 # NOTE: Global defaults for any other componet that configure proxy on the system.
540 # If your environment has just one simple proxy, set it on linux:system:proxy.
541 #
542 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
543 # as for https and http
544 ftp: ftp://proxy.host.local:2121
545 http: http://proxy.host.local:3142
546 https: https://proxy.host.local:3143
547
548Package manager proxy setup per repository:
549
550.. code-block:: yaml
551
552 linux:
553 system:
554 ...
555 repo:
556 debian:
557 source: "deb http://apt-mk.mirantis.com/ stable main salt"
558 ...
559 apt-mk:
560 source: "deb http://apt-mk.mirantis.com/ stable main salt"
561 # per repository proxy
562 proxy:
563 enabled: true
564 http: http://maas-01:8080
565 https: http://maas-01:8080
566 ...
567 proxy:
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600568 # package manager fallback defaults
Petr Michalec10462bb2017-03-23 19:18:08 +0100569 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
570 pkg:
571 enabled: true
572 ftp: ftp://proxy.host.local:2121
573 #http: http://proxy.host.local:3142
574 #https: https://proxy.host.local:3143
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600575 ...
Petr Michalec10462bb2017-03-23 19:18:08 +0100576 # global system fallback system defaults
577 ftp: ftp://proxy.host.local:2121
578 http: http://proxy.host.local:3142
579 https: https://proxy.host.local:3143
580
581
Jiri Broulik34a29b42017-04-25 14:42:54 +0200582Remove all repositories:
583
584.. code-block:: yaml
585
586 linux:
587 system:
588 purge_repos: true
589
590
Petr Michalec10462bb2017-03-23 19:18:08 +0100591RC
592~~
593
Jakub Pavlik78859382016-01-21 11:26:39 +0100594rc.local example
595
596.. code-block:: yaml
597
598 linux:
599 system:
600 rc:
601 local: |
602 #!/bin/sh -e
603 #
604 # rc.local
605 #
606 # This script is executed at the end of each multiuser runlevel.
607 # Make sure that the script will "exit 0" on success or any other
608 # value on error.
609 #
610 # In order to enable or disable this script just change the execution
611 # bits.
612 #
613 # By default this script does nothing.
614 exit 0
615
Petr Michalec10462bb2017-03-23 19:18:08 +0100616
Filip Pytloun1f40dac2016-01-22 15:52:57 +0100617Prompt
618~~~~~~
619
620Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
621user can have different prompt.
622
623.. code-block:: yaml
624
625 linux:
626 system:
627 prompt:
628 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\\]
629 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
630
631On Debian systems to set prompt system-wide it's necessary to remove setting
632PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
633``/etc/skel/.bashrc``). This formula will do this automatically, but will not
Filip Pytlound9b68da2016-01-22 15:58:41 +0100634touch existing user's ``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +0100635
Filip Pytlouneef11c12016-03-25 11:00:23 +0100636Bash
637~~~~
638
639Fix bash configuration to preserve history across sessions (like ZSH does by
640default).
641
642.. code-block:: yaml
643
644 linux:
645 system:
646 bash:
647 preserve_history: true
648
Filip Pytloune874dfb2016-01-22 16:57:34 +0100649Message of the day
650~~~~~~~~~~~~~~~~~~
651
652``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
653day. Setting custom motd will cleanup existing ones.
654
655.. code-block:: yaml
656
657 linux:
658 system:
659 motd:
660 - release: |
661 #!/bin/sh
662 [ -r /etc/lsb-release ] && . /etc/lsb-release
663
664 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
665 # Fall back to using the very slow lsb_release utility
666 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
667 fi
668
669 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
670 - warning: |
671 #!/bin/sh
672 printf "This is [company name] network.\n"
673 printf "Unauthorized access strictly prohibited.\n"
674
Marek Celoud713e9072017-05-18 15:20:25 +0200675Services
676~~~~~~~~
677
678Stop and disable linux service:
679
680.. code-block:: yaml
681
682 linux:
683 system:
684 service:
685 apt-daily.timer:
686 status: dead
687
688Possible status is dead (disable service by default), running (enable service by default), enabled, disabled.
689
Filip Pytloun2f70b492016-02-19 15:55:25 +0100690RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +0100691^^^^^^^^^^^^^
Filip Pytloun2f70b492016-02-19 15:55:25 +0100692
693Unfortunately ``update-motd`` is currently not available for RHEL so there's
694no native support for dynamic motd.
695You can still set static one, only pillar structure differs:
696
697.. code-block:: yaml
698
699 linux:
700 system:
701 motd: |
702 This is [company name] network.
703 Unauthorized access strictly prohibited.
704
Filip Pytloun8296bb92016-02-19 18:42:09 +0100705Haveged
706~~~~~~~
707
708If you are running headless server and are low on entropy, it may be a good
709idea to setup Haveged.
710
711.. code-block:: yaml
712
713 linux:
714 system:
715 haveged:
716 enabled: true
717
Filip Pytlounf5383a42015-10-06 16:28:32 +0200718Linux network
719-------------
720
721Linux with network manager
722
723.. code-block:: yaml
724
725 linux:
726 network:
727 enabled: true
728 network_manager: true
729
730Linux with default static network interfaces, default gateway interface and DNS servers
731
732.. code-block:: yaml
733
734 linux:
735 network:
736 enabled: true
737 interface:
738 eth0:
739 enabled: true
740 type: eth
741 address: 192.168.0.102
742 netmask: 255.255.255.0
743 gateway: 192.168.0.1
744 name_servers:
745 - 8.8.8.8
746 - 8.8.4.4
747 mtu: 1500
748
jan kaufman6d30adf2016-01-18 17:30:12 +0100749Linux with bonded interfaces and disabled NetworkManager
Filip Pytlounf5383a42015-10-06 16:28:32 +0200750
751.. code-block:: yaml
752
753 linux:
754 network:
755 enabled: true
756 interface:
757 eth0:
758 type: eth
759 ...
760 eth1:
761 type: eth
762 ...
763 bond0:
764 enabled: true
765 type: bond
766 address: 192.168.0.102
767 netmask: 255.255.255.0
768 mtu: 1500
769 use_in:
770 - interface: ${linux:interface:eth0}
771 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +0100772 network_manager:
773 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200774
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100775Linux with vlan interface_params
776
777.. code-block:: yaml
778
779 linux:
780 network:
781 enabled: true
782 interface:
783 vlan69:
784 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +0100785 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100786 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100787
Filip Pytlounf5383a42015-10-06 16:28:32 +0200788Linux with wireless interface parameters
789
790.. code-block:: yaml
791
792 linux:
793 network:
794 enabled: true
795 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100796 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200797 interface:
798 wlan0:
799 type: eth
800 wireless:
801 essid: example
802 key: example_key
803 security: wpa
804 priority: 1
805
806Linux networks with routes defined
807
808.. code-block:: yaml
809
810 linux:
811 network:
812 enabled: true
813 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100814 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200815 interface:
816 eth0:
817 type: eth
818 route:
819 default:
820 address: 192.168.0.123
821 netmask: 255.255.255.0
822 gateway: 192.168.0.1
823
824Native Linux Bridges
825
826.. code-block:: yaml
827
828 linux:
829 network:
830 interface:
831 eth1:
832 enabled: true
833 type: eth
834 proto: manual
835 up_cmds:
836 - ip address add 0/0 dev $IFACE
837 - ip link set $IFACE up
838 down_cmds:
839 - ip link set $IFACE down
840 br-ex:
841 enabled: true
842 type: bridge
843 address: ${linux:network:host:public_local:address}
844 netmask: 255.255.255.0
845 use_interfaces:
846 - eth1
847
848OpenVswitch Bridges
849
850.. code-block:: yaml
851
852 linux:
853 network:
854 bridge: openvswitch
855 interface:
856 eth1:
857 enabled: true
858 type: eth
859 proto: manual
860 up_cmds:
861 - ip address add 0/0 dev $IFACE
862 - ip link set $IFACE up
863 down_cmds:
864 - ip link set $IFACE down
865 br-ex:
866 enabled: true
867 type: bridge
868 address: ${linux:network:host:public_local:address}
869 netmask: 255.255.255.0
870 use_interfaces:
871 - eth1
872
Petr Jediný8f8ae542017-07-13 16:19:12 +0200873Debian manual proto interfaces
874
875When you are changing interface proto from static in up state to manual, you
876may need to flush ip addresses. For example, if you want to use the interface
877and the ip on the bridge. This can be done by setting the ``ipflush_onchange``
878to true.
879
880.. code-block:: yaml
881
882 linux:
883 network:
884 interface:
885 eth1:
886 enabled: true
887 type: eth
888 proto: manual
889 mtu: 9100
890 ipflush_onchange: true
891
892
Petr Jedinýd577cb52017-06-28 20:17:49 +0200893Concatinating and removing interface files
894
895Debian based distributions have `/etc/network/interfaces.d/` directory, where
896you can store configuration of network interfaces in separate files. You can
897concatinate the files to the defined destination when needed, this operation
898removes the file from the `/etc/network/interfaces.d/`. If you just need to
899remove iface files, you can use the `remove_iface_files` key.
900
901.. code-block:: yaml
902
903 linux:
904 network:
905 concat_iface_files:
906 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
907 dst: '/etc/network/interfaces'
908 remove_iface_files:
909 - '/etc/network/interfaces.d/90-custom.cfg'
910
911
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600912DHCP client configuration
913
914None of the keys is mandatory, include only those you really need. For full list
915of available options under send, supersede, prepend, append refer to dhcp-options(5)
916
917.. code-block:: yaml
918
919 linux:
920 network:
921 dhclient:
922 enabled: true
923 backoff_cutoff: 15
924 initial_interval: 10
925 reboot: 10
926 retry: 60
927 select_timeout: 0
928 timeout: 120
929 send:
930 - option: host-name
931 declaration: "= gethostname()"
932 supersede:
933 - option: host-name
934 declaration: "spaceship"
935 - option: domain-name
936 declaration: "domain.home"
937 #- option: arp-cache-timeout
938 # declaration: 20
939 prepend:
940 - option: domain-name-servers
941 declaration:
942 - 8.8.8.8
943 - 8.8.4.4
944 - option: domain-search
945 declaration:
946 - example.com
947 - eng.example.com
948 #append:
949 #- option: domain-name-servers
950 # declaration: 127.0.0.1
951 # ip or subnet to reject dhcp offer from
952 reject:
953 - 192.33.137.209
954 - 10.0.2.0/24
955 request:
956 - subnet-mask
957 - broadcast-address
958 - time-offset
959 - routers
960 - domain-name
961 - domain-name-servers
962 - domain-search
963 - host-name
964 - dhcp6.name-servers
965 - dhcp6.domain-search
966 - dhcp6.fqdn
967 - dhcp6.sntp-servers
968 - netbios-name-servers
969 - netbios-scope
970 - interface-mtu
971 - rfc3442-classless-static-routes
972 - ntp-servers
973 require:
974 - subnet-mask
975 - domain-name-servers
976 # if per interface configuration required add below
977 interface:
978 ens2:
979 initial_interval: 11
980 reject:
981 - 192.33.137.210
982 ens3:
983 initial_interval: 12
984 reject:
985 - 192.33.137.211
986
987
Petr Michalec10462bb2017-03-23 19:18:08 +0100988Configure global environment variables
989~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
990
991Linux /etc/environment:
992``/etc/environment`` is for static system wide variable assignment after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +0200993
994.. code-block:: yaml
995
996 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +0100997 system:
998 env:
999 BOB_VARIABLE: Alice
1000 ...
1001 BOB_PATH:
1002 - /srv/alice/bin
1003 - /srv/bob/bin
1004 ...
1005 ftp_proxy: none
1006 http_proxy: http://global-http-proxy.host.local:8080
1007 https_proxy: ${linux:system:proxy:https}
1008 no_proxy:
1009 - 192.168.0.80
1010 - 192.168.1.80
1011 - .domain.com
1012 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001013 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001014 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001015 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001016 ftp: ftp://proxy.host.local:2121
1017 http: http://proxy.host.local:3142
1018 https: https://proxy.host.local:3143
1019 noproxy:
1020 - .domain.com
1021 - .local
1022
1023Configure profile.d scripts
1024~~~~~~~~~~~~~~~~~~~~~~~~~~~
1025
1026Linux /etc/profile.d:
1027The profile.d scripts are being sourced during .sh execution and support variable expansion in opposite to /etc/environment
1028global settings in ``/etc/environment``.
1029
1030.. code-block:: yaml
1031
1032 linux:
1033 system:
1034 profile:
1035 locales: |
1036 export LANG=C
1037 export LC_ALL=C
1038 ...
1039 vi_flavors.sh: |
1040 export PAGER=view
1041 export EDITOR=vim
1042 alias vi=vim
1043 shell_locales.sh: |
1044 export LANG=en_US
1045 export LC_ALL=en_US.UTF-8
1046 shell_proxies.sh: |
1047 export FTP_PROXY=ftp://127.0.3.3:2121
1048 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001049
1050Linux with hosts
Petr Michalec10462bb2017-03-23 19:18:08 +01001051~~~~~~~~~~~~~~~~
Filip Pytlounf5383a42015-10-06 16:28:32 +02001052
Filip Pytloun86506fe2017-01-26 14:36:16 +01001053Parameter purge_hosts will enforce whole /etc/hosts file, removing entries
1054that are not defined in model except defaults for both IPv4 and IPv6 localhost
1055and hostname + fqdn.
1056It's good to use this option if you want to ensure /etc/hosts is always in a
1057clean state however it's not enabled by default for safety.
1058
Filip Pytlounf5383a42015-10-06 16:28:32 +02001059.. code-block:: yaml
1060
1061 linux:
1062 network:
1063 ...
Filip Pytloun86506fe2017-01-26 14:36:16 +01001064 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001065 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001066 # No need to define this one if purge_hosts is true
1067 hostname:
1068 address: 127.0.1.1
1069 names:
1070 - ${linux:network:fqdn}
1071 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001072 node1:
1073 address: 192.168.10.200
1074 names:
1075 - node2.domain.com
1076 - service2.domain.com
1077 node2:
1078 address: 192.168.10.201
1079 names:
1080 - node2.domain.com
1081 - service2.domain.com
1082
Filip Pytloun86506fe2017-01-26 14:36:16 +01001083
Filip Pytlounde9bea52016-01-11 15:39:10 +01001084Setup resolv.conf, nameservers, domain and search domains
Petr Michalec10462bb2017-03-23 19:18:08 +01001085~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filip Pytlounde9bea52016-01-11 15:39:10 +01001086
1087.. code-block:: yaml
1088
1089 linux:
1090 network:
1091 resolv:
1092 dns:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001093 - 8.8.4.4
1094 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01001095 domain: my.example.com
1096 search:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001097 - my.example.com
1098 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01001099 options:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001100 - ndots: 5
1101 - timeout: 2
1102 - attempts: 2
Filip Pytlounde9bea52016-01-11 15:39:10 +01001103
Andrii Petrenko735761d2017-03-21 17:17:35 -07001104**setting custom TX queue length for tap interfaces**
1105
1106.. code-block:: yaml
1107
1108 linux:
1109 network:
1110 tap_custom_txqueuelen: 10000
1111
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001112DPDK OVS interfaces
1113--------------------
1114
1115**DPDK OVS NIC**
1116
1117.. code-block:: yaml
1118
1119 linux:
1120 network:
1121 bridge: openvswitch
1122 dpdk:
1123 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001124 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001125 openvswitch:
1126 pmd_cpu_mask: "0x6"
1127 dpdk_socket_mem: "1024,1024"
1128 dpdk_lcore_mask: "0x400"
1129 memory_channels: 2
1130 interface:
1131 dpkd0:
1132 name: ${_param:dpdk_nic}
1133 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001134 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001135 enabled: true
1136 type: dpdk_ovs_port
1137 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001138 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001139 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01001140 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001141 br-prv:
1142 enabled: true
1143 type: dpdk_ovs_bridge
1144
1145**DPDK OVS Bond**
1146
1147.. code-block:: yaml
1148
1149 linux:
1150 network:
1151 bridge: openvswitch
1152 dpdk:
1153 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001154 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001155 openvswitch:
1156 pmd_cpu_mask: "0x6"
1157 dpdk_socket_mem: "1024,1024"
1158 dpdk_lcore_mask: "0x400"
1159 memory_channels: 2
1160 interface:
1161 dpdk_second_nic:
1162 name: ${_param:primary_second_nic}
1163 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001164 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001165 bond: dpdkbond0
1166 enabled: true
1167 type: dpdk_ovs_port
1168 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001169 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001170 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001171 dpdk_first_nic:
1172 name: ${_param:primary_first_nic}
1173 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001174 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001175 bond: dpdkbond0
1176 enabled: true
1177 type: dpdk_ovs_port
1178 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001179 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001180 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001181 dpdkbond0:
1182 enabled: true
1183 bridge: br-prv
1184 type: dpdk_ovs_bond
1185 mode: active-backup
1186 br-prv:
1187 enabled: true
1188 type: dpdk_ovs_bridge
1189
Jakub Pavlikaa759062017-03-13 15:57:26 +01001190**DPDK OVS bridge for VXLAN**
1191
1192If VXLAN is used as tenant segmentation then ip address must be set on br-prv
1193
1194.. code-block:: yaml
1195
1196 linux:
1197 network:
1198 ...
1199 interface:
1200 br-prv:
1201 enabled: true
1202 type: dpdk_ovs_bridge
1203 address: 192.168.50.0
1204 netmask: 255.255.255.0
1205 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001206
1207Linux storage
1208-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02001209
1210Linux with mounted Samba
1211
1212.. code-block:: yaml
1213
1214 linux:
1215 storage:
1216 enabled: true
1217 mount:
1218 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01001219 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001220 - path: /media/myuser/public/
1221 - device: //192.168.0.1/storage
1222 - file_system: cifs
1223 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
1224
Jiri Broulikb017f932017-03-31 13:55:36 +02001225NFS mount
1226
1227.. code-block:: yaml
1228
1229 linux:
1230 storage:
1231 enabled: true
1232 mount:
1233 nfs_glance:
1234 enabled: true
1235 path: /var/lib/glance/images
1236 device: 172.16.10.110:/var/nfs/glance
1237 file_system: nfs
1238 opts: rw,sync
1239
1240
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001241File swap configuration
Filip Pytlounf5383a42015-10-06 16:28:32 +02001242
1243.. code-block:: yaml
1244
1245 linux:
1246 storage:
1247 enabled: true
1248 swap:
1249 file:
1250 enabled: true
1251 engine: file
1252 device: /swapfile
1253 size: 1024
1254
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001255Partition swap configuration
Lachlan Evenson30676512016-01-22 15:43:28 -08001256
1257.. code-block:: yaml
1258
1259 linux:
1260 storage:
1261 enabled: true
1262 swap:
1263 partition:
1264 enabled: true
1265 engine: partition
1266 device: /dev/vg0/swap
1267
Filip Pytlounc8a001a2015-12-15 14:09:19 +01001268LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
1269
1270.. code-block:: yaml
1271
1272 parameters:
1273 linux:
1274 storage:
1275 mount:
1276 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01001277 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01001278 device: /dev/vg1/data
1279 file_system: ext4
1280 path: /mnt/data
1281 lvm:
1282 vg1:
1283 enabled: true
1284 devices:
1285 - /dev/sdb
1286 volume:
1287 data:
1288 size: 40G
1289 mount: ${linux:storage:mount:data}
1290
Jakub Pavlik4f742142017-08-08 15:05:50 +02001291Create partitions on disk. Specify size in MB. It expects empty
1292disk without any existing partitions.
1293
1294.. code-block:: yaml
1295
1296 linux:
1297 storage:
1298 disk:
1299 first_drive:
1300 name: /dev/loop1
1301 type: gpt
1302 partitions:
1303 - size: 200 #size in MB
1304 type: fat32
1305 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02001306 mkfs: True
1307 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02001308 /dev/vda1:
1309 partitions:
1310 - size: 5
1311 type: ext2
1312 - size: 10
1313 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02001314
1315Multipath with Fujitsu Eternus DXL
1316
1317.. code-block:: yaml
1318
1319 parameters:
1320 linux:
1321 storage:
1322 multipath:
1323 enabled: true
1324 blacklist_devices:
1325 - /dev/sda
1326 - /dev/sdb
1327 backends:
1328 - fujitsu_eternus_dxl
1329
1330Multipath with Hitachi VSP 1000
1331
1332.. code-block:: yaml
1333
1334 parameters:
1335 linux:
1336 storage:
1337 multipath:
1338 enabled: true
1339 blacklist_devices:
1340 - /dev/sda
1341 - /dev/sdb
1342 backends:
1343 - hitachi_vsp1000
1344
1345Multipath with IBM Storwize
1346
1347.. code-block:: yaml
1348
1349 parameters:
1350 linux:
1351 storage:
1352 multipath:
1353 enabled: true
1354 blacklist_devices:
1355 - /dev/sda
1356 - /dev/sdb
1357 backends:
1358 - ibm_storwize
1359
1360Multipath with multiple backends
1361
1362.. code-block:: yaml
1363
1364 parameters:
1365 linux:
1366 storage:
1367 multipath:
1368 enabled: true
1369 blacklist_devices:
1370 - /dev/sda
1371 - /dev/sdb
1372 - /dev/sdc
1373 - /dev/sdd
1374 backends:
1375 - ibm_storwize
1376 - fujitsu_eternus_dxl
1377 - hitachi_vsp1000
1378
1379Disabled multipath (the default setup)
1380
1381.. code-block:: yaml
1382
1383 parameters:
1384 linux:
1385 storage:
1386 multipath:
1387 enabled: false
1388
Simon Pasquier375001e2017-01-26 13:22:33 +01001389Linux with local loopback device
1390
1391.. code-block:: yaml
1392
1393 linux:
1394 storage:
1395 loopback:
1396 disk1:
1397 file: /srv/disk1
1398 size: 50G
1399
Filip Pytlounb2c8f852016-11-21 17:03:43 +01001400External config generation
1401--------------------------
1402
1403You are able to use config support metadata between formulas and only generate
1404config files for external use, eg. docker, etc.
1405
1406.. code-block:: yaml
1407
1408 parameters:
1409 linux:
1410 system:
1411 config:
1412 pillar:
1413 jenkins:
1414 master:
1415 home: /srv/volumes/jenkins
1416 approved_scripts:
1417 - method java.net.URL openConnection
1418 credentials:
1419 - type: username_password
1420 scope: global
1421 id: test
1422 desc: Testing credentials
1423 username: test
1424 password: test
1425
Vladimir Ereminccf28842017-04-10 23:52:10 +03001426Netconsole Remote Kernel Logging
1427--------------------------------
1428
1429Netconsole logger could be configured for configfs-enabled kernels
1430(`CONFIG_NETCONSOLE_DYNAMIC` should be enabled). Configuration applies both in
1431runtime (if network is already configured), and on-boot after interface
1432initialization. Notes:
1433
1434 * receiver could be located only in same L3 domain
1435 (or you need to configure gateway MAC manually)
1436 * receiver's MAC is detected only on configuration time
1437 * using broadcast MAC is not recommended
1438
1439.. code-block:: yaml
1440
1441 parameters:
1442 linux:
1443 system:
1444 netconsole:
1445 enabled: true
1446 port: 514 (optional)
1447 loglevel: debug (optional)
1448 target:
1449 192.168.0.1:
1450 interface: bond0
1451 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02001452
Filip Pytlounf5383a42015-10-06 16:28:32 +02001453Usage
1454=====
1455
1456Set mtu of network interface eth0 to 1400
1457
1458.. code-block:: bash
1459
1460 ip link set dev eth0 mtu 1400
1461
1462Read more
1463=========
1464
1465* https://www.archlinux.org/
1466* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu
Filip Pytloun018f8712017-02-02 13:02:03 +01001467
1468Documentation and Bugs
1469======================
1470
1471To learn how to install and update salt-formulas, consult the documentation
1472available online at:
1473
1474 http://salt-formulas.readthedocs.io/
1475
1476In the unfortunate event that bugs are discovered, they should be reported to
1477the appropriate issue tracker. Use Github issue tracker for specific salt
1478formula:
1479
1480 https://github.com/salt-formulas/salt-formula-linux/issues
1481
1482For feature requests, bug reports or blueprints affecting entire ecosystem,
1483use Launchpad salt-formulas project:
1484
1485 https://launchpad.net/salt-formulas
1486
1487You can also join salt-formulas-users team and subscribe to mailing list:
1488
1489 https://launchpad.net/~salt-formulas-users
1490
1491Developers wishing to work on the salt-formulas projects should always base
1492their work on master branch and submit pull request against specific formula.
1493
1494 https://github.com/salt-formulas/salt-formula-linux
1495
1496Any questions or feedback is always welcome so feel free to join our IRC
1497channel:
1498
1499 #salt-formulas @ irc.freenode.net