blob: 209a79974edda82fc29e9b87ca5c5bd48cf1a045 [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
Petr Michalec1c4c8d82017-02-28 19:09:21 +010034Linux with system users, some with password set
Filip Pytlounf5383a42015-10-06 16:28:32 +020035
36.. code-block:: yaml
37
38 linux:
39 system:
40 ...
41 user:
42 jdoe:
43 name: 'jdoe'
44 enabled: true
45 sudo: true
46 shell: /bin/bash
47 full_name: 'Jonh Doe'
48 home: '/home/jdoe'
49 email: 'jonh@doe.com'
50 jsmith:
51 name: 'jsmith'
52 enabled: true
53 full_name: 'Password'
54 home: '/home/jsmith'
55 password: userpassword
56
Petr Michalec1c4c8d82017-02-28 19:09:21 +010057Configure sudo for users and groups under ``/etc/sudoers.d/``.
58This ways ``linux.system.sudo`` pillar map to actual sudo attributes:
59
60.. code-block:: jinja
Aleš Komárek63572992017-04-11 13:16:44 +020061
Petr Michalec1c4c8d82017-02-28 19:09:21 +010062 # simplified template:
63 Cmds_Alias {{ alias }}={{ commands }}
64 {{ user }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
65 %{{ group }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
66
67 # when rendered:
68 saltuser1 ALL=(ALL) NOPASSWD: ALL
69
Petr Michalec1c4c8d82017-02-28 19:09:21 +010070.. code-block:: yaml
Aleš Komárek63572992017-04-11 13:16:44 +020071
Petr Michalec1c4c8d82017-02-28 19:09:21 +010072 linux:
73 system:
74 sudo:
75 enabled: true
Tomas Kammd8eb3002017-05-08 19:30:29 +020076 aliases:
Petr Michalec1c4c8d82017-02-28 19:09:21 +010077 host:
78 LOCAL:
79 - localhost
80 PRODUCTION:
81 - db1
82 - db2
83 runas:
84 DBA:
85 - postgres
86 - mysql
87 SALT:
88 - root
89 command:
90 # Note: This is not 100% safe when ALL keyword is used, user still may modify configs and hide his actions.
91 # Best practice is to specify full list of commands user is allowed to run.
92 SUPPORT_RESTRICTED:
93 - /bin/vi /etc/sudoers*
94 - /bin/vim /etc/sudoers*
95 - /bin/nano /etc/sudoers*
96 - /bin/emacs /etc/sudoers*
97 - /bin/su - root
98 - /bin/su -
99 - /bin/su
100 - /usr/sbin/visudo
101 SUPPORT_SHELLS:
102 - /bin/sh
103 - /bin/ksh
104 - /bin/bash
105 - /bin/rbash
106 - /bin/dash
107 - /bin/zsh
108 - /bin/csh
109 - /bin/fish
110 - /bin/tcsh
111 - /usr/bin/login
112 - /usr/bin/su
113 - /usr/su
114 ALL_SALT_SAFE:
115 - /usr/bin/salt state*
116 - /usr/bin/salt service*
117 - /usr/bin/salt pillar*
118 - /usr/bin/salt grains*
119 - /usr/bin/salt saltutil*
120 - /usr/bin/salt-call state*
121 - /usr/bin/salt-call service*
122 - /usr/bin/salt-call pillar*
123 - /usr/bin/salt-call grains*
124 - /usr/bin/salt-call saltutil*
125 SALT_TRUSTED:
126 - /usr/bin/salt*
127 users:
128 # saltuser1 with default values: saltuser1 ALL=(ALL) NOPASSWD: ALL
129 saltuser1: {}
130 saltuser2:
131 hosts:
132 - LOCAL
133 # User Alias DBA
134 DBA:
135 hosts:
136 - ALL
137 commands:
138 - ALL_SALT_SAFE
139 groups:
140 db-ops:
141 hosts:
142 - ALL
143 - '!PRODUCTION'
144 runas:
145 - DBA
146 commands:
147 - /bin/cat *
148 - /bin/less *
149 - /bin/ls *
150 salt-ops:
151 hosts:
152 - 'ALL'
153 runas:
154 - SALT
155 commands:
156 - SUPPORT_SHELLS
157 salt-ops-2nd:
158 name: salt-ops
159 nopasswd: false
Jakub Josef7a9d9b92017-05-16 11:39:01 +0200160 setenv: true # Enable sudo -E option
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100161 runas:
162 - DBA
163 commands:
164 - ALL
165 - '!SUPPORT_SHELLS'
166 - '!SUPPORT_RESTRICTED'
167
Filip Pytlounf5383a42015-10-06 16:28:32 +0200168Linux with package, latest version
169
170.. code-block:: yaml
171
172 linux:
173 system:
174 ...
175 package:
176 package-name:
177 version: latest
178
179Linux with package from certail repo, version with no upgrades
180
181.. code-block:: yaml
182
183 linux:
184 system:
185 ...
186 package:
187 package-name:
188 version: 2132.323
189 repo: 'custom-repo'
190 hold: true
191
192Linux with package from certail repo, version with no GPG verification
193
194.. code-block:: yaml
195
196 linux:
197 system:
198 ...
199 package:
200 package-name:
201 version: 2132.323
202 repo: 'custom-repo'
203 verify: false
204
Bruno Binet69a9d8d2017-02-16 22:34:32 +0100205Linux with autoupdates (automatically install security package updates)
206
207.. code-block:: yaml
208
209 linux:
210 system:
211 ...
212 autoupdates:
213 enabled: true
214 mail: root@localhost
215 mail_only_on_error: true
216 remove_unused_dependencies: false
217 automatic_reboot: true
218 automatic_reboot_time: "02:00"
219
Filip Pytlounf5383a42015-10-06 16:28:32 +0200220Linux with cron jobs
221
222.. code-block:: yaml
223
224 linux:
225 system:
226 ...
227 job:
228 cmd1:
229 command: '/cmd/to/run'
230 enabled: true
231 user: 'root'
232 hour: 2
233 minute: 0
234
Filip Pytlound0a29e72015-11-30 15:23:34 +0100235Linux security limits (limit sensu user memory usage to max 1GB):
236
237.. code-block:: yaml
238
239 linux:
240 system:
241 ...
242 limit:
243 sensu:
244 enabled: true
245 domain: sensu
246 limits:
247 - type: hard
248 item: as
249 value: 1000000
250
Filip Pytloun7fee0542015-10-15 11:19:24 +0200251Enable autologin on tty1 (may work only for Ubuntu 14.04):
252
253.. code-block:: yaml
254
255 linux:
256 system:
257 console:
258 tty1:
259 autologin: root
Filip Pytloun281d0202016-01-29 14:03:51 +0100260 # Enable serial console
261 ttyS0:
262 autologin: root
263 rate: 115200
264 term: xterm
Filip Pytloun7fee0542015-10-15 11:19:24 +0200265
266To disable set autologin to `false`.
267
Filip Pytloun7731b852016-02-01 11:13:47 +0100268Set ``policy-rc.d`` on Debian-based systems. Action can be any available
269command in ``while true`` loop and ``case`` context.
270Following will disallow dpkg to stop/start services for cassandra package automatically:
271
272.. code-block:: yaml
273
274 linux:
275 system:
276 policyrcd:
277 - package: cassandra
278 action: exit 101
279 - package: '*'
280 action: switch
281
Filip Pytlounc49445a2016-04-04 14:23:20 +0200282Set system locales:
283
284.. code-block:: yaml
285
286 linux:
287 system:
288 locale:
289 en_US.UTF-8:
290 default: true
Filip Pytlounee1745f2016-04-04 17:39:41 +0200291 "cs_CZ.UTF-8 UTF-8":
Filip Pytlounc49445a2016-04-04 14:23:20 +0200292 enabled: true
293
Andrey Shestakove7cca052017-05-24 23:06:24 +0300294Systemd settings:
295
296.. code-block:: yaml
297
298 linux:
299 system:
300 ...
301 systemd:
302 system:
303 Manager:
304 DefaultLimitNOFILE: 307200
305 DefaultLimitNPROC: 307200
306 user:
307 Manager:
308 DefaultLimitCPU: 2
309 DefaultLimitNPROC: 4
310
Filip Pytloun281034a2016-01-04 18:06:22 +0100311Kernel
312~~~~~~
313
314Install always up to date LTS kernel and headers from Ubuntu trusty:
315
316.. code-block:: yaml
317
318 linux:
319 system:
320 kernel:
321 type: generic
322 lts: trusty
323 headers: true
324
Tomáš Kukrálba35b212017-02-15 17:59:46 +0100325Load kernel modules and add them to `/etc/modules`:
326
327.. code-block:: yaml
328
329 linux:
330 system:
331 kernel:
332 modules:
333 - nf_conntrack
334 - tp_smapi
335 - 8021q
336
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300337Configure or blacklist kernel modules with additional options to `/etc/modprobe.d` following example
338will add `/etc/modprobe.d/nf_conntrack.conf` file with line `options nf_conntrack hashsize=262144`:
339
340.. code-block:: yaml
341
342 linux:
343 system:
344 kernel:
345 module:
346 nf_conntrack:
347 option:
348 hashsize: 262144
349
350
351
Filip Pytloun281034a2016-01-04 18:06:22 +0100352Install specific kernel version and ensure all other kernel packages are
353not present. Also install extra modules and headers for this kernel:
354
355.. code-block:: yaml
356
357 linux:
358 system:
359 kernel:
360 type: generic
361 extra: true
362 headers: true
363 version: 4.2.0-22
364
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100365Systcl kernel parameters
366
367.. code-block:: yaml
368
369 linux:
370 system:
371 kernel:
372 sysctl:
373 net.ipv4.tcp_keepalive_intvl: 3
374 net.ipv4.tcp_keepalive_time: 30
375 net.ipv4.tcp_keepalive_probes: 8
376
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100377
378CPU
379~~~
380
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300381Enable cpufreq governor for every cpu:
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100382
383.. code-block:: yaml
384
385 linux:
386 system:
387 cpu:
388 governor: performance
389
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100390Huge Pages
391~~~~~~~~~~~~
392
393Huge Pages give a performance boost to applications that intensively deal
394with memory allocation/deallocation by decreasing memory fragmentation.
395
396.. code-block:: yaml
397
398 linux:
399 system:
400 kernel:
401 hugepages:
402 small:
403 size: 2M
404 count: 107520
405 mount_point: /mnt/hugepages_2MB
406 mount: false/true # default false
407 large:
408 default: true # default automatically mounted
409 size: 1G
410 count: 210
411 mount_point: /mnt/hugepages_1GB
412
413Note: not recommended to use both pagesizes in concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100414
Jakub Pavlik5398d872017-02-13 22:30:47 +0100415Intel SR-IOV
416~~~~~~~~~~~~
417
418PCI-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.
419
420.. code-block:: yaml
421
422 linux:
423 system:
424 kernel:
425 sriov: True
426 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
427 rc:
428 local: |
429 #!/bin/sh -e
430 # Enable 7 VF on eth1
431 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
432 exit 0
433
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100434Isolate CPU options
435~~~~~~~~~~~~~~~~~~~
436
437Remove the specified CPUs, as defined by the cpu_number values, from the general kernel
438SMP balancing and scheduler algroithms. The only way to move a process onto or off an
439"isolated" CPU is via the CPU affinity syscalls. cpu_number begins at 0, so the
440maximum value is 1 less than the number of CPUs on the system.
441
442.. code-block:: yaml
443
444 linux:
445 system:
446 kernel:
447 isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100448
Filip Pytlounf5383a42015-10-06 16:28:32 +0200449Repositories
450~~~~~~~~~~~~
451
452RedHat based Linux with additional OpenStack repo
453
454.. code-block:: yaml
455
456 linux:
457 system:
458 ...
459 repo:
460 rdo-icehouse:
461 enabled: true
462 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
463 pgpcheck: 0
464
465Ensure system repository to use czech Debian mirror (``default: true``)
466Also pin it's packages with priority 900.
467
468.. code-block:: yaml
469
470 linux:
471 system:
472 repo:
473 debian:
474 default: true
475 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
476 # Import signing key from URL if needed
477 key_url: "http://dummy.com/public.gpg"
478 pin:
479 - pin: 'origin "ftp.cz.debian.org"'
480 priority: 900
481 package: '*'
482
Petr Michalec10462bb2017-03-23 19:18:08 +0100483
484Package manager proxy setup globally:
485
486.. code-block:: yaml
487
488 linux:
489 system:
490 ...
491 repo:
492 apt-mk:
493 source: "deb http://apt-mk.mirantis.com/ stable main salt"
494 ...
495 proxy:
496 pkg:
497 enabled: true
498 ftp: ftp://ftp-proxy-for-apt.host.local:2121
499 ...
500 # NOTE: Global defaults for any other componet that configure proxy on the system.
501 # If your environment has just one simple proxy, set it on linux:system:proxy.
502 #
503 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
504 # as for https and http
505 ftp: ftp://proxy.host.local:2121
506 http: http://proxy.host.local:3142
507 https: https://proxy.host.local:3143
508
509Package manager proxy setup per repository:
510
511.. code-block:: yaml
512
513 linux:
514 system:
515 ...
516 repo:
517 debian:
518 source: "deb http://apt-mk.mirantis.com/ stable main salt"
519 ...
520 apt-mk:
521 source: "deb http://apt-mk.mirantis.com/ stable main salt"
522 # per repository proxy
523 proxy:
524 enabled: true
525 http: http://maas-01:8080
526 https: http://maas-01:8080
527 ...
528 proxy:
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600529 # package manager fallback defaults
Petr Michalec10462bb2017-03-23 19:18:08 +0100530 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
531 pkg:
532 enabled: true
533 ftp: ftp://proxy.host.local:2121
534 #http: http://proxy.host.local:3142
535 #https: https://proxy.host.local:3143
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600536 ...
Petr Michalec10462bb2017-03-23 19:18:08 +0100537 # global system fallback system defaults
538 ftp: ftp://proxy.host.local:2121
539 http: http://proxy.host.local:3142
540 https: https://proxy.host.local:3143
541
542
Jiri Broulik34a29b42017-04-25 14:42:54 +0200543Remove all repositories:
544
545.. code-block:: yaml
546
547 linux:
548 system:
549 purge_repos: true
550
551
Petr Michalec10462bb2017-03-23 19:18:08 +0100552RC
553~~
554
Jakub Pavlik78859382016-01-21 11:26:39 +0100555rc.local example
556
557.. code-block:: yaml
558
559 linux:
560 system:
561 rc:
562 local: |
563 #!/bin/sh -e
564 #
565 # rc.local
566 #
567 # This script is executed at the end of each multiuser runlevel.
568 # Make sure that the script will "exit 0" on success or any other
569 # value on error.
570 #
571 # In order to enable or disable this script just change the execution
572 # bits.
573 #
574 # By default this script does nothing.
575 exit 0
576
Petr Michalec10462bb2017-03-23 19:18:08 +0100577
Filip Pytloun1f40dac2016-01-22 15:52:57 +0100578Prompt
579~~~~~~
580
581Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
582user can have different prompt.
583
584.. code-block:: yaml
585
586 linux:
587 system:
588 prompt:
589 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\\]
590 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
591
592On Debian systems to set prompt system-wide it's necessary to remove setting
593PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
594``/etc/skel/.bashrc``). This formula will do this automatically, but will not
Filip Pytlound9b68da2016-01-22 15:58:41 +0100595touch existing user's ``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +0100596
Filip Pytlouneef11c12016-03-25 11:00:23 +0100597Bash
598~~~~
599
600Fix bash configuration to preserve history across sessions (like ZSH does by
601default).
602
603.. code-block:: yaml
604
605 linux:
606 system:
607 bash:
608 preserve_history: true
609
Filip Pytloune874dfb2016-01-22 16:57:34 +0100610Message of the day
611~~~~~~~~~~~~~~~~~~
612
613``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
614day. Setting custom motd will cleanup existing ones.
615
616.. code-block:: yaml
617
618 linux:
619 system:
620 motd:
621 - release: |
622 #!/bin/sh
623 [ -r /etc/lsb-release ] && . /etc/lsb-release
624
625 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
626 # Fall back to using the very slow lsb_release utility
627 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
628 fi
629
630 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
631 - warning: |
632 #!/bin/sh
633 printf "This is [company name] network.\n"
634 printf "Unauthorized access strictly prohibited.\n"
635
Marek Celoud713e9072017-05-18 15:20:25 +0200636Services
637~~~~~~~~
638
639Stop and disable linux service:
640
641.. code-block:: yaml
642
643 linux:
644 system:
645 service:
646 apt-daily.timer:
647 status: dead
648
649Possible status is dead (disable service by default), running (enable service by default), enabled, disabled.
650
Filip Pytloun2f70b492016-02-19 15:55:25 +0100651RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +0100652^^^^^^^^^^^^^
Filip Pytloun2f70b492016-02-19 15:55:25 +0100653
654Unfortunately ``update-motd`` is currently not available for RHEL so there's
655no native support for dynamic motd.
656You can still set static one, only pillar structure differs:
657
658.. code-block:: yaml
659
660 linux:
661 system:
662 motd: |
663 This is [company name] network.
664 Unauthorized access strictly prohibited.
665
Filip Pytloun8296bb92016-02-19 18:42:09 +0100666Haveged
667~~~~~~~
668
669If you are running headless server and are low on entropy, it may be a good
670idea to setup Haveged.
671
672.. code-block:: yaml
673
674 linux:
675 system:
676 haveged:
677 enabled: true
678
Filip Pytlounf5383a42015-10-06 16:28:32 +0200679Linux network
680-------------
681
682Linux with network manager
683
684.. code-block:: yaml
685
686 linux:
687 network:
688 enabled: true
689 network_manager: true
690
691Linux with default static network interfaces, default gateway interface and DNS servers
692
693.. code-block:: yaml
694
695 linux:
696 network:
697 enabled: true
698 interface:
699 eth0:
700 enabled: true
701 type: eth
702 address: 192.168.0.102
703 netmask: 255.255.255.0
704 gateway: 192.168.0.1
705 name_servers:
706 - 8.8.8.8
707 - 8.8.4.4
708 mtu: 1500
709
jan kaufman6d30adf2016-01-18 17:30:12 +0100710Linux with bonded interfaces and disabled NetworkManager
Filip Pytlounf5383a42015-10-06 16:28:32 +0200711
712.. code-block:: yaml
713
714 linux:
715 network:
716 enabled: true
717 interface:
718 eth0:
719 type: eth
720 ...
721 eth1:
722 type: eth
723 ...
724 bond0:
725 enabled: true
726 type: bond
727 address: 192.168.0.102
728 netmask: 255.255.255.0
729 mtu: 1500
730 use_in:
731 - interface: ${linux:interface:eth0}
732 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +0100733 network_manager:
734 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200735
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100736Linux with vlan interface_params
737
738.. code-block:: yaml
739
740 linux:
741 network:
742 enabled: true
743 interface:
744 vlan69:
745 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +0100746 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100747 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100748
Filip Pytlounf5383a42015-10-06 16:28:32 +0200749Linux with wireless interface parameters
750
751.. code-block:: yaml
752
753 linux:
754 network:
755 enabled: true
756 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100757 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200758 interface:
759 wlan0:
760 type: eth
761 wireless:
762 essid: example
763 key: example_key
764 security: wpa
765 priority: 1
766
767Linux networks with routes defined
768
769.. code-block:: yaml
770
771 linux:
772 network:
773 enabled: true
774 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100775 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200776 interface:
777 eth0:
778 type: eth
779 route:
780 default:
781 address: 192.168.0.123
782 netmask: 255.255.255.0
783 gateway: 192.168.0.1
784
785Native Linux Bridges
786
787.. code-block:: yaml
788
789 linux:
790 network:
791 interface:
792 eth1:
793 enabled: true
794 type: eth
795 proto: manual
796 up_cmds:
797 - ip address add 0/0 dev $IFACE
798 - ip link set $IFACE up
799 down_cmds:
800 - ip link set $IFACE down
801 br-ex:
802 enabled: true
803 type: bridge
804 address: ${linux:network:host:public_local:address}
805 netmask: 255.255.255.0
806 use_interfaces:
807 - eth1
808
809OpenVswitch Bridges
810
811.. code-block:: yaml
812
813 linux:
814 network:
815 bridge: openvswitch
816 interface:
817 eth1:
818 enabled: true
819 type: eth
820 proto: manual
821 up_cmds:
822 - ip address add 0/0 dev $IFACE
823 - ip link set $IFACE up
824 down_cmds:
825 - ip link set $IFACE down
826 br-ex:
827 enabled: true
828 type: bridge
829 address: ${linux:network:host:public_local:address}
830 netmask: 255.255.255.0
831 use_interfaces:
832 - eth1
833
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600834DHCP client configuration
835
836None of the keys is mandatory, include only those you really need. For full list
837of available options under send, supersede, prepend, append refer to dhcp-options(5)
838
839.. code-block:: yaml
840
841 linux:
842 network:
843 dhclient:
844 enabled: true
845 backoff_cutoff: 15
846 initial_interval: 10
847 reboot: 10
848 retry: 60
849 select_timeout: 0
850 timeout: 120
851 send:
852 - option: host-name
853 declaration: "= gethostname()"
854 supersede:
855 - option: host-name
856 declaration: "spaceship"
857 - option: domain-name
858 declaration: "domain.home"
859 #- option: arp-cache-timeout
860 # declaration: 20
861 prepend:
862 - option: domain-name-servers
863 declaration:
864 - 8.8.8.8
865 - 8.8.4.4
866 - option: domain-search
867 declaration:
868 - example.com
869 - eng.example.com
870 #append:
871 #- option: domain-name-servers
872 # declaration: 127.0.0.1
873 # ip or subnet to reject dhcp offer from
874 reject:
875 - 192.33.137.209
876 - 10.0.2.0/24
877 request:
878 - subnet-mask
879 - broadcast-address
880 - time-offset
881 - routers
882 - domain-name
883 - domain-name-servers
884 - domain-search
885 - host-name
886 - dhcp6.name-servers
887 - dhcp6.domain-search
888 - dhcp6.fqdn
889 - dhcp6.sntp-servers
890 - netbios-name-servers
891 - netbios-scope
892 - interface-mtu
893 - rfc3442-classless-static-routes
894 - ntp-servers
895 require:
896 - subnet-mask
897 - domain-name-servers
898 # if per interface configuration required add below
899 interface:
900 ens2:
901 initial_interval: 11
902 reject:
903 - 192.33.137.210
904 ens3:
905 initial_interval: 12
906 reject:
907 - 192.33.137.211
908
Petr Michaleceb14b552017-06-01 10:27:05 +0200909Linux network systemd settings:
910
911.. code-block:: yaml
912
913 linux:
914 network:
915 ...
916 systemd:
917 link:
918 10-iface-dmz:
919 Match:
920 MACAddress: c8:5b:67:fa:1a:af
921 OriginalName: eth0
922 Link:
923 Name: dmz0
924 netdev:
925 20-bridge-dmz:
926 match:
927 name: dmz0
928 network:
929 mescription: bridge
930 bridge: br-dmz0
931 network:
932 # works with lowercase, keys are by default capitalized
933 40-dhcp:
934 match:
935 name: '*'
936 network:
937 DHCP: yes
938
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600939
Petr Michalec10462bb2017-03-23 19:18:08 +0100940Configure global environment variables
941~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
942
943Linux /etc/environment:
944``/etc/environment`` is for static system wide variable assignment after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +0200945
946.. code-block:: yaml
947
948 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +0100949 system:
950 env:
951 BOB_VARIABLE: Alice
952 ...
953 BOB_PATH:
954 - /srv/alice/bin
955 - /srv/bob/bin
956 ...
957 ftp_proxy: none
958 http_proxy: http://global-http-proxy.host.local:8080
959 https_proxy: ${linux:system:proxy:https}
960 no_proxy:
961 - 192.168.0.80
962 - 192.168.1.80
963 - .domain.com
964 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +0200965 ...
Petr Michalec10462bb2017-03-23 19:18:08 +0100966 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +0200967 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +0100968 ftp: ftp://proxy.host.local:2121
969 http: http://proxy.host.local:3142
970 https: https://proxy.host.local:3143
971 noproxy:
972 - .domain.com
973 - .local
974
975Configure profile.d scripts
976~~~~~~~~~~~~~~~~~~~~~~~~~~~
977
978Linux /etc/profile.d:
979The profile.d scripts are being sourced during .sh execution and support variable expansion in opposite to /etc/environment
980global settings in ``/etc/environment``.
981
982.. code-block:: yaml
983
984 linux:
985 system:
986 profile:
987 locales: |
988 export LANG=C
989 export LC_ALL=C
990 ...
991 vi_flavors.sh: |
992 export PAGER=view
993 export EDITOR=vim
994 alias vi=vim
995 shell_locales.sh: |
996 export LANG=en_US
997 export LC_ALL=en_US.UTF-8
998 shell_proxies.sh: |
999 export FTP_PROXY=ftp://127.0.3.3:2121
1000 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001001
1002Linux with hosts
Petr Michalec10462bb2017-03-23 19:18:08 +01001003~~~~~~~~~~~~~~~~
Filip Pytlounf5383a42015-10-06 16:28:32 +02001004
Filip Pytloun86506fe2017-01-26 14:36:16 +01001005Parameter purge_hosts will enforce whole /etc/hosts file, removing entries
1006that are not defined in model except defaults for both IPv4 and IPv6 localhost
1007and hostname + fqdn.
1008It's good to use this option if you want to ensure /etc/hosts is always in a
1009clean state however it's not enabled by default for safety.
1010
Filip Pytlounf5383a42015-10-06 16:28:32 +02001011.. code-block:: yaml
1012
1013 linux:
1014 network:
1015 ...
Filip Pytloun86506fe2017-01-26 14:36:16 +01001016 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001017 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001018 # No need to define this one if purge_hosts is true
1019 hostname:
1020 address: 127.0.1.1
1021 names:
1022 - ${linux:network:fqdn}
1023 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001024 node1:
1025 address: 192.168.10.200
1026 names:
1027 - node2.domain.com
1028 - service2.domain.com
1029 node2:
1030 address: 192.168.10.201
1031 names:
1032 - node2.domain.com
1033 - service2.domain.com
1034
Filip Pytloun86506fe2017-01-26 14:36:16 +01001035
Filip Pytlounde9bea52016-01-11 15:39:10 +01001036Setup resolv.conf, nameservers, domain and search domains
Petr Michalec10462bb2017-03-23 19:18:08 +01001037~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filip Pytlounde9bea52016-01-11 15:39:10 +01001038
1039.. code-block:: yaml
1040
1041 linux:
1042 network:
1043 resolv:
1044 dns:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001045 - 8.8.4.4
1046 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01001047 domain: my.example.com
1048 search:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001049 - my.example.com
1050 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01001051 options:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001052 - ndots: 5
1053 - timeout: 2
1054 - attempts: 2
Filip Pytlounde9bea52016-01-11 15:39:10 +01001055
Andrii Petrenko735761d2017-03-21 17:17:35 -07001056**setting custom TX queue length for tap interfaces**
1057
1058.. code-block:: yaml
1059
1060 linux:
1061 network:
1062 tap_custom_txqueuelen: 10000
1063
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001064DPDK OVS interfaces
1065--------------------
1066
1067**DPDK OVS NIC**
1068
1069.. code-block:: yaml
1070
1071 linux:
1072 network:
1073 bridge: openvswitch
1074 dpdk:
1075 enabled: true
1076 driver: uio/vfio-pci
1077 openvswitch:
1078 pmd_cpu_mask: "0x6"
1079 dpdk_socket_mem: "1024,1024"
1080 dpdk_lcore_mask: "0x400"
1081 memory_channels: 2
1082 interface:
1083 dpkd0:
1084 name: ${_param:dpdk_nic}
1085 pci: 0000:06:00.0
1086 driver: igb_uio/vfio
1087 enabled: true
1088 type: dpdk_ovs_port
1089 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001090 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001091 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01001092 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001093 br-prv:
1094 enabled: true
1095 type: dpdk_ovs_bridge
1096
1097**DPDK OVS Bond**
1098
1099.. code-block:: yaml
1100
1101 linux:
1102 network:
1103 bridge: openvswitch
1104 dpdk:
1105 enabled: true
1106 driver: uio/vfio-pci
1107 openvswitch:
1108 pmd_cpu_mask: "0x6"
1109 dpdk_socket_mem: "1024,1024"
1110 dpdk_lcore_mask: "0x400"
1111 memory_channels: 2
1112 interface:
1113 dpdk_second_nic:
1114 name: ${_param:primary_second_nic}
1115 pci: 0000:06:00.0
1116 driver: igb_uio/vfio
1117 bond: dpdkbond0
1118 enabled: true
1119 type: dpdk_ovs_port
1120 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001121 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001122 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001123 dpdk_first_nic:
1124 name: ${_param:primary_first_nic}
1125 pci: 0000:05:00.0
1126 driver: igb_uio/vfio
1127 bond: dpdkbond0
1128 enabled: true
1129 type: dpdk_ovs_port
1130 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001131 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001132 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001133 dpdkbond0:
1134 enabled: true
1135 bridge: br-prv
1136 type: dpdk_ovs_bond
1137 mode: active-backup
1138 br-prv:
1139 enabled: true
1140 type: dpdk_ovs_bridge
1141
Jakub Pavlikaa759062017-03-13 15:57:26 +01001142**DPDK OVS bridge for VXLAN**
1143
1144If VXLAN is used as tenant segmentation then ip address must be set on br-prv
1145
1146.. code-block:: yaml
1147
1148 linux:
1149 network:
1150 ...
1151 interface:
1152 br-prv:
1153 enabled: true
1154 type: dpdk_ovs_bridge
1155 address: 192.168.50.0
1156 netmask: 255.255.255.0
1157 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001158
1159Linux storage
1160-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02001161
1162Linux with mounted Samba
1163
1164.. code-block:: yaml
1165
1166 linux:
1167 storage:
1168 enabled: true
1169 mount:
1170 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01001171 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001172 - path: /media/myuser/public/
1173 - device: //192.168.0.1/storage
1174 - file_system: cifs
1175 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
1176
Jiri Broulikb017f932017-03-31 13:55:36 +02001177NFS mount
1178
1179.. code-block:: yaml
1180
1181 linux:
1182 storage:
1183 enabled: true
1184 mount:
1185 nfs_glance:
1186 enabled: true
1187 path: /var/lib/glance/images
1188 device: 172.16.10.110:/var/nfs/glance
1189 file_system: nfs
1190 opts: rw,sync
1191
1192
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001193File swap configuration
Filip Pytlounf5383a42015-10-06 16:28:32 +02001194
1195.. code-block:: yaml
1196
1197 linux:
1198 storage:
1199 enabled: true
1200 swap:
1201 file:
1202 enabled: true
1203 engine: file
1204 device: /swapfile
1205 size: 1024
1206
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001207Partition swap configuration
Lachlan Evenson30676512016-01-22 15:43:28 -08001208
1209.. code-block:: yaml
1210
1211 linux:
1212 storage:
1213 enabled: true
1214 swap:
1215 partition:
1216 enabled: true
1217 engine: partition
1218 device: /dev/vg0/swap
1219
Filip Pytlounc8a001a2015-12-15 14:09:19 +01001220LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
1221
1222.. code-block:: yaml
1223
1224 parameters:
1225 linux:
1226 storage:
1227 mount:
1228 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01001229 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01001230 device: /dev/vg1/data
1231 file_system: ext4
1232 path: /mnt/data
1233 lvm:
1234 vg1:
1235 enabled: true
1236 devices:
1237 - /dev/sdb
1238 volume:
1239 data:
1240 size: 40G
1241 mount: ${linux:storage:mount:data}
1242
Ales Komareka634f4b2016-10-02 13:11:04 +02001243
1244Multipath with Fujitsu Eternus DXL
1245
1246.. code-block:: yaml
1247
1248 parameters:
1249 linux:
1250 storage:
1251 multipath:
1252 enabled: true
1253 blacklist_devices:
1254 - /dev/sda
1255 - /dev/sdb
1256 backends:
1257 - fujitsu_eternus_dxl
1258
1259Multipath with Hitachi VSP 1000
1260
1261.. code-block:: yaml
1262
1263 parameters:
1264 linux:
1265 storage:
1266 multipath:
1267 enabled: true
1268 blacklist_devices:
1269 - /dev/sda
1270 - /dev/sdb
1271 backends:
1272 - hitachi_vsp1000
1273
1274Multipath with IBM Storwize
1275
1276.. code-block:: yaml
1277
1278 parameters:
1279 linux:
1280 storage:
1281 multipath:
1282 enabled: true
1283 blacklist_devices:
1284 - /dev/sda
1285 - /dev/sdb
1286 backends:
1287 - ibm_storwize
1288
1289Multipath with multiple backends
1290
1291.. code-block:: yaml
1292
1293 parameters:
1294 linux:
1295 storage:
1296 multipath:
1297 enabled: true
1298 blacklist_devices:
1299 - /dev/sda
1300 - /dev/sdb
1301 - /dev/sdc
1302 - /dev/sdd
1303 backends:
1304 - ibm_storwize
1305 - fujitsu_eternus_dxl
1306 - hitachi_vsp1000
1307
1308Disabled multipath (the default setup)
1309
1310.. code-block:: yaml
1311
1312 parameters:
1313 linux:
1314 storage:
1315 multipath:
1316 enabled: false
1317
Simon Pasquier375001e2017-01-26 13:22:33 +01001318Linux with local loopback device
1319
1320.. code-block:: yaml
1321
1322 linux:
1323 storage:
1324 loopback:
1325 disk1:
1326 file: /srv/disk1
1327 size: 50G
1328
Filip Pytlounb2c8f852016-11-21 17:03:43 +01001329External config generation
1330--------------------------
1331
1332You are able to use config support metadata between formulas and only generate
1333config files for external use, eg. docker, etc.
1334
1335.. code-block:: yaml
1336
1337 parameters:
1338 linux:
1339 system:
1340 config:
1341 pillar:
1342 jenkins:
1343 master:
1344 home: /srv/volumes/jenkins
1345 approved_scripts:
1346 - method java.net.URL openConnection
1347 credentials:
1348 - type: username_password
1349 scope: global
1350 id: test
1351 desc: Testing credentials
1352 username: test
1353 password: test
1354
Vladimir Ereminccf28842017-04-10 23:52:10 +03001355Netconsole Remote Kernel Logging
1356--------------------------------
1357
1358Netconsole logger could be configured for configfs-enabled kernels
1359(`CONFIG_NETCONSOLE_DYNAMIC` should be enabled). Configuration applies both in
1360runtime (if network is already configured), and on-boot after interface
1361initialization. Notes:
1362
1363 * receiver could be located only in same L3 domain
1364 (or you need to configure gateway MAC manually)
1365 * receiver's MAC is detected only on configuration time
1366 * using broadcast MAC is not recommended
1367
1368.. code-block:: yaml
1369
1370 parameters:
1371 linux:
1372 system:
1373 netconsole:
1374 enabled: true
1375 port: 514 (optional)
1376 loglevel: debug (optional)
1377 target:
1378 192.168.0.1:
1379 interface: bond0
1380 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02001381
Filip Pytlounf5383a42015-10-06 16:28:32 +02001382Usage
1383=====
1384
1385Set mtu of network interface eth0 to 1400
1386
1387.. code-block:: bash
1388
1389 ip link set dev eth0 mtu 1400
1390
1391Read more
1392=========
1393
1394* https://www.archlinux.org/
1395* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu
Filip Pytloun018f8712017-02-02 13:02:03 +01001396
1397Documentation and Bugs
1398======================
1399
1400To learn how to install and update salt-formulas, consult the documentation
1401available online at:
1402
1403 http://salt-formulas.readthedocs.io/
1404
1405In the unfortunate event that bugs are discovered, they should be reported to
1406the appropriate issue tracker. Use Github issue tracker for specific salt
1407formula:
1408
1409 https://github.com/salt-formulas/salt-formula-linux/issues
1410
1411For feature requests, bug reports or blueprints affecting entire ecosystem,
1412use Launchpad salt-formulas project:
1413
1414 https://launchpad.net/salt-formulas
1415
1416You can also join salt-formulas-users team and subscribe to mailing list:
1417
1418 https://launchpad.net/~salt-formulas-users
1419
1420Developers wishing to work on the salt-formulas projects should always base
1421their work on master branch and submit pull request against specific formula.
1422
1423 https://github.com/salt-formulas/salt-formula-linux
1424
1425Any questions or feedback is always welcome so feel free to join our IRC
1426channel:
1427
1428 #salt-formulas @ irc.freenode.net