blob: b10d88103dc5124dd8b60c5cf71c7013a9b552db [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
76 alias:
77 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
160 runas:
161 - DBA
162 commands:
163 - ALL
164 - '!SUPPORT_SHELLS'
165 - '!SUPPORT_RESTRICTED'
166
Filip Pytlounf5383a42015-10-06 16:28:32 +0200167Linux with package, latest version
168
169.. code-block:: yaml
170
171 linux:
172 system:
173 ...
174 package:
175 package-name:
176 version: latest
177
178Linux with package from certail repo, version with no upgrades
179
180.. code-block:: yaml
181
182 linux:
183 system:
184 ...
185 package:
186 package-name:
187 version: 2132.323
188 repo: 'custom-repo'
189 hold: true
190
191Linux with package from certail repo, version with no GPG verification
192
193.. code-block:: yaml
194
195 linux:
196 system:
197 ...
198 package:
199 package-name:
200 version: 2132.323
201 repo: 'custom-repo'
202 verify: false
203
Bruno Binet69a9d8d2017-02-16 22:34:32 +0100204Linux with autoupdates (automatically install security package updates)
205
206.. code-block:: yaml
207
208 linux:
209 system:
210 ...
211 autoupdates:
212 enabled: true
213 mail: root@localhost
214 mail_only_on_error: true
215 remove_unused_dependencies: false
216 automatic_reboot: true
217 automatic_reboot_time: "02:00"
218
Filip Pytlounf5383a42015-10-06 16:28:32 +0200219Linux with cron jobs
220
221.. code-block:: yaml
222
223 linux:
224 system:
225 ...
226 job:
227 cmd1:
228 command: '/cmd/to/run'
229 enabled: true
230 user: 'root'
231 hour: 2
232 minute: 0
233
Filip Pytlound0a29e72015-11-30 15:23:34 +0100234Linux security limits (limit sensu user memory usage to max 1GB):
235
236.. code-block:: yaml
237
238 linux:
239 system:
240 ...
241 limit:
242 sensu:
243 enabled: true
244 domain: sensu
245 limits:
246 - type: hard
247 item: as
248 value: 1000000
249
Filip Pytloun7fee0542015-10-15 11:19:24 +0200250Enable autologin on tty1 (may work only for Ubuntu 14.04):
251
252.. code-block:: yaml
253
254 linux:
255 system:
256 console:
257 tty1:
258 autologin: root
Filip Pytloun281d0202016-01-29 14:03:51 +0100259 # Enable serial console
260 ttyS0:
261 autologin: root
262 rate: 115200
263 term: xterm
Filip Pytloun7fee0542015-10-15 11:19:24 +0200264
265To disable set autologin to `false`.
266
Filip Pytloun7731b852016-02-01 11:13:47 +0100267Set ``policy-rc.d`` on Debian-based systems. Action can be any available
268command in ``while true`` loop and ``case`` context.
269Following will disallow dpkg to stop/start services for cassandra package automatically:
270
271.. code-block:: yaml
272
273 linux:
274 system:
275 policyrcd:
276 - package: cassandra
277 action: exit 101
278 - package: '*'
279 action: switch
280
Filip Pytlounc49445a2016-04-04 14:23:20 +0200281Set system locales:
282
283.. code-block:: yaml
284
285 linux:
286 system:
287 locale:
288 en_US.UTF-8:
289 default: true
Filip Pytlounee1745f2016-04-04 17:39:41 +0200290 "cs_CZ.UTF-8 UTF-8":
Filip Pytlounc49445a2016-04-04 14:23:20 +0200291 enabled: true
292
Filip Pytloun281034a2016-01-04 18:06:22 +0100293Kernel
294~~~~~~
295
296Install always up to date LTS kernel and headers from Ubuntu trusty:
297
298.. code-block:: yaml
299
300 linux:
301 system:
302 kernel:
303 type: generic
304 lts: trusty
305 headers: true
306
Tomáš Kukrálba35b212017-02-15 17:59:46 +0100307Load kernel modules and add them to `/etc/modules`:
308
309.. code-block:: yaml
310
311 linux:
312 system:
313 kernel:
314 modules:
315 - nf_conntrack
316 - tp_smapi
317 - 8021q
318
Filip Pytloun281034a2016-01-04 18:06:22 +0100319Install specific kernel version and ensure all other kernel packages are
320not present. Also install extra modules and headers for this kernel:
321
322.. code-block:: yaml
323
324 linux:
325 system:
326 kernel:
327 type: generic
328 extra: true
329 headers: true
330 version: 4.2.0-22
331
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100332Systcl kernel parameters
333
334.. code-block:: yaml
335
336 linux:
337 system:
338 kernel:
339 sysctl:
340 net.ipv4.tcp_keepalive_intvl: 3
341 net.ipv4.tcp_keepalive_time: 30
342 net.ipv4.tcp_keepalive_probes: 8
343
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100344
345CPU
346~~~
347
348Disable ondemand cpu mode service:
349
350.. code-block:: yaml
351
352 linux:
353 system:
354 cpu:
355 governor: performance
356
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100357Huge Pages
358~~~~~~~~~~~~
359
360Huge Pages give a performance boost to applications that intensively deal
361with memory allocation/deallocation by decreasing memory fragmentation.
362
363.. code-block:: yaml
364
365 linux:
366 system:
367 kernel:
368 hugepages:
369 small:
370 size: 2M
371 count: 107520
372 mount_point: /mnt/hugepages_2MB
373 mount: false/true # default false
374 large:
375 default: true # default automatically mounted
376 size: 1G
377 count: 210
378 mount_point: /mnt/hugepages_1GB
379
380Note: not recommended to use both pagesizes in concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100381
Jakub Pavlik5398d872017-02-13 22:30:47 +0100382Intel SR-IOV
383~~~~~~~~~~~~
384
385PCI-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.
386
387.. code-block:: yaml
388
389 linux:
390 system:
391 kernel:
392 sriov: True
393 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
394 rc:
395 local: |
396 #!/bin/sh -e
397 # Enable 7 VF on eth1
398 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
399 exit 0
400
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100401Isolate CPU options
402~~~~~~~~~~~~~~~~~~~
403
404Remove the specified CPUs, as defined by the cpu_number values, from the general kernel
405SMP balancing and scheduler algroithms. The only way to move a process onto or off an
406"isolated" CPU is via the CPU affinity syscalls. cpu_number begins at 0, so the
407maximum value is 1 less than the number of CPUs on the system.
408
409.. code-block:: yaml
410
411 linux:
412 system:
413 kernel:
414 isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100415
Filip Pytlounf5383a42015-10-06 16:28:32 +0200416Repositories
417~~~~~~~~~~~~
418
419RedHat based Linux with additional OpenStack repo
420
421.. code-block:: yaml
422
423 linux:
424 system:
425 ...
426 repo:
427 rdo-icehouse:
428 enabled: true
429 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
430 pgpcheck: 0
431
432Ensure system repository to use czech Debian mirror (``default: true``)
433Also pin it's packages with priority 900.
434
435.. code-block:: yaml
436
437 linux:
438 system:
439 repo:
440 debian:
441 default: true
442 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
443 # Import signing key from URL if needed
444 key_url: "http://dummy.com/public.gpg"
445 pin:
446 - pin: 'origin "ftp.cz.debian.org"'
447 priority: 900
448 package: '*'
449
Petr Michalec10462bb2017-03-23 19:18:08 +0100450
451Package manager proxy setup globally:
452
453.. code-block:: yaml
454
455 linux:
456 system:
457 ...
458 repo:
459 apt-mk:
460 source: "deb http://apt-mk.mirantis.com/ stable main salt"
461 ...
462 proxy:
463 pkg:
464 enabled: true
465 ftp: ftp://ftp-proxy-for-apt.host.local:2121
466 ...
467 # NOTE: Global defaults for any other componet that configure proxy on the system.
468 # If your environment has just one simple proxy, set it on linux:system:proxy.
469 #
470 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
471 # as for https and http
472 ftp: ftp://proxy.host.local:2121
473 http: http://proxy.host.local:3142
474 https: https://proxy.host.local:3143
475
476Package manager proxy setup per repository:
477
478.. code-block:: yaml
479
480 linux:
481 system:
482 ...
483 repo:
484 debian:
485 source: "deb http://apt-mk.mirantis.com/ stable main salt"
486 ...
487 apt-mk:
488 source: "deb http://apt-mk.mirantis.com/ stable main salt"
489 # per repository proxy
490 proxy:
491 enabled: true
492 http: http://maas-01:8080
493 https: http://maas-01:8080
494 ...
495 proxy:
496 # package manager fallback defaults
497 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
498 pkg:
499 enabled: true
500 ftp: ftp://proxy.host.local:2121
501 #http: http://proxy.host.local:3142
502 #https: https://proxy.host.local:3143
503 ...
504 # global system fallback system defaults
505 ftp: ftp://proxy.host.local:2121
506 http: http://proxy.host.local:3142
507 https: https://proxy.host.local:3143
508
509
Jiri Broulik34a29b42017-04-25 14:42:54 +0200510Remove all repositories:
511
512.. code-block:: yaml
513
514 linux:
515 system:
516 purge_repos: true
517
518
Petr Michalec10462bb2017-03-23 19:18:08 +0100519RC
520~~
521
Jakub Pavlik78859382016-01-21 11:26:39 +0100522rc.local example
523
524.. code-block:: yaml
525
526 linux:
527 system:
528 rc:
529 local: |
530 #!/bin/sh -e
531 #
532 # rc.local
533 #
534 # This script is executed at the end of each multiuser runlevel.
535 # Make sure that the script will "exit 0" on success or any other
536 # value on error.
537 #
538 # In order to enable or disable this script just change the execution
539 # bits.
540 #
541 # By default this script does nothing.
542 exit 0
543
Petr Michalec10462bb2017-03-23 19:18:08 +0100544
Filip Pytloun1f40dac2016-01-22 15:52:57 +0100545Prompt
546~~~~~~
547
548Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
549user can have different prompt.
550
551.. code-block:: yaml
552
553 linux:
554 system:
555 prompt:
556 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\\]
557 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
558
559On Debian systems to set prompt system-wide it's necessary to remove setting
560PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
561``/etc/skel/.bashrc``). This formula will do this automatically, but will not
Filip Pytlound9b68da2016-01-22 15:58:41 +0100562touch existing user's ``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +0100563
Filip Pytlouneef11c12016-03-25 11:00:23 +0100564Bash
565~~~~
566
567Fix bash configuration to preserve history across sessions (like ZSH does by
568default).
569
570.. code-block:: yaml
571
572 linux:
573 system:
574 bash:
575 preserve_history: true
576
Filip Pytloune874dfb2016-01-22 16:57:34 +0100577Message of the day
578~~~~~~~~~~~~~~~~~~
579
580``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
581day. Setting custom motd will cleanup existing ones.
582
583.. code-block:: yaml
584
585 linux:
586 system:
587 motd:
588 - release: |
589 #!/bin/sh
590 [ -r /etc/lsb-release ] && . /etc/lsb-release
591
592 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
593 # Fall back to using the very slow lsb_release utility
594 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
595 fi
596
597 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
598 - warning: |
599 #!/bin/sh
600 printf "This is [company name] network.\n"
601 printf "Unauthorized access strictly prohibited.\n"
602
Filip Pytloun2f70b492016-02-19 15:55:25 +0100603RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +0100604^^^^^^^^^^^^^
Filip Pytloun2f70b492016-02-19 15:55:25 +0100605
606Unfortunately ``update-motd`` is currently not available for RHEL so there's
607no native support for dynamic motd.
608You can still set static one, only pillar structure differs:
609
610.. code-block:: yaml
611
612 linux:
613 system:
614 motd: |
615 This is [company name] network.
616 Unauthorized access strictly prohibited.
617
Filip Pytloun8296bb92016-02-19 18:42:09 +0100618Haveged
619~~~~~~~
620
621If you are running headless server and are low on entropy, it may be a good
622idea to setup Haveged.
623
624.. code-block:: yaml
625
626 linux:
627 system:
628 haveged:
629 enabled: true
630
Filip Pytlounf5383a42015-10-06 16:28:32 +0200631Linux network
632-------------
633
634Linux with network manager
635
636.. code-block:: yaml
637
638 linux:
639 network:
640 enabled: true
641 network_manager: true
642
643Linux with default static network interfaces, default gateway interface and DNS servers
644
645.. code-block:: yaml
646
647 linux:
648 network:
649 enabled: true
650 interface:
651 eth0:
652 enabled: true
653 type: eth
654 address: 192.168.0.102
655 netmask: 255.255.255.0
656 gateway: 192.168.0.1
657 name_servers:
658 - 8.8.8.8
659 - 8.8.4.4
660 mtu: 1500
661
jan kaufman6d30adf2016-01-18 17:30:12 +0100662Linux with bonded interfaces and disabled NetworkManager
Filip Pytlounf5383a42015-10-06 16:28:32 +0200663
664.. code-block:: yaml
665
666 linux:
667 network:
668 enabled: true
669 interface:
670 eth0:
671 type: eth
672 ...
673 eth1:
674 type: eth
675 ...
676 bond0:
677 enabled: true
678 type: bond
679 address: 192.168.0.102
680 netmask: 255.255.255.0
681 mtu: 1500
682 use_in:
683 - interface: ${linux:interface:eth0}
684 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +0100685 network_manager:
686 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200687
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100688Linux with vlan interface_params
689
690.. code-block:: yaml
691
692 linux:
693 network:
694 enabled: true
695 interface:
696 vlan69:
697 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +0100698 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100699 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100700
Filip Pytlounf5383a42015-10-06 16:28:32 +0200701Linux with wireless interface parameters
702
703.. code-block:: yaml
704
705 linux:
706 network:
707 enabled: true
708 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100709 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200710 interface:
711 wlan0:
712 type: eth
713 wireless:
714 essid: example
715 key: example_key
716 security: wpa
717 priority: 1
718
719Linux networks with routes defined
720
721.. code-block:: yaml
722
723 linux:
724 network:
725 enabled: true
726 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100727 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200728 interface:
729 eth0:
730 type: eth
731 route:
732 default:
733 address: 192.168.0.123
734 netmask: 255.255.255.0
735 gateway: 192.168.0.1
736
737Native Linux Bridges
738
739.. code-block:: yaml
740
741 linux:
742 network:
743 interface:
744 eth1:
745 enabled: true
746 type: eth
747 proto: manual
748 up_cmds:
749 - ip address add 0/0 dev $IFACE
750 - ip link set $IFACE up
751 down_cmds:
752 - ip link set $IFACE down
753 br-ex:
754 enabled: true
755 type: bridge
756 address: ${linux:network:host:public_local:address}
757 netmask: 255.255.255.0
758 use_interfaces:
759 - eth1
760
761OpenVswitch Bridges
762
763.. code-block:: yaml
764
765 linux:
766 network:
767 bridge: openvswitch
768 interface:
769 eth1:
770 enabled: true
771 type: eth
772 proto: manual
773 up_cmds:
774 - ip address add 0/0 dev $IFACE
775 - ip link set $IFACE up
776 down_cmds:
777 - ip link set $IFACE down
778 br-ex:
779 enabled: true
780 type: bridge
781 address: ${linux:network:host:public_local:address}
782 netmask: 255.255.255.0
783 use_interfaces:
784 - eth1
785
Petr Michalec10462bb2017-03-23 19:18:08 +0100786Configure global environment variables
787~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
788
789Linux /etc/environment:
790``/etc/environment`` is for static system wide variable assignment after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +0200791
792.. code-block:: yaml
793
794 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +0100795 system:
796 env:
797 BOB_VARIABLE: Alice
798 ...
799 BOB_PATH:
800 - /srv/alice/bin
801 - /srv/bob/bin
802 ...
803 ftp_proxy: none
804 http_proxy: http://global-http-proxy.host.local:8080
805 https_proxy: ${linux:system:proxy:https}
806 no_proxy:
807 - 192.168.0.80
808 - 192.168.1.80
809 - .domain.com
810 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +0200811 ...
Petr Michalec10462bb2017-03-23 19:18:08 +0100812 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +0200813 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +0100814 ftp: ftp://proxy.host.local:2121
815 http: http://proxy.host.local:3142
816 https: https://proxy.host.local:3143
817 noproxy:
818 - .domain.com
819 - .local
820
821Configure profile.d scripts
822~~~~~~~~~~~~~~~~~~~~~~~~~~~
823
824Linux /etc/profile.d:
825The profile.d scripts are being sourced during .sh execution and support variable expansion in opposite to /etc/environment
826global settings in ``/etc/environment``.
827
828.. code-block:: yaml
829
830 linux:
831 system:
832 profile:
833 locales: |
834 export LANG=C
835 export LC_ALL=C
836 ...
837 vi_flavors.sh: |
838 export PAGER=view
839 export EDITOR=vim
840 alias vi=vim
841 shell_locales.sh: |
842 export LANG=en_US
843 export LC_ALL=en_US.UTF-8
844 shell_proxies.sh: |
845 export FTP_PROXY=ftp://127.0.3.3:2121
846 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +0200847
848Linux with hosts
Petr Michalec10462bb2017-03-23 19:18:08 +0100849~~~~~~~~~~~~~~~~
Filip Pytlounf5383a42015-10-06 16:28:32 +0200850
Filip Pytloun86506fe2017-01-26 14:36:16 +0100851Parameter purge_hosts will enforce whole /etc/hosts file, removing entries
852that are not defined in model except defaults for both IPv4 and IPv6 localhost
853and hostname + fqdn.
854It's good to use this option if you want to ensure /etc/hosts is always in a
855clean state however it's not enabled by default for safety.
856
Filip Pytlounf5383a42015-10-06 16:28:32 +0200857.. code-block:: yaml
858
859 linux:
860 network:
861 ...
Filip Pytloun86506fe2017-01-26 14:36:16 +0100862 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200863 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +0100864 # No need to define this one if purge_hosts is true
865 hostname:
866 address: 127.0.1.1
867 names:
868 - ${linux:network:fqdn}
869 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +0200870 node1:
871 address: 192.168.10.200
872 names:
873 - node2.domain.com
874 - service2.domain.com
875 node2:
876 address: 192.168.10.201
877 names:
878 - node2.domain.com
879 - service2.domain.com
880
Filip Pytloun86506fe2017-01-26 14:36:16 +0100881
Filip Pytlounde9bea52016-01-11 15:39:10 +0100882Setup resolv.conf, nameservers, domain and search domains
Petr Michalec10462bb2017-03-23 19:18:08 +0100883~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filip Pytlounde9bea52016-01-11 15:39:10 +0100884
885.. code-block:: yaml
886
887 linux:
888 network:
889 resolv:
890 dns:
Jakub Pavlik21ca2152017-02-27 22:21:09 +0100891 - 8.8.4.4
892 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +0100893 domain: my.example.com
894 search:
Jakub Pavlik21ca2152017-02-27 22:21:09 +0100895 - my.example.com
896 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +0100897 options:
Jakub Pavlik21ca2152017-02-27 22:21:09 +0100898 - ndots: 5
899 - timeout: 2
900 - attempts: 2
Filip Pytlounde9bea52016-01-11 15:39:10 +0100901
Andrii Petrenko735761d2017-03-21 17:17:35 -0700902**setting custom TX queue length for tap interfaces**
903
904.. code-block:: yaml
905
906 linux:
907 network:
908 tap_custom_txqueuelen: 10000
909
Jakub Pavlik21ca2152017-02-27 22:21:09 +0100910DPDK OVS interfaces
911--------------------
912
913**DPDK OVS NIC**
914
915.. code-block:: yaml
916
917 linux:
918 network:
919 bridge: openvswitch
920 dpdk:
921 enabled: true
922 driver: uio/vfio-pci
923 openvswitch:
924 pmd_cpu_mask: "0x6"
925 dpdk_socket_mem: "1024,1024"
926 dpdk_lcore_mask: "0x400"
927 memory_channels: 2
928 interface:
929 dpkd0:
930 name: ${_param:dpdk_nic}
931 pci: 0000:06:00.0
932 driver: igb_uio/vfio
933 enabled: true
934 type: dpdk_ovs_port
935 n_rxq: 2
936 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +0100937 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +0100938 br-prv:
939 enabled: true
940 type: dpdk_ovs_bridge
941
942**DPDK OVS Bond**
943
944.. code-block:: yaml
945
946 linux:
947 network:
948 bridge: openvswitch
949 dpdk:
950 enabled: true
951 driver: uio/vfio-pci
952 openvswitch:
953 pmd_cpu_mask: "0x6"
954 dpdk_socket_mem: "1024,1024"
955 dpdk_lcore_mask: "0x400"
956 memory_channels: 2
957 interface:
958 dpdk_second_nic:
959 name: ${_param:primary_second_nic}
960 pci: 0000:06:00.0
961 driver: igb_uio/vfio
962 bond: dpdkbond0
963 enabled: true
964 type: dpdk_ovs_port
965 n_rxq: 2
Jakub Pavlikaa759062017-03-13 15:57:26 +0100966 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +0100967 dpdk_first_nic:
968 name: ${_param:primary_first_nic}
969 pci: 0000:05:00.0
970 driver: igb_uio/vfio
971 bond: dpdkbond0
972 enabled: true
973 type: dpdk_ovs_port
974 n_rxq: 2
Jakub Pavlikaa759062017-03-13 15:57:26 +0100975 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +0100976 dpdkbond0:
977 enabled: true
978 bridge: br-prv
979 type: dpdk_ovs_bond
980 mode: active-backup
981 br-prv:
982 enabled: true
983 type: dpdk_ovs_bridge
984
Jakub Pavlikaa759062017-03-13 15:57:26 +0100985**DPDK OVS bridge for VXLAN**
986
987If VXLAN is used as tenant segmentation then ip address must be set on br-prv
988
989.. code-block:: yaml
990
991 linux:
992 network:
993 ...
994 interface:
995 br-prv:
996 enabled: true
997 type: dpdk_ovs_bridge
998 address: 192.168.50.0
999 netmask: 255.255.255.0
1000 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001001
1002Linux storage
1003-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02001004
1005Linux with mounted Samba
1006
1007.. code-block:: yaml
1008
1009 linux:
1010 storage:
1011 enabled: true
1012 mount:
1013 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01001014 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001015 - path: /media/myuser/public/
1016 - device: //192.168.0.1/storage
1017 - file_system: cifs
1018 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
1019
Jiri Broulikb017f932017-03-31 13:55:36 +02001020NFS mount
1021
1022.. code-block:: yaml
1023
1024 linux:
1025 storage:
1026 enabled: true
1027 mount:
1028 nfs_glance:
1029 enabled: true
1030 path: /var/lib/glance/images
1031 device: 172.16.10.110:/var/nfs/glance
1032 file_system: nfs
1033 opts: rw,sync
1034
1035
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001036File swap configuration
Filip Pytlounf5383a42015-10-06 16:28:32 +02001037
1038.. code-block:: yaml
1039
1040 linux:
1041 storage:
1042 enabled: true
1043 swap:
1044 file:
1045 enabled: true
1046 engine: file
1047 device: /swapfile
1048 size: 1024
1049
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001050Partition swap configuration
Lachlan Evenson30676512016-01-22 15:43:28 -08001051
1052.. code-block:: yaml
1053
1054 linux:
1055 storage:
1056 enabled: true
1057 swap:
1058 partition:
1059 enabled: true
1060 engine: partition
1061 device: /dev/vg0/swap
1062
Filip Pytlounc8a001a2015-12-15 14:09:19 +01001063LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
1064
1065.. code-block:: yaml
1066
1067 parameters:
1068 linux:
1069 storage:
1070 mount:
1071 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01001072 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01001073 device: /dev/vg1/data
1074 file_system: ext4
1075 path: /mnt/data
1076 lvm:
1077 vg1:
1078 enabled: true
1079 devices:
1080 - /dev/sdb
1081 volume:
1082 data:
1083 size: 40G
1084 mount: ${linux:storage:mount:data}
1085
Ales Komareka634f4b2016-10-02 13:11:04 +02001086
1087Multipath with Fujitsu Eternus DXL
1088
1089.. code-block:: yaml
1090
1091 parameters:
1092 linux:
1093 storage:
1094 multipath:
1095 enabled: true
1096 blacklist_devices:
1097 - /dev/sda
1098 - /dev/sdb
1099 backends:
1100 - fujitsu_eternus_dxl
1101
1102Multipath with Hitachi VSP 1000
1103
1104.. code-block:: yaml
1105
1106 parameters:
1107 linux:
1108 storage:
1109 multipath:
1110 enabled: true
1111 blacklist_devices:
1112 - /dev/sda
1113 - /dev/sdb
1114 backends:
1115 - hitachi_vsp1000
1116
1117Multipath with IBM Storwize
1118
1119.. code-block:: yaml
1120
1121 parameters:
1122 linux:
1123 storage:
1124 multipath:
1125 enabled: true
1126 blacklist_devices:
1127 - /dev/sda
1128 - /dev/sdb
1129 backends:
1130 - ibm_storwize
1131
1132Multipath with multiple backends
1133
1134.. code-block:: yaml
1135
1136 parameters:
1137 linux:
1138 storage:
1139 multipath:
1140 enabled: true
1141 blacklist_devices:
1142 - /dev/sda
1143 - /dev/sdb
1144 - /dev/sdc
1145 - /dev/sdd
1146 backends:
1147 - ibm_storwize
1148 - fujitsu_eternus_dxl
1149 - hitachi_vsp1000
1150
1151Disabled multipath (the default setup)
1152
1153.. code-block:: yaml
1154
1155 parameters:
1156 linux:
1157 storage:
1158 multipath:
1159 enabled: false
1160
Simon Pasquier375001e2017-01-26 13:22:33 +01001161Linux with local loopback device
1162
1163.. code-block:: yaml
1164
1165 linux:
1166 storage:
1167 loopback:
1168 disk1:
1169 file: /srv/disk1
1170 size: 50G
1171
Filip Pytlounb2c8f852016-11-21 17:03:43 +01001172External config generation
1173--------------------------
1174
1175You are able to use config support metadata between formulas and only generate
1176config files for external use, eg. docker, etc.
1177
1178.. code-block:: yaml
1179
1180 parameters:
1181 linux:
1182 system:
1183 config:
1184 pillar:
1185 jenkins:
1186 master:
1187 home: /srv/volumes/jenkins
1188 approved_scripts:
1189 - method java.net.URL openConnection
1190 credentials:
1191 - type: username_password
1192 scope: global
1193 id: test
1194 desc: Testing credentials
1195 username: test
1196 password: test
1197
Vladimir Ereminccf28842017-04-10 23:52:10 +03001198Netconsole Remote Kernel Logging
1199--------------------------------
1200
1201Netconsole logger could be configured for configfs-enabled kernels
1202(`CONFIG_NETCONSOLE_DYNAMIC` should be enabled). Configuration applies both in
1203runtime (if network is already configured), and on-boot after interface
1204initialization. Notes:
1205
1206 * receiver could be located only in same L3 domain
1207 (or you need to configure gateway MAC manually)
1208 * receiver's MAC is detected only on configuration time
1209 * using broadcast MAC is not recommended
1210
1211.. code-block:: yaml
1212
1213 parameters:
1214 linux:
1215 system:
1216 netconsole:
1217 enabled: true
1218 port: 514 (optional)
1219 loglevel: debug (optional)
1220 target:
1221 192.168.0.1:
1222 interface: bond0
1223 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02001224
Filip Pytlounf5383a42015-10-06 16:28:32 +02001225Usage
1226=====
1227
1228Set mtu of network interface eth0 to 1400
1229
1230.. code-block:: bash
1231
1232 ip link set dev eth0 mtu 1400
1233
1234Read more
1235=========
1236
1237* https://www.archlinux.org/
1238* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu
Filip Pytloun018f8712017-02-02 13:02:03 +01001239
1240Documentation and Bugs
1241======================
1242
1243To learn how to install and update salt-formulas, consult the documentation
1244available online at:
1245
1246 http://salt-formulas.readthedocs.io/
1247
1248In the unfortunate event that bugs are discovered, they should be reported to
1249the appropriate issue tracker. Use Github issue tracker for specific salt
1250formula:
1251
1252 https://github.com/salt-formulas/salt-formula-linux/issues
1253
1254For feature requests, bug reports or blueprints affecting entire ecosystem,
1255use Launchpad salt-formulas project:
1256
1257 https://launchpad.net/salt-formulas
1258
1259You can also join salt-formulas-users team and subscribe to mailing list:
1260
1261 https://launchpad.net/~salt-formulas-users
1262
1263Developers wishing to work on the salt-formulas projects should always base
1264their work on master branch and submit pull request against specific formula.
1265
1266 https://github.com/salt-formulas/salt-formula-linux
1267
1268Any questions or feedback is always welcome so feel free to join our IRC
1269channel:
1270
1271 #salt-formulas @ irc.freenode.net