blob: 348f9508433e6460a45c7ec4be8037f0487832ef [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
245
Filip Pytlounf5383a42015-10-06 16:28:32 +0200246Repositories
247~~~~~~~~~~~~
248
249RedHat based Linux with additional OpenStack repo
250
251.. code-block:: yaml
252
253 linux:
254 system:
255 ...
256 repo:
257 rdo-icehouse:
258 enabled: true
259 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
260 pgpcheck: 0
261
262Ensure system repository to use czech Debian mirror (``default: true``)
263Also pin it's packages with priority 900.
264
265.. code-block:: yaml
266
267 linux:
268 system:
269 repo:
270 debian:
271 default: true
272 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
273 # Import signing key from URL if needed
274 key_url: "http://dummy.com/public.gpg"
275 pin:
276 - pin: 'origin "ftp.cz.debian.org"'
277 priority: 900
278 package: '*'
279
Jakub Pavlik78859382016-01-21 11:26:39 +0100280rc.local example
281
282.. code-block:: yaml
283
284 linux:
285 system:
286 rc:
287 local: |
288 #!/bin/sh -e
289 #
290 # rc.local
291 #
292 # This script is executed at the end of each multiuser runlevel.
293 # Make sure that the script will "exit 0" on success or any other
294 # value on error.
295 #
296 # In order to enable or disable this script just change the execution
297 # bits.
298 #
299 # By default this script does nothing.
300 exit 0
301
Filip Pytloun1f40dac2016-01-22 15:52:57 +0100302Prompt
303~~~~~~
304
305Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
306user can have different prompt.
307
308.. code-block:: yaml
309
310 linux:
311 system:
312 prompt:
313 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\\]
314 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
315
316On Debian systems to set prompt system-wide it's necessary to remove setting
317PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
318``/etc/skel/.bashrc``). This formula will do this automatically, but will not
Filip Pytlound9b68da2016-01-22 15:58:41 +0100319touch existing user's ``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +0100320
Filip Pytlouneef11c12016-03-25 11:00:23 +0100321Bash
322~~~~
323
324Fix bash configuration to preserve history across sessions (like ZSH does by
325default).
326
327.. code-block:: yaml
328
329 linux:
330 system:
331 bash:
332 preserve_history: true
333
Filip Pytloune874dfb2016-01-22 16:57:34 +0100334Message of the day
335~~~~~~~~~~~~~~~~~~
336
337``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
338day. Setting custom motd will cleanup existing ones.
339
340.. code-block:: yaml
341
342 linux:
343 system:
344 motd:
345 - release: |
346 #!/bin/sh
347 [ -r /etc/lsb-release ] && . /etc/lsb-release
348
349 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
350 # Fall back to using the very slow lsb_release utility
351 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
352 fi
353
354 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
355 - warning: |
356 #!/bin/sh
357 printf "This is [company name] network.\n"
358 printf "Unauthorized access strictly prohibited.\n"
359
Filip Pytloun2f70b492016-02-19 15:55:25 +0100360RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +0100361^^^^^^^^^^^^^
Filip Pytloun2f70b492016-02-19 15:55:25 +0100362
363Unfortunately ``update-motd`` is currently not available for RHEL so there's
364no native support for dynamic motd.
365You can still set static one, only pillar structure differs:
366
367.. code-block:: yaml
368
369 linux:
370 system:
371 motd: |
372 This is [company name] network.
373 Unauthorized access strictly prohibited.
374
Filip Pytloun8296bb92016-02-19 18:42:09 +0100375Haveged
376~~~~~~~
377
378If you are running headless server and are low on entropy, it may be a good
379idea to setup Haveged.
380
381.. code-block:: yaml
382
383 linux:
384 system:
385 haveged:
386 enabled: true
387
Filip Pytlounf5383a42015-10-06 16:28:32 +0200388Linux network
389-------------
390
391Linux with network manager
392
393.. code-block:: yaml
394
395 linux:
396 network:
397 enabled: true
398 network_manager: true
399
400Linux with default static network interfaces, default gateway interface and DNS servers
401
402.. code-block:: yaml
403
404 linux:
405 network:
406 enabled: true
407 interface:
408 eth0:
409 enabled: true
410 type: eth
411 address: 192.168.0.102
412 netmask: 255.255.255.0
413 gateway: 192.168.0.1
414 name_servers:
415 - 8.8.8.8
416 - 8.8.4.4
417 mtu: 1500
418
jan kaufman6d30adf2016-01-18 17:30:12 +0100419Linux with bonded interfaces and disabled NetworkManager
Filip Pytlounf5383a42015-10-06 16:28:32 +0200420
421.. code-block:: yaml
422
423 linux:
424 network:
425 enabled: true
426 interface:
427 eth0:
428 type: eth
429 ...
430 eth1:
431 type: eth
432 ...
433 bond0:
434 enabled: true
435 type: bond
436 address: 192.168.0.102
437 netmask: 255.255.255.0
438 mtu: 1500
439 use_in:
440 - interface: ${linux:interface:eth0}
441 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +0100442 network_manager:
443 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200444
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100445Linux with vlan interface_params
446
447.. code-block:: yaml
448
449 linux:
450 network:
451 enabled: true
452 interface:
453 vlan69:
454 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +0100455 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100456 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100457
Filip Pytlounf5383a42015-10-06 16:28:32 +0200458Linux with wireless interface parameters
459
460.. code-block:: yaml
461
462 linux:
463 network:
464 enabled: true
465 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100466 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200467 interface:
468 wlan0:
469 type: eth
470 wireless:
471 essid: example
472 key: example_key
473 security: wpa
474 priority: 1
475
476Linux networks with routes defined
477
478.. code-block:: yaml
479
480 linux:
481 network:
482 enabled: true
483 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100484 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200485 interface:
486 eth0:
487 type: eth
488 route:
489 default:
490 address: 192.168.0.123
491 netmask: 255.255.255.0
492 gateway: 192.168.0.1
493
494Native Linux Bridges
495
496.. code-block:: yaml
497
498 linux:
499 network:
500 interface:
501 eth1:
502 enabled: true
503 type: eth
504 proto: manual
505 up_cmds:
506 - ip address add 0/0 dev $IFACE
507 - ip link set $IFACE up
508 down_cmds:
509 - ip link set $IFACE down
510 br-ex:
511 enabled: true
512 type: bridge
513 address: ${linux:network:host:public_local:address}
514 netmask: 255.255.255.0
515 use_interfaces:
516 - eth1
517
518OpenVswitch Bridges
519
520.. code-block:: yaml
521
522 linux:
523 network:
524 bridge: openvswitch
525 interface:
526 eth1:
527 enabled: true
528 type: eth
529 proto: manual
530 up_cmds:
531 - ip address add 0/0 dev $IFACE
532 - ip link set $IFACE up
533 down_cmds:
534 - ip link set $IFACE down
535 br-ex:
536 enabled: true
537 type: bridge
538 address: ${linux:network:host:public_local:address}
539 netmask: 255.255.255.0
540 use_interfaces:
541 - eth1
542
543Linux with proxy
544
545.. code-block:: yaml
546
547 linux:
548 network:
549 ...
550 proxy:
551 host: proxy.domain.com
552 port: 3128
553
554Linux with hosts
555
Filip Pytloun86506fe2017-01-26 14:36:16 +0100556Parameter purge_hosts will enforce whole /etc/hosts file, removing entries
557that are not defined in model except defaults for both IPv4 and IPv6 localhost
558and hostname + fqdn.
559It's good to use this option if you want to ensure /etc/hosts is always in a
560clean state however it's not enabled by default for safety.
561
Filip Pytlounf5383a42015-10-06 16:28:32 +0200562.. code-block:: yaml
563
564 linux:
565 network:
566 ...
Filip Pytloun86506fe2017-01-26 14:36:16 +0100567 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200568 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +0100569 # No need to define this one if purge_hosts is true
570 hostname:
571 address: 127.0.1.1
572 names:
573 - ${linux:network:fqdn}
574 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +0200575 node1:
576 address: 192.168.10.200
577 names:
578 - node2.domain.com
579 - service2.domain.com
580 node2:
581 address: 192.168.10.201
582 names:
583 - node2.domain.com
584 - service2.domain.com
585
Filip Pytloun86506fe2017-01-26 14:36:16 +0100586
Filip Pytlounde9bea52016-01-11 15:39:10 +0100587Setup resolv.conf, nameservers, domain and search domains
588
589.. code-block:: yaml
590
591 linux:
592 network:
593 resolv:
594 dns:
595 - 8.8.4.4
596 - 8.8.8.8
597 domain: my.example.com
598 search:
599 - my.example.com
600 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +0100601 options:
602 - ndots:5
603 - timeout:2
604 - attempts:2
Filip Pytlounde9bea52016-01-11 15:39:10 +0100605
Filip Pytlounf5383a42015-10-06 16:28:32 +0200606Linux storage pillars
607---------------------
608
609Linux with mounted Samba
610
611.. code-block:: yaml
612
613 linux:
614 storage:
615 enabled: true
616 mount:
617 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +0100618 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200619 - path: /media/myuser/public/
620 - device: //192.168.0.1/storage
621 - file_system: cifs
622 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
623
624Linux with file swap
625
626.. code-block:: yaml
627
628 linux:
629 storage:
630 enabled: true
631 swap:
632 file:
633 enabled: true
634 engine: file
635 device: /swapfile
636 size: 1024
637
Lachlan Evenson30676512016-01-22 15:43:28 -0800638Linux with partition swap
639
640.. code-block:: yaml
641
642 linux:
643 storage:
644 enabled: true
645 swap:
646 partition:
647 enabled: true
648 engine: partition
649 device: /dev/vg0/swap
650
Filip Pytlounc8a001a2015-12-15 14:09:19 +0100651LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
652
653.. code-block:: yaml
654
655 parameters:
656 linux:
657 storage:
658 mount:
659 data:
Simon Pasquier376262a2016-11-16 15:21:51 +0100660 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +0100661 device: /dev/vg1/data
662 file_system: ext4
663 path: /mnt/data
664 lvm:
665 vg1:
666 enabled: true
667 devices:
668 - /dev/sdb
669 volume:
670 data:
671 size: 40G
672 mount: ${linux:storage:mount:data}
673
Ales Komareka634f4b2016-10-02 13:11:04 +0200674
675Multipath with Fujitsu Eternus DXL
676
677.. code-block:: yaml
678
679 parameters:
680 linux:
681 storage:
682 multipath:
683 enabled: true
684 blacklist_devices:
685 - /dev/sda
686 - /dev/sdb
687 backends:
688 - fujitsu_eternus_dxl
689
690Multipath with Hitachi VSP 1000
691
692.. code-block:: yaml
693
694 parameters:
695 linux:
696 storage:
697 multipath:
698 enabled: true
699 blacklist_devices:
700 - /dev/sda
701 - /dev/sdb
702 backends:
703 - hitachi_vsp1000
704
705Multipath with IBM Storwize
706
707.. code-block:: yaml
708
709 parameters:
710 linux:
711 storage:
712 multipath:
713 enabled: true
714 blacklist_devices:
715 - /dev/sda
716 - /dev/sdb
717 backends:
718 - ibm_storwize
719
720Multipath with multiple backends
721
722.. code-block:: yaml
723
724 parameters:
725 linux:
726 storage:
727 multipath:
728 enabled: true
729 blacklist_devices:
730 - /dev/sda
731 - /dev/sdb
732 - /dev/sdc
733 - /dev/sdd
734 backends:
735 - ibm_storwize
736 - fujitsu_eternus_dxl
737 - hitachi_vsp1000
738
739Disabled multipath (the default setup)
740
741.. code-block:: yaml
742
743 parameters:
744 linux:
745 storage:
746 multipath:
747 enabled: false
748
Simon Pasquier375001e2017-01-26 13:22:33 +0100749Linux with local loopback device
750
751.. code-block:: yaml
752
753 linux:
754 storage:
755 loopback:
756 disk1:
757 file: /srv/disk1
758 size: 50G
759
Filip Pytlounb2c8f852016-11-21 17:03:43 +0100760External config generation
761--------------------------
762
763You are able to use config support metadata between formulas and only generate
764config files for external use, eg. docker, etc.
765
766.. code-block:: yaml
767
768 parameters:
769 linux:
770 system:
771 config:
772 pillar:
773 jenkins:
774 master:
775 home: /srv/volumes/jenkins
776 approved_scripts:
777 - method java.net.URL openConnection
778 credentials:
779 - type: username_password
780 scope: global
781 id: test
782 desc: Testing credentials
783 username: test
784 password: test
785
Ales Komareka634f4b2016-10-02 13:11:04 +0200786
Filip Pytlounf5383a42015-10-06 16:28:32 +0200787Usage
788=====
789
790Set mtu of network interface eth0 to 1400
791
792.. code-block:: bash
793
794 ip link set dev eth0 mtu 1400
795
796Read more
797=========
798
799* https://www.archlinux.org/
800* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu
Filip Pytloun018f8712017-02-02 13:02:03 +0100801
802Documentation and Bugs
803======================
804
805To learn how to install and update salt-formulas, consult the documentation
806available online at:
807
808 http://salt-formulas.readthedocs.io/
809
810In the unfortunate event that bugs are discovered, they should be reported to
811the appropriate issue tracker. Use Github issue tracker for specific salt
812formula:
813
814 https://github.com/salt-formulas/salt-formula-linux/issues
815
816For feature requests, bug reports or blueprints affecting entire ecosystem,
817use Launchpad salt-formulas project:
818
819 https://launchpad.net/salt-formulas
820
821You can also join salt-formulas-users team and subscribe to mailing list:
822
823 https://launchpad.net/~salt-formulas-users
824
825Developers wishing to work on the salt-formulas projects should always base
826their work on master branch and submit pull request against specific formula.
827
828 https://github.com/salt-formulas/salt-formula-linux
829
830Any questions or feedback is always welcome so feel free to join our IRC
831channel:
832
833 #salt-formulas @ irc.freenode.net