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