blob: a0a415aaa272bbe6a907ccafedcccbba43056ca0 [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
Filip Pytloun281034a2016-01-04 18:06:22 +0100294Kernel
295~~~~~~
296
297Install always up to date LTS kernel and headers from Ubuntu trusty:
298
299.. code-block:: yaml
300
301 linux:
302 system:
303 kernel:
304 type: generic
305 lts: trusty
306 headers: true
307
Tomáš Kukrálba35b212017-02-15 17:59:46 +0100308Load kernel modules and add them to `/etc/modules`:
309
310.. code-block:: yaml
311
312 linux:
313 system:
314 kernel:
315 modules:
316 - nf_conntrack
317 - tp_smapi
318 - 8021q
319
Filip Pytloun281034a2016-01-04 18:06:22 +0100320Install specific kernel version and ensure all other kernel packages are
321not present. Also install extra modules and headers for this kernel:
322
323.. code-block:: yaml
324
325 linux:
326 system:
327 kernel:
328 type: generic
329 extra: true
330 headers: true
331 version: 4.2.0-22
332
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100333Systcl kernel parameters
334
335.. code-block:: yaml
336
337 linux:
338 system:
339 kernel:
340 sysctl:
341 net.ipv4.tcp_keepalive_intvl: 3
342 net.ipv4.tcp_keepalive_time: 30
343 net.ipv4.tcp_keepalive_probes: 8
344
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100345
346CPU
347~~~
348
349Disable ondemand cpu mode service:
350
351.. code-block:: yaml
352
353 linux:
354 system:
355 cpu:
356 governor: performance
357
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100358Huge Pages
359~~~~~~~~~~~~
360
361Huge Pages give a performance boost to applications that intensively deal
362with memory allocation/deallocation by decreasing memory fragmentation.
363
364.. code-block:: yaml
365
366 linux:
367 system:
368 kernel:
369 hugepages:
370 small:
371 size: 2M
372 count: 107520
373 mount_point: /mnt/hugepages_2MB
374 mount: false/true # default false
375 large:
376 default: true # default automatically mounted
377 size: 1G
378 count: 210
379 mount_point: /mnt/hugepages_1GB
380
381Note: not recommended to use both pagesizes in concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100382
Jakub Pavlik5398d872017-02-13 22:30:47 +0100383Intel SR-IOV
384~~~~~~~~~~~~
385
386PCI-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.
387
388.. code-block:: yaml
389
390 linux:
391 system:
392 kernel:
393 sriov: True
394 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
395 rc:
396 local: |
397 #!/bin/sh -e
398 # Enable 7 VF on eth1
399 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
400 exit 0
401
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100402Isolate CPU options
403~~~~~~~~~~~~~~~~~~~
404
405Remove the specified CPUs, as defined by the cpu_number values, from the general kernel
406SMP balancing and scheduler algroithms. The only way to move a process onto or off an
407"isolated" CPU is via the CPU affinity syscalls. cpu_number begins at 0, so the
408maximum value is 1 less than the number of CPUs on the system.
409
410.. code-block:: yaml
411
412 linux:
413 system:
414 kernel:
415 isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100416
Filip Pytlounf5383a42015-10-06 16:28:32 +0200417Repositories
418~~~~~~~~~~~~
419
420RedHat based Linux with additional OpenStack repo
421
422.. code-block:: yaml
423
424 linux:
425 system:
426 ...
427 repo:
428 rdo-icehouse:
429 enabled: true
430 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
431 pgpcheck: 0
432
433Ensure system repository to use czech Debian mirror (``default: true``)
434Also pin it's packages with priority 900.
435
436.. code-block:: yaml
437
438 linux:
439 system:
440 repo:
441 debian:
442 default: true
443 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
444 # Import signing key from URL if needed
445 key_url: "http://dummy.com/public.gpg"
446 pin:
447 - pin: 'origin "ftp.cz.debian.org"'
448 priority: 900
449 package: '*'
450
Petr Michalec10462bb2017-03-23 19:18:08 +0100451
452Package manager proxy setup globally:
453
454.. code-block:: yaml
455
456 linux:
457 system:
458 ...
459 repo:
460 apt-mk:
461 source: "deb http://apt-mk.mirantis.com/ stable main salt"
462 ...
463 proxy:
464 pkg:
465 enabled: true
466 ftp: ftp://ftp-proxy-for-apt.host.local:2121
467 ...
468 # NOTE: Global defaults for any other componet that configure proxy on the system.
469 # If your environment has just one simple proxy, set it on linux:system:proxy.
470 #
471 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
472 # as for https and http
473 ftp: ftp://proxy.host.local:2121
474 http: http://proxy.host.local:3142
475 https: https://proxy.host.local:3143
476
477Package manager proxy setup per repository:
478
479.. code-block:: yaml
480
481 linux:
482 system:
483 ...
484 repo:
485 debian:
486 source: "deb http://apt-mk.mirantis.com/ stable main salt"
487 ...
488 apt-mk:
489 source: "deb http://apt-mk.mirantis.com/ stable main salt"
490 # per repository proxy
491 proxy:
492 enabled: true
493 http: http://maas-01:8080
494 https: http://maas-01:8080
495 ...
496 proxy:
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600497 # package manager fallback defaults
Petr Michalec10462bb2017-03-23 19:18:08 +0100498 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
499 pkg:
500 enabled: true
501 ftp: ftp://proxy.host.local:2121
502 #http: http://proxy.host.local:3142
503 #https: https://proxy.host.local:3143
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600504 ...
Petr Michalec10462bb2017-03-23 19:18:08 +0100505 # global system fallback system defaults
506 ftp: ftp://proxy.host.local:2121
507 http: http://proxy.host.local:3142
508 https: https://proxy.host.local:3143
509
510
Jiri Broulik34a29b42017-04-25 14:42:54 +0200511Remove all repositories:
512
513.. code-block:: yaml
514
515 linux:
516 system:
517 purge_repos: true
518
519
Petr Michalec10462bb2017-03-23 19:18:08 +0100520RC
521~~
522
Jakub Pavlik78859382016-01-21 11:26:39 +0100523rc.local example
524
525.. code-block:: yaml
526
527 linux:
528 system:
529 rc:
530 local: |
531 #!/bin/sh -e
532 #
533 # rc.local
534 #
535 # This script is executed at the end of each multiuser runlevel.
536 # Make sure that the script will "exit 0" on success or any other
537 # value on error.
538 #
539 # In order to enable or disable this script just change the execution
540 # bits.
541 #
542 # By default this script does nothing.
543 exit 0
544
Petr Michalec10462bb2017-03-23 19:18:08 +0100545
Filip Pytloun1f40dac2016-01-22 15:52:57 +0100546Prompt
547~~~~~~
548
549Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
550user can have different prompt.
551
552.. code-block:: yaml
553
554 linux:
555 system:
556 prompt:
557 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\\]
558 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
559
560On Debian systems to set prompt system-wide it's necessary to remove setting
561PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
562``/etc/skel/.bashrc``). This formula will do this automatically, but will not
Filip Pytlound9b68da2016-01-22 15:58:41 +0100563touch existing user's ``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +0100564
Filip Pytlouneef11c12016-03-25 11:00:23 +0100565Bash
566~~~~
567
568Fix bash configuration to preserve history across sessions (like ZSH does by
569default).
570
571.. code-block:: yaml
572
573 linux:
574 system:
575 bash:
576 preserve_history: true
577
Filip Pytloune874dfb2016-01-22 16:57:34 +0100578Message of the day
579~~~~~~~~~~~~~~~~~~
580
581``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
582day. Setting custom motd will cleanup existing ones.
583
584.. code-block:: yaml
585
586 linux:
587 system:
588 motd:
589 - release: |
590 #!/bin/sh
591 [ -r /etc/lsb-release ] && . /etc/lsb-release
592
593 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
594 # Fall back to using the very slow lsb_release utility
595 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
596 fi
597
598 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
599 - warning: |
600 #!/bin/sh
601 printf "This is [company name] network.\n"
602 printf "Unauthorized access strictly prohibited.\n"
603
Marek Celoud713e9072017-05-18 15:20:25 +0200604Services
605~~~~~~~~
606
607Stop and disable linux service:
608
609.. code-block:: yaml
610
611 linux:
612 system:
613 service:
614 apt-daily.timer:
615 status: dead
616
617Possible status is dead (disable service by default), running (enable service by default), enabled, disabled.
618
Filip Pytloun2f70b492016-02-19 15:55:25 +0100619RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +0100620^^^^^^^^^^^^^
Filip Pytloun2f70b492016-02-19 15:55:25 +0100621
622Unfortunately ``update-motd`` is currently not available for RHEL so there's
623no native support for dynamic motd.
624You can still set static one, only pillar structure differs:
625
626.. code-block:: yaml
627
628 linux:
629 system:
630 motd: |
631 This is [company name] network.
632 Unauthorized access strictly prohibited.
633
Filip Pytloun8296bb92016-02-19 18:42:09 +0100634Haveged
635~~~~~~~
636
637If you are running headless server and are low on entropy, it may be a good
638idea to setup Haveged.
639
640.. code-block:: yaml
641
642 linux:
643 system:
644 haveged:
645 enabled: true
646
Filip Pytlounf5383a42015-10-06 16:28:32 +0200647Linux network
648-------------
649
650Linux with network manager
651
652.. code-block:: yaml
653
654 linux:
655 network:
656 enabled: true
657 network_manager: true
658
659Linux with default static network interfaces, default gateway interface and DNS servers
660
661.. code-block:: yaml
662
663 linux:
664 network:
665 enabled: true
666 interface:
667 eth0:
668 enabled: true
669 type: eth
670 address: 192.168.0.102
671 netmask: 255.255.255.0
672 gateway: 192.168.0.1
673 name_servers:
674 - 8.8.8.8
675 - 8.8.4.4
676 mtu: 1500
677
jan kaufman6d30adf2016-01-18 17:30:12 +0100678Linux with bonded interfaces and disabled NetworkManager
Filip Pytlounf5383a42015-10-06 16:28:32 +0200679
680.. code-block:: yaml
681
682 linux:
683 network:
684 enabled: true
685 interface:
686 eth0:
687 type: eth
688 ...
689 eth1:
690 type: eth
691 ...
692 bond0:
693 enabled: true
694 type: bond
695 address: 192.168.0.102
696 netmask: 255.255.255.0
697 mtu: 1500
698 use_in:
699 - interface: ${linux:interface:eth0}
700 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +0100701 network_manager:
702 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200703
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100704Linux with vlan interface_params
705
706.. code-block:: yaml
707
708 linux:
709 network:
710 enabled: true
711 interface:
712 vlan69:
713 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +0100714 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100715 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100716
Filip Pytlounf5383a42015-10-06 16:28:32 +0200717Linux with wireless interface parameters
718
719.. code-block:: yaml
720
721 linux:
722 network:
723 enabled: true
724 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100725 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200726 interface:
727 wlan0:
728 type: eth
729 wireless:
730 essid: example
731 key: example_key
732 security: wpa
733 priority: 1
734
735Linux networks with routes defined
736
737.. code-block:: yaml
738
739 linux:
740 network:
741 enabled: true
742 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100743 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200744 interface:
745 eth0:
746 type: eth
747 route:
748 default:
749 address: 192.168.0.123
750 netmask: 255.255.255.0
751 gateway: 192.168.0.1
752
753Native Linux Bridges
754
755.. code-block:: yaml
756
757 linux:
758 network:
759 interface:
760 eth1:
761 enabled: true
762 type: eth
763 proto: manual
764 up_cmds:
765 - ip address add 0/0 dev $IFACE
766 - ip link set $IFACE up
767 down_cmds:
768 - ip link set $IFACE down
769 br-ex:
770 enabled: true
771 type: bridge
772 address: ${linux:network:host:public_local:address}
773 netmask: 255.255.255.0
774 use_interfaces:
775 - eth1
776
777OpenVswitch Bridges
778
779.. code-block:: yaml
780
781 linux:
782 network:
783 bridge: openvswitch
784 interface:
785 eth1:
786 enabled: true
787 type: eth
788 proto: manual
789 up_cmds:
790 - ip address add 0/0 dev $IFACE
791 - ip link set $IFACE up
792 down_cmds:
793 - ip link set $IFACE down
794 br-ex:
795 enabled: true
796 type: bridge
797 address: ${linux:network:host:public_local:address}
798 netmask: 255.255.255.0
799 use_interfaces:
800 - eth1
801
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600802DHCP client configuration
803
804None of the keys is mandatory, include only those you really need. For full list
805of available options under send, supersede, prepend, append refer to dhcp-options(5)
806
807.. code-block:: yaml
808
809 linux:
810 network:
811 dhclient:
812 enabled: true
813 backoff_cutoff: 15
814 initial_interval: 10
815 reboot: 10
816 retry: 60
817 select_timeout: 0
818 timeout: 120
819 send:
820 - option: host-name
821 declaration: "= gethostname()"
822 supersede:
823 - option: host-name
824 declaration: "spaceship"
825 - option: domain-name
826 declaration: "domain.home"
827 #- option: arp-cache-timeout
828 # declaration: 20
829 prepend:
830 - option: domain-name-servers
831 declaration:
832 - 8.8.8.8
833 - 8.8.4.4
834 - option: domain-search
835 declaration:
836 - example.com
837 - eng.example.com
838 #append:
839 #- option: domain-name-servers
840 # declaration: 127.0.0.1
841 # ip or subnet to reject dhcp offer from
842 reject:
843 - 192.33.137.209
844 - 10.0.2.0/24
845 request:
846 - subnet-mask
847 - broadcast-address
848 - time-offset
849 - routers
850 - domain-name
851 - domain-name-servers
852 - domain-search
853 - host-name
854 - dhcp6.name-servers
855 - dhcp6.domain-search
856 - dhcp6.fqdn
857 - dhcp6.sntp-servers
858 - netbios-name-servers
859 - netbios-scope
860 - interface-mtu
861 - rfc3442-classless-static-routes
862 - ntp-servers
863 require:
864 - subnet-mask
865 - domain-name-servers
866 # if per interface configuration required add below
867 interface:
868 ens2:
869 initial_interval: 11
870 reject:
871 - 192.33.137.210
872 ens3:
873 initial_interval: 12
874 reject:
875 - 192.33.137.211
876
877
Petr Michalec10462bb2017-03-23 19:18:08 +0100878Configure global environment variables
879~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
880
881Linux /etc/environment:
882``/etc/environment`` is for static system wide variable assignment after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +0200883
884.. code-block:: yaml
885
886 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +0100887 system:
888 env:
889 BOB_VARIABLE: Alice
890 ...
891 BOB_PATH:
892 - /srv/alice/bin
893 - /srv/bob/bin
894 ...
895 ftp_proxy: none
896 http_proxy: http://global-http-proxy.host.local:8080
897 https_proxy: ${linux:system:proxy:https}
898 no_proxy:
899 - 192.168.0.80
900 - 192.168.1.80
901 - .domain.com
902 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +0200903 ...
Petr Michalec10462bb2017-03-23 19:18:08 +0100904 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +0200905 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +0100906 ftp: ftp://proxy.host.local:2121
907 http: http://proxy.host.local:3142
908 https: https://proxy.host.local:3143
909 noproxy:
910 - .domain.com
911 - .local
912
913Configure profile.d scripts
914~~~~~~~~~~~~~~~~~~~~~~~~~~~
915
916Linux /etc/profile.d:
917The profile.d scripts are being sourced during .sh execution and support variable expansion in opposite to /etc/environment
918global settings in ``/etc/environment``.
919
920.. code-block:: yaml
921
922 linux:
923 system:
924 profile:
925 locales: |
926 export LANG=C
927 export LC_ALL=C
928 ...
929 vi_flavors.sh: |
930 export PAGER=view
931 export EDITOR=vim
932 alias vi=vim
933 shell_locales.sh: |
934 export LANG=en_US
935 export LC_ALL=en_US.UTF-8
936 shell_proxies.sh: |
937 export FTP_PROXY=ftp://127.0.3.3:2121
938 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +0200939
940Linux with hosts
Petr Michalec10462bb2017-03-23 19:18:08 +0100941~~~~~~~~~~~~~~~~
Filip Pytlounf5383a42015-10-06 16:28:32 +0200942
Filip Pytloun86506fe2017-01-26 14:36:16 +0100943Parameter purge_hosts will enforce whole /etc/hosts file, removing entries
944that are not defined in model except defaults for both IPv4 and IPv6 localhost
945and hostname + fqdn.
946It's good to use this option if you want to ensure /etc/hosts is always in a
947clean state however it's not enabled by default for safety.
948
Filip Pytlounf5383a42015-10-06 16:28:32 +0200949.. code-block:: yaml
950
951 linux:
952 network:
953 ...
Filip Pytloun86506fe2017-01-26 14:36:16 +0100954 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200955 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +0100956 # No need to define this one if purge_hosts is true
957 hostname:
958 address: 127.0.1.1
959 names:
960 - ${linux:network:fqdn}
961 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +0200962 node1:
963 address: 192.168.10.200
964 names:
965 - node2.domain.com
966 - service2.domain.com
967 node2:
968 address: 192.168.10.201
969 names:
970 - node2.domain.com
971 - service2.domain.com
972
Filip Pytloun86506fe2017-01-26 14:36:16 +0100973
Filip Pytlounde9bea52016-01-11 15:39:10 +0100974Setup resolv.conf, nameservers, domain and search domains
Petr Michalec10462bb2017-03-23 19:18:08 +0100975~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filip Pytlounde9bea52016-01-11 15:39:10 +0100976
977.. code-block:: yaml
978
979 linux:
980 network:
981 resolv:
982 dns:
Jakub Pavlik21ca2152017-02-27 22:21:09 +0100983 - 8.8.4.4
984 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +0100985 domain: my.example.com
986 search:
Jakub Pavlik21ca2152017-02-27 22:21:09 +0100987 - my.example.com
988 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +0100989 options:
Jakub Pavlik21ca2152017-02-27 22:21:09 +0100990 - ndots: 5
991 - timeout: 2
992 - attempts: 2
Filip Pytlounde9bea52016-01-11 15:39:10 +0100993
Andrii Petrenko735761d2017-03-21 17:17:35 -0700994**setting custom TX queue length for tap interfaces**
995
996.. code-block:: yaml
997
998 linux:
999 network:
1000 tap_custom_txqueuelen: 10000
1001
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001002DPDK OVS interfaces
1003--------------------
1004
1005**DPDK OVS NIC**
1006
1007.. code-block:: yaml
1008
1009 linux:
1010 network:
1011 bridge: openvswitch
1012 dpdk:
1013 enabled: true
1014 driver: uio/vfio-pci
1015 openvswitch:
1016 pmd_cpu_mask: "0x6"
1017 dpdk_socket_mem: "1024,1024"
1018 dpdk_lcore_mask: "0x400"
1019 memory_channels: 2
1020 interface:
1021 dpkd0:
1022 name: ${_param:dpdk_nic}
1023 pci: 0000:06:00.0
1024 driver: igb_uio/vfio
1025 enabled: true
1026 type: dpdk_ovs_port
1027 n_rxq: 2
1028 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01001029 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001030 br-prv:
1031 enabled: true
1032 type: dpdk_ovs_bridge
1033
1034**DPDK OVS Bond**
1035
1036.. code-block:: yaml
1037
1038 linux:
1039 network:
1040 bridge: openvswitch
1041 dpdk:
1042 enabled: true
1043 driver: uio/vfio-pci
1044 openvswitch:
1045 pmd_cpu_mask: "0x6"
1046 dpdk_socket_mem: "1024,1024"
1047 dpdk_lcore_mask: "0x400"
1048 memory_channels: 2
1049 interface:
1050 dpdk_second_nic:
1051 name: ${_param:primary_second_nic}
1052 pci: 0000:06:00.0
1053 driver: igb_uio/vfio
1054 bond: dpdkbond0
1055 enabled: true
1056 type: dpdk_ovs_port
1057 n_rxq: 2
Jakub Pavlikaa759062017-03-13 15:57:26 +01001058 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001059 dpdk_first_nic:
1060 name: ${_param:primary_first_nic}
1061 pci: 0000:05:00.0
1062 driver: igb_uio/vfio
1063 bond: dpdkbond0
1064 enabled: true
1065 type: dpdk_ovs_port
1066 n_rxq: 2
Jakub Pavlikaa759062017-03-13 15:57:26 +01001067 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001068 dpdkbond0:
1069 enabled: true
1070 bridge: br-prv
1071 type: dpdk_ovs_bond
1072 mode: active-backup
1073 br-prv:
1074 enabled: true
1075 type: dpdk_ovs_bridge
1076
Jakub Pavlikaa759062017-03-13 15:57:26 +01001077**DPDK OVS bridge for VXLAN**
1078
1079If VXLAN is used as tenant segmentation then ip address must be set on br-prv
1080
1081.. code-block:: yaml
1082
1083 linux:
1084 network:
1085 ...
1086 interface:
1087 br-prv:
1088 enabled: true
1089 type: dpdk_ovs_bridge
1090 address: 192.168.50.0
1091 netmask: 255.255.255.0
1092 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001093
1094Linux storage
1095-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02001096
1097Linux with mounted Samba
1098
1099.. code-block:: yaml
1100
1101 linux:
1102 storage:
1103 enabled: true
1104 mount:
1105 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01001106 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001107 - path: /media/myuser/public/
1108 - device: //192.168.0.1/storage
1109 - file_system: cifs
1110 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
1111
Jiri Broulikb017f932017-03-31 13:55:36 +02001112NFS mount
1113
1114.. code-block:: yaml
1115
1116 linux:
1117 storage:
1118 enabled: true
1119 mount:
1120 nfs_glance:
1121 enabled: true
1122 path: /var/lib/glance/images
1123 device: 172.16.10.110:/var/nfs/glance
1124 file_system: nfs
1125 opts: rw,sync
1126
1127
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001128File swap configuration
Filip Pytlounf5383a42015-10-06 16:28:32 +02001129
1130.. code-block:: yaml
1131
1132 linux:
1133 storage:
1134 enabled: true
1135 swap:
1136 file:
1137 enabled: true
1138 engine: file
1139 device: /swapfile
1140 size: 1024
1141
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001142Partition swap configuration
Lachlan Evenson30676512016-01-22 15:43:28 -08001143
1144.. code-block:: yaml
1145
1146 linux:
1147 storage:
1148 enabled: true
1149 swap:
1150 partition:
1151 enabled: true
1152 engine: partition
1153 device: /dev/vg0/swap
1154
Filip Pytlounc8a001a2015-12-15 14:09:19 +01001155LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
1156
1157.. code-block:: yaml
1158
1159 parameters:
1160 linux:
1161 storage:
1162 mount:
1163 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01001164 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01001165 device: /dev/vg1/data
1166 file_system: ext4
1167 path: /mnt/data
1168 lvm:
1169 vg1:
1170 enabled: true
1171 devices:
1172 - /dev/sdb
1173 volume:
1174 data:
1175 size: 40G
1176 mount: ${linux:storage:mount:data}
1177
Ales Komareka634f4b2016-10-02 13:11:04 +02001178
1179Multipath with Fujitsu Eternus DXL
1180
1181.. code-block:: yaml
1182
1183 parameters:
1184 linux:
1185 storage:
1186 multipath:
1187 enabled: true
1188 blacklist_devices:
1189 - /dev/sda
1190 - /dev/sdb
1191 backends:
1192 - fujitsu_eternus_dxl
1193
1194Multipath with Hitachi VSP 1000
1195
1196.. code-block:: yaml
1197
1198 parameters:
1199 linux:
1200 storage:
1201 multipath:
1202 enabled: true
1203 blacklist_devices:
1204 - /dev/sda
1205 - /dev/sdb
1206 backends:
1207 - hitachi_vsp1000
1208
1209Multipath with IBM Storwize
1210
1211.. code-block:: yaml
1212
1213 parameters:
1214 linux:
1215 storage:
1216 multipath:
1217 enabled: true
1218 blacklist_devices:
1219 - /dev/sda
1220 - /dev/sdb
1221 backends:
1222 - ibm_storwize
1223
1224Multipath with multiple backends
1225
1226.. code-block:: yaml
1227
1228 parameters:
1229 linux:
1230 storage:
1231 multipath:
1232 enabled: true
1233 blacklist_devices:
1234 - /dev/sda
1235 - /dev/sdb
1236 - /dev/sdc
1237 - /dev/sdd
1238 backends:
1239 - ibm_storwize
1240 - fujitsu_eternus_dxl
1241 - hitachi_vsp1000
1242
1243Disabled multipath (the default setup)
1244
1245.. code-block:: yaml
1246
1247 parameters:
1248 linux:
1249 storage:
1250 multipath:
1251 enabled: false
1252
Simon Pasquier375001e2017-01-26 13:22:33 +01001253Linux with local loopback device
1254
1255.. code-block:: yaml
1256
1257 linux:
1258 storage:
1259 loopback:
1260 disk1:
1261 file: /srv/disk1
1262 size: 50G
1263
Filip Pytlounb2c8f852016-11-21 17:03:43 +01001264External config generation
1265--------------------------
1266
1267You are able to use config support metadata between formulas and only generate
1268config files for external use, eg. docker, etc.
1269
1270.. code-block:: yaml
1271
1272 parameters:
1273 linux:
1274 system:
1275 config:
1276 pillar:
1277 jenkins:
1278 master:
1279 home: /srv/volumes/jenkins
1280 approved_scripts:
1281 - method java.net.URL openConnection
1282 credentials:
1283 - type: username_password
1284 scope: global
1285 id: test
1286 desc: Testing credentials
1287 username: test
1288 password: test
1289
Vladimir Ereminccf28842017-04-10 23:52:10 +03001290Netconsole Remote Kernel Logging
1291--------------------------------
1292
1293Netconsole logger could be configured for configfs-enabled kernels
1294(`CONFIG_NETCONSOLE_DYNAMIC` should be enabled). Configuration applies both in
1295runtime (if network is already configured), and on-boot after interface
1296initialization. Notes:
1297
1298 * receiver could be located only in same L3 domain
1299 (or you need to configure gateway MAC manually)
1300 * receiver's MAC is detected only on configuration time
1301 * using broadcast MAC is not recommended
1302
1303.. code-block:: yaml
1304
1305 parameters:
1306 linux:
1307 system:
1308 netconsole:
1309 enabled: true
1310 port: 514 (optional)
1311 loglevel: debug (optional)
1312 target:
1313 192.168.0.1:
1314 interface: bond0
1315 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02001316
Filip Pytlounf5383a42015-10-06 16:28:32 +02001317Usage
1318=====
1319
1320Set mtu of network interface eth0 to 1400
1321
1322.. code-block:: bash
1323
1324 ip link set dev eth0 mtu 1400
1325
1326Read more
1327=========
1328
1329* https://www.archlinux.org/
1330* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu
Filip Pytloun018f8712017-02-02 13:02:03 +01001331
1332Documentation and Bugs
1333======================
1334
1335To learn how to install and update salt-formulas, consult the documentation
1336available online at:
1337
1338 http://salt-formulas.readthedocs.io/
1339
1340In the unfortunate event that bugs are discovered, they should be reported to
1341the appropriate issue tracker. Use Github issue tracker for specific salt
1342formula:
1343
1344 https://github.com/salt-formulas/salt-formula-linux/issues
1345
1346For feature requests, bug reports or blueprints affecting entire ecosystem,
1347use Launchpad salt-formulas project:
1348
1349 https://launchpad.net/salt-formulas
1350
1351You can also join salt-formulas-users team and subscribe to mailing list:
1352
1353 https://launchpad.net/~salt-formulas-users
1354
1355Developers wishing to work on the salt-formulas projects should always base
1356their work on master branch and submit pull request against specific formula.
1357
1358 https://github.com/salt-formulas/salt-formula-linux
1359
1360Any questions or feedback is always welcome so feel free to join our IRC
1361channel:
1362
1363 #salt-formulas @ irc.freenode.net