blob: cf61802ca77b682c66c16e3ed910cbe83457b20b [file] [log] [blame]
Filip Pytlounf5383a42015-10-06 16:28:32 +02001
2=====
3Linux
4=====
5
6Linux Operating Systems.
7
8* Ubuntu
9* CentOS
10* RedHat
11* Fedora
12* Arch
13
14Sample pillars
15==============
16
17Linux system
18------------
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
34Linux with system users, sowe with password set
35
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
57Linux with package, latest version
58
59.. code-block:: yaml
60
61 linux:
62 system:
63 ...
64 package:
65 package-name:
66 version: latest
67
68Linux with package from certail repo, version with no upgrades
69
70.. code-block:: yaml
71
72 linux:
73 system:
74 ...
75 package:
76 package-name:
77 version: 2132.323
78 repo: 'custom-repo'
79 hold: true
80
81Linux with package from certail repo, version with no GPG verification
82
83.. code-block:: yaml
84
85 linux:
86 system:
87 ...
88 package:
89 package-name:
90 version: 2132.323
91 repo: 'custom-repo'
92 verify: false
93
Bruno Binet69a9d8d2017-02-16 22:34:32 +010094Linux with autoupdates (automatically install security package updates)
95
96.. code-block:: yaml
97
98 linux:
99 system:
100 ...
101 autoupdates:
102 enabled: true
103 mail: root@localhost
104 mail_only_on_error: true
105 remove_unused_dependencies: false
106 automatic_reboot: true
107 automatic_reboot_time: "02:00"
108
Filip Pytlounf5383a42015-10-06 16:28:32 +0200109Linux with cron jobs
110
111.. code-block:: yaml
112
113 linux:
114 system:
115 ...
116 job:
117 cmd1:
118 command: '/cmd/to/run'
119 enabled: true
120 user: 'root'
121 hour: 2
122 minute: 0
123
Filip Pytlound0a29e72015-11-30 15:23:34 +0100124Linux security limits (limit sensu user memory usage to max 1GB):
125
126.. code-block:: yaml
127
128 linux:
129 system:
130 ...
131 limit:
132 sensu:
133 enabled: true
134 domain: sensu
135 limits:
136 - type: hard
137 item: as
138 value: 1000000
139
Filip Pytloun7fee0542015-10-15 11:19:24 +0200140Enable autologin on tty1 (may work only for Ubuntu 14.04):
141
142.. code-block:: yaml
143
144 linux:
145 system:
146 console:
147 tty1:
148 autologin: root
Filip Pytloun281d0202016-01-29 14:03:51 +0100149 # Enable serial console
150 ttyS0:
151 autologin: root
152 rate: 115200
153 term: xterm
Filip Pytloun7fee0542015-10-15 11:19:24 +0200154
155To disable set autologin to `false`.
156
Filip Pytloun7731b852016-02-01 11:13:47 +0100157Set ``policy-rc.d`` on Debian-based systems. Action can be any available
158command in ``while true`` loop and ``case`` context.
159Following will disallow dpkg to stop/start services for cassandra package automatically:
160
161.. code-block:: yaml
162
163 linux:
164 system:
165 policyrcd:
166 - package: cassandra
167 action: exit 101
168 - package: '*'
169 action: switch
170
Filip Pytlounc49445a2016-04-04 14:23:20 +0200171Set system locales:
172
173.. code-block:: yaml
174
175 linux:
176 system:
177 locale:
178 en_US.UTF-8:
179 default: true
Filip Pytlounee1745f2016-04-04 17:39:41 +0200180 "cs_CZ.UTF-8 UTF-8":
Filip Pytlounc49445a2016-04-04 14:23:20 +0200181 enabled: true
182
Filip Pytloun281034a2016-01-04 18:06:22 +0100183Kernel
184~~~~~~
185
186Install always up to date LTS kernel and headers from Ubuntu trusty:
187
188.. code-block:: yaml
189
190 linux:
191 system:
192 kernel:
193 type: generic
194 lts: trusty
195 headers: true
196
Tomáš Kukrálba35b212017-02-15 17:59:46 +0100197Load kernel modules and add them to `/etc/modules`:
198
199.. code-block:: yaml
200
201 linux:
202 system:
203 kernel:
204 modules:
205 - nf_conntrack
206 - tp_smapi
207 - 8021q
208
Filip Pytloun281034a2016-01-04 18:06:22 +0100209Install specific kernel version and ensure all other kernel packages are
210not present. Also install extra modules and headers for this kernel:
211
212.. code-block:: yaml
213
214 linux:
215 system:
216 kernel:
217 type: generic
218 extra: true
219 headers: true
220 version: 4.2.0-22
221
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100222Systcl kernel parameters
223
224.. code-block:: yaml
225
226 linux:
227 system:
228 kernel:
229 sysctl:
230 net.ipv4.tcp_keepalive_intvl: 3
231 net.ipv4.tcp_keepalive_time: 30
232 net.ipv4.tcp_keepalive_probes: 8
233
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100234
235CPU
236~~~
237
238Disable ondemand cpu mode service:
239
240.. code-block:: yaml
241
242 linux:
243 system:
244 cpu:
245 governor: performance
246
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100247Huge Pages
248~~~~~~~~~~~~
249
250Huge Pages give a performance boost to applications that intensively deal
251with memory allocation/deallocation by decreasing memory fragmentation.
252
253.. code-block:: yaml
254
255 linux:
256 system:
257 kernel:
258 hugepages:
259 small:
260 size: 2M
261 count: 107520
262 mount_point: /mnt/hugepages_2MB
263 mount: false/true # default false
264 large:
265 default: true # default automatically mounted
266 size: 1G
267 count: 210
268 mount_point: /mnt/hugepages_1GB
269
270Note: not recommended to use both pagesizes in concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100271
Jakub Pavlik5398d872017-02-13 22:30:47 +0100272Intel SR-IOV
273~~~~~~~~~~~~
274
275PCI-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.
276
277.. code-block:: yaml
278
279 linux:
280 system:
281 kernel:
282 sriov: True
283 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
284 rc:
285 local: |
286 #!/bin/sh -e
287 # Enable 7 VF on eth1
288 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
289 exit 0
290
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100291
Filip Pytlounf5383a42015-10-06 16:28:32 +0200292Repositories
293~~~~~~~~~~~~
294
295RedHat based Linux with additional OpenStack repo
296
297.. code-block:: yaml
298
299 linux:
300 system:
301 ...
302 repo:
303 rdo-icehouse:
304 enabled: true
305 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
306 pgpcheck: 0
307
308Ensure system repository to use czech Debian mirror (``default: true``)
309Also pin it's packages with priority 900.
310
311.. code-block:: yaml
312
313 linux:
314 system:
315 repo:
316 debian:
317 default: true
318 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
319 # Import signing key from URL if needed
320 key_url: "http://dummy.com/public.gpg"
321 pin:
322 - pin: 'origin "ftp.cz.debian.org"'
323 priority: 900
324 package: '*'
325
Jakub Pavlik78859382016-01-21 11:26:39 +0100326rc.local example
327
328.. code-block:: yaml
329
330 linux:
331 system:
332 rc:
333 local: |
334 #!/bin/sh -e
335 #
336 # rc.local
337 #
338 # This script is executed at the end of each multiuser runlevel.
339 # Make sure that the script will "exit 0" on success or any other
340 # value on error.
341 #
342 # In order to enable or disable this script just change the execution
343 # bits.
344 #
345 # By default this script does nothing.
346 exit 0
347
Filip Pytloun1f40dac2016-01-22 15:52:57 +0100348Prompt
349~~~~~~
350
351Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
352user can have different prompt.
353
354.. code-block:: yaml
355
356 linux:
357 system:
358 prompt:
359 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\\]
360 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
361
362On Debian systems to set prompt system-wide it's necessary to remove setting
363PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
364``/etc/skel/.bashrc``). This formula will do this automatically, but will not
Filip Pytlound9b68da2016-01-22 15:58:41 +0100365touch existing user's ``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +0100366
Filip Pytlouneef11c12016-03-25 11:00:23 +0100367Bash
368~~~~
369
370Fix bash configuration to preserve history across sessions (like ZSH does by
371default).
372
373.. code-block:: yaml
374
375 linux:
376 system:
377 bash:
378 preserve_history: true
379
Filip Pytloune874dfb2016-01-22 16:57:34 +0100380Message of the day
381~~~~~~~~~~~~~~~~~~
382
383``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
384day. Setting custom motd will cleanup existing ones.
385
386.. code-block:: yaml
387
388 linux:
389 system:
390 motd:
391 - release: |
392 #!/bin/sh
393 [ -r /etc/lsb-release ] && . /etc/lsb-release
394
395 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
396 # Fall back to using the very slow lsb_release utility
397 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
398 fi
399
400 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
401 - warning: |
402 #!/bin/sh
403 printf "This is [company name] network.\n"
404 printf "Unauthorized access strictly prohibited.\n"
405
Filip Pytloun2f70b492016-02-19 15:55:25 +0100406RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +0100407^^^^^^^^^^^^^
Filip Pytloun2f70b492016-02-19 15:55:25 +0100408
409Unfortunately ``update-motd`` is currently not available for RHEL so there's
410no native support for dynamic motd.
411You can still set static one, only pillar structure differs:
412
413.. code-block:: yaml
414
415 linux:
416 system:
417 motd: |
418 This is [company name] network.
419 Unauthorized access strictly prohibited.
420
Filip Pytloun8296bb92016-02-19 18:42:09 +0100421Haveged
422~~~~~~~
423
424If you are running headless server and are low on entropy, it may be a good
425idea to setup Haveged.
426
427.. code-block:: yaml
428
429 linux:
430 system:
431 haveged:
432 enabled: true
433
Filip Pytlounf5383a42015-10-06 16:28:32 +0200434Linux network
435-------------
436
437Linux with network manager
438
439.. code-block:: yaml
440
441 linux:
442 network:
443 enabled: true
444 network_manager: true
445
446Linux with default static network interfaces, default gateway interface and DNS servers
447
448.. code-block:: yaml
449
450 linux:
451 network:
452 enabled: true
453 interface:
454 eth0:
455 enabled: true
456 type: eth
457 address: 192.168.0.102
458 netmask: 255.255.255.0
459 gateway: 192.168.0.1
460 name_servers:
461 - 8.8.8.8
462 - 8.8.4.4
463 mtu: 1500
464
jan kaufman6d30adf2016-01-18 17:30:12 +0100465Linux with bonded interfaces and disabled NetworkManager
Filip Pytlounf5383a42015-10-06 16:28:32 +0200466
467.. code-block:: yaml
468
469 linux:
470 network:
471 enabled: true
472 interface:
473 eth0:
474 type: eth
475 ...
476 eth1:
477 type: eth
478 ...
479 bond0:
480 enabled: true
481 type: bond
482 address: 192.168.0.102
483 netmask: 255.255.255.0
484 mtu: 1500
485 use_in:
486 - interface: ${linux:interface:eth0}
487 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +0100488 network_manager:
489 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200490
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100491Linux with vlan interface_params
492
493.. code-block:: yaml
494
495 linux:
496 network:
497 enabled: true
498 interface:
499 vlan69:
500 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +0100501 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100502 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100503
Filip Pytlounf5383a42015-10-06 16:28:32 +0200504Linux with wireless interface parameters
505
506.. code-block:: yaml
507
508 linux:
509 network:
510 enabled: true
511 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100512 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200513 interface:
514 wlan0:
515 type: eth
516 wireless:
517 essid: example
518 key: example_key
519 security: wpa
520 priority: 1
521
522Linux networks with routes defined
523
524.. code-block:: yaml
525
526 linux:
527 network:
528 enabled: true
529 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100530 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200531 interface:
532 eth0:
533 type: eth
534 route:
535 default:
536 address: 192.168.0.123
537 netmask: 255.255.255.0
538 gateway: 192.168.0.1
539
540Native Linux Bridges
541
542.. code-block:: yaml
543
544 linux:
545 network:
546 interface:
547 eth1:
548 enabled: true
549 type: eth
550 proto: manual
551 up_cmds:
552 - ip address add 0/0 dev $IFACE
553 - ip link set $IFACE up
554 down_cmds:
555 - ip link set $IFACE down
556 br-ex:
557 enabled: true
558 type: bridge
559 address: ${linux:network:host:public_local:address}
560 netmask: 255.255.255.0
561 use_interfaces:
562 - eth1
563
564OpenVswitch Bridges
565
566.. code-block:: yaml
567
568 linux:
569 network:
570 bridge: openvswitch
571 interface:
572 eth1:
573 enabled: true
574 type: eth
575 proto: manual
576 up_cmds:
577 - ip address add 0/0 dev $IFACE
578 - ip link set $IFACE up
579 down_cmds:
580 - ip link set $IFACE down
581 br-ex:
582 enabled: true
583 type: bridge
584 address: ${linux:network:host:public_local:address}
585 netmask: 255.255.255.0
586 use_interfaces:
587 - eth1
588
589Linux with proxy
590
591.. code-block:: yaml
592
593 linux:
594 network:
595 ...
596 proxy:
597 host: proxy.domain.com
598 port: 3128
599
600Linux with hosts
601
Filip Pytloun86506fe2017-01-26 14:36:16 +0100602Parameter purge_hosts will enforce whole /etc/hosts file, removing entries
603that are not defined in model except defaults for both IPv4 and IPv6 localhost
604and hostname + fqdn.
605It's good to use this option if you want to ensure /etc/hosts is always in a
606clean state however it's not enabled by default for safety.
607
Filip Pytlounf5383a42015-10-06 16:28:32 +0200608.. code-block:: yaml
609
610 linux:
611 network:
612 ...
Filip Pytloun86506fe2017-01-26 14:36:16 +0100613 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200614 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +0100615 # No need to define this one if purge_hosts is true
616 hostname:
617 address: 127.0.1.1
618 names:
619 - ${linux:network:fqdn}
620 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +0200621 node1:
622 address: 192.168.10.200
623 names:
624 - node2.domain.com
625 - service2.domain.com
626 node2:
627 address: 192.168.10.201
628 names:
629 - node2.domain.com
630 - service2.domain.com
631
Filip Pytloun86506fe2017-01-26 14:36:16 +0100632
Filip Pytlounde9bea52016-01-11 15:39:10 +0100633Setup resolv.conf, nameservers, domain and search domains
634
635.. code-block:: yaml
636
637 linux:
638 network:
639 resolv:
640 dns:
641 - 8.8.4.4
642 - 8.8.8.8
643 domain: my.example.com
644 search:
645 - my.example.com
646 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +0100647 options:
648 - ndots:5
649 - timeout:2
650 - attempts:2
Filip Pytlounde9bea52016-01-11 15:39:10 +0100651
Filip Pytlounf5383a42015-10-06 16:28:32 +0200652Linux storage pillars
653---------------------
654
655Linux with mounted Samba
656
657.. code-block:: yaml
658
659 linux:
660 storage:
661 enabled: true
662 mount:
663 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +0100664 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200665 - path: /media/myuser/public/
666 - device: //192.168.0.1/storage
667 - file_system: cifs
668 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
669
670Linux with file swap
671
672.. code-block:: yaml
673
674 linux:
675 storage:
676 enabled: true
677 swap:
678 file:
679 enabled: true
680 engine: file
681 device: /swapfile
682 size: 1024
683
Lachlan Evenson30676512016-01-22 15:43:28 -0800684Linux with partition swap
685
686.. code-block:: yaml
687
688 linux:
689 storage:
690 enabled: true
691 swap:
692 partition:
693 enabled: true
694 engine: partition
695 device: /dev/vg0/swap
696
Filip Pytlounc8a001a2015-12-15 14:09:19 +0100697LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
698
699.. code-block:: yaml
700
701 parameters:
702 linux:
703 storage:
704 mount:
705 data:
Simon Pasquier376262a2016-11-16 15:21:51 +0100706 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +0100707 device: /dev/vg1/data
708 file_system: ext4
709 path: /mnt/data
710 lvm:
711 vg1:
712 enabled: true
713 devices:
714 - /dev/sdb
715 volume:
716 data:
717 size: 40G
718 mount: ${linux:storage:mount:data}
719
Ales Komareka634f4b2016-10-02 13:11:04 +0200720
721Multipath with Fujitsu Eternus DXL
722
723.. code-block:: yaml
724
725 parameters:
726 linux:
727 storage:
728 multipath:
729 enabled: true
730 blacklist_devices:
731 - /dev/sda
732 - /dev/sdb
733 backends:
734 - fujitsu_eternus_dxl
735
736Multipath with Hitachi VSP 1000
737
738.. code-block:: yaml
739
740 parameters:
741 linux:
742 storage:
743 multipath:
744 enabled: true
745 blacklist_devices:
746 - /dev/sda
747 - /dev/sdb
748 backends:
749 - hitachi_vsp1000
750
751Multipath with IBM Storwize
752
753.. code-block:: yaml
754
755 parameters:
756 linux:
757 storage:
758 multipath:
759 enabled: true
760 blacklist_devices:
761 - /dev/sda
762 - /dev/sdb
763 backends:
764 - ibm_storwize
765
766Multipath with multiple backends
767
768.. code-block:: yaml
769
770 parameters:
771 linux:
772 storage:
773 multipath:
774 enabled: true
775 blacklist_devices:
776 - /dev/sda
777 - /dev/sdb
778 - /dev/sdc
779 - /dev/sdd
780 backends:
781 - ibm_storwize
782 - fujitsu_eternus_dxl
783 - hitachi_vsp1000
784
785Disabled multipath (the default setup)
786
787.. code-block:: yaml
788
789 parameters:
790 linux:
791 storage:
792 multipath:
793 enabled: false
794
Simon Pasquier375001e2017-01-26 13:22:33 +0100795Linux with local loopback device
796
797.. code-block:: yaml
798
799 linux:
800 storage:
801 loopback:
802 disk1:
803 file: /srv/disk1
804 size: 50G
805
Filip Pytlounb2c8f852016-11-21 17:03:43 +0100806External config generation
807--------------------------
808
809You are able to use config support metadata between formulas and only generate
810config files for external use, eg. docker, etc.
811
812.. code-block:: yaml
813
814 parameters:
815 linux:
816 system:
817 config:
818 pillar:
819 jenkins:
820 master:
821 home: /srv/volumes/jenkins
822 approved_scripts:
823 - method java.net.URL openConnection
824 credentials:
825 - type: username_password
826 scope: global
827 id: test
828 desc: Testing credentials
829 username: test
830 password: test
831
Ales Komareka634f4b2016-10-02 13:11:04 +0200832
Filip Pytlounf5383a42015-10-06 16:28:32 +0200833Usage
834=====
835
836Set mtu of network interface eth0 to 1400
837
838.. code-block:: bash
839
840 ip link set dev eth0 mtu 1400
841
842Read more
843=========
844
845* https://www.archlinux.org/
846* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu
Filip Pytloun018f8712017-02-02 13:02:03 +0100847
848Documentation and Bugs
849======================
850
851To learn how to install and update salt-formulas, consult the documentation
852available online at:
853
854 http://salt-formulas.readthedocs.io/
855
856In the unfortunate event that bugs are discovered, they should be reported to
857the appropriate issue tracker. Use Github issue tracker for specific salt
858formula:
859
860 https://github.com/salt-formulas/salt-formula-linux/issues
861
862For feature requests, bug reports or blueprints affecting entire ecosystem,
863use Launchpad salt-formulas project:
864
865 https://launchpad.net/salt-formulas
866
867You can also join salt-formulas-users team and subscribe to mailing list:
868
869 https://launchpad.net/~salt-formulas-users
870
871Developers wishing to work on the salt-formulas projects should always base
872their work on master branch and submit pull request against specific formula.
873
874 https://github.com/salt-formulas/salt-formula-linux
875
876Any questions or feedback is always welcome so feel free to join our IRC
877channel:
878
879 #salt-formulas @ irc.freenode.net