blob: 6f81c5dc0ec785f9b599b63caeaf07a2dbac0231 [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
azvyagintsev967af132017-06-12 12:25:24 +030034Linux with system users, some with password set:
35.. WARNING::
36If no 'password' variable has been passed - any predifined password
37will be removed.
Filip Pytlounf5383a42015-10-06 16:28:32 +020038
39.. code-block:: yaml
40
41 linux:
42 system:
43 ...
44 user:
45 jdoe:
46 name: 'jdoe'
47 enabled: true
48 sudo: true
49 shell: /bin/bash
50 full_name: 'Jonh Doe'
51 home: '/home/jdoe'
52 email: 'jonh@doe.com'
53 jsmith:
54 name: 'jsmith'
55 enabled: true
azvyagintsev967af132017-06-12 12:25:24 +030056 full_name: 'With clear password'
Filip Pytlounf5383a42015-10-06 16:28:32 +020057 home: '/home/jsmith'
azvyagintsev967af132017-06-12 12:25:24 +030058 hash_password: true
59 password: "userpassword"
60 mark:
61 name: 'mark'
62 enabled: true
63 full_name: "unchange password'
64 home: '/home/mark'
65 password: false
66 elizabeth:
67 name: 'elizabeth'
68 enabled: true
69 full_name: 'With hased password'
70 home: '/home/elizabeth'
71 password: "$6$nUI7QEz3$dFYjzQqK5cJ6HQ38KqG4gTWA9eJu3aKx6TRVDFh6BVJxJgFWg2akfAA7f1fCxcSUeOJ2arCO6EEI6XXnHXxG10"
Filip Pytlounf5383a42015-10-06 16:28:32 +020072
Petr Michalec1c4c8d82017-02-28 19:09:21 +010073Configure sudo for users and groups under ``/etc/sudoers.d/``.
74This ways ``linux.system.sudo`` pillar map to actual sudo attributes:
75
76.. code-block:: jinja
Aleš Komárek63572992017-04-11 13:16:44 +020077
Petr Michalec1c4c8d82017-02-28 19:09:21 +010078 # simplified template:
79 Cmds_Alias {{ alias }}={{ commands }}
80 {{ user }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
81 %{{ group }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
82
83 # when rendered:
84 saltuser1 ALL=(ALL) NOPASSWD: ALL
85
Petr Michalec1c4c8d82017-02-28 19:09:21 +010086.. code-block:: yaml
Aleš Komárek63572992017-04-11 13:16:44 +020087
Petr Michalec1c4c8d82017-02-28 19:09:21 +010088 linux:
89 system:
90 sudo:
91 enabled: true
Tomas Kammd8eb3002017-05-08 19:30:29 +020092 aliases:
Petr Michalec1c4c8d82017-02-28 19:09:21 +010093 host:
94 LOCAL:
95 - localhost
96 PRODUCTION:
97 - db1
98 - db2
99 runas:
100 DBA:
101 - postgres
102 - mysql
103 SALT:
104 - root
105 command:
106 # Note: This is not 100% safe when ALL keyword is used, user still may modify configs and hide his actions.
107 # Best practice is to specify full list of commands user is allowed to run.
108 SUPPORT_RESTRICTED:
109 - /bin/vi /etc/sudoers*
110 - /bin/vim /etc/sudoers*
111 - /bin/nano /etc/sudoers*
112 - /bin/emacs /etc/sudoers*
113 - /bin/su - root
114 - /bin/su -
115 - /bin/su
116 - /usr/sbin/visudo
117 SUPPORT_SHELLS:
118 - /bin/sh
119 - /bin/ksh
120 - /bin/bash
121 - /bin/rbash
122 - /bin/dash
123 - /bin/zsh
124 - /bin/csh
125 - /bin/fish
126 - /bin/tcsh
127 - /usr/bin/login
128 - /usr/bin/su
129 - /usr/su
130 ALL_SALT_SAFE:
131 - /usr/bin/salt state*
132 - /usr/bin/salt service*
133 - /usr/bin/salt pillar*
134 - /usr/bin/salt grains*
135 - /usr/bin/salt saltutil*
136 - /usr/bin/salt-call state*
137 - /usr/bin/salt-call service*
138 - /usr/bin/salt-call pillar*
139 - /usr/bin/salt-call grains*
140 - /usr/bin/salt-call saltutil*
141 SALT_TRUSTED:
142 - /usr/bin/salt*
143 users:
144 # saltuser1 with default values: saltuser1 ALL=(ALL) NOPASSWD: ALL
145 saltuser1: {}
146 saltuser2:
147 hosts:
148 - LOCAL
149 # User Alias DBA
150 DBA:
151 hosts:
152 - ALL
153 commands:
154 - ALL_SALT_SAFE
155 groups:
156 db-ops:
157 hosts:
158 - ALL
159 - '!PRODUCTION'
160 runas:
161 - DBA
162 commands:
163 - /bin/cat *
164 - /bin/less *
165 - /bin/ls *
166 salt-ops:
167 hosts:
168 - 'ALL'
169 runas:
170 - SALT
171 commands:
172 - SUPPORT_SHELLS
173 salt-ops-2nd:
174 name: salt-ops
175 nopasswd: false
Jakub Josef7a9d9b92017-05-16 11:39:01 +0200176 setenv: true # Enable sudo -E option
Petr Michalec1c4c8d82017-02-28 19:09:21 +0100177 runas:
178 - DBA
179 commands:
180 - ALL
181 - '!SUPPORT_SHELLS'
182 - '!SUPPORT_RESTRICTED'
183
Filip Pytlounf5383a42015-10-06 16:28:32 +0200184Linux with package, latest version
185
186.. code-block:: yaml
187
188 linux:
189 system:
190 ...
191 package:
192 package-name:
193 version: latest
194
195Linux with package from certail repo, version with no upgrades
196
197.. code-block:: yaml
198
199 linux:
200 system:
201 ...
202 package:
203 package-name:
204 version: 2132.323
205 repo: 'custom-repo'
206 hold: true
207
208Linux with package from certail repo, version with no GPG verification
209
210.. code-block:: yaml
211
212 linux:
213 system:
214 ...
215 package:
216 package-name:
217 version: 2132.323
218 repo: 'custom-repo'
219 verify: false
220
Bruno Binet69a9d8d2017-02-16 22:34:32 +0100221Linux with autoupdates (automatically install security package updates)
222
223.. code-block:: yaml
224
225 linux:
226 system:
227 ...
228 autoupdates:
229 enabled: true
230 mail: root@localhost
231 mail_only_on_error: true
232 remove_unused_dependencies: false
233 automatic_reboot: true
234 automatic_reboot_time: "02:00"
235
Filip Pytlounf5383a42015-10-06 16:28:32 +0200236Linux with cron jobs
Filip Pytloun91222222017-08-04 10:55:27 +0200237By default it will use name as an identifier, unless identifier key is
238explicitly set or False (then it will use Salt's default behavior which is
239identifier same as command resulting in not being able to change it)
Filip Pytlounf5383a42015-10-06 16:28:32 +0200240
241.. code-block:: yaml
242
243 linux:
244 system:
245 ...
246 job:
247 cmd1:
248 command: '/cmd/to/run'
Filip Pytloun91222222017-08-04 10:55:27 +0200249 identifier: cmd1
Filip Pytlounf5383a42015-10-06 16:28:32 +0200250 enabled: true
251 user: 'root'
252 hour: 2
253 minute: 0
254
Filip Pytlound0a29e72015-11-30 15:23:34 +0100255Linux security limits (limit sensu user memory usage to max 1GB):
256
257.. code-block:: yaml
258
259 linux:
260 system:
261 ...
262 limit:
263 sensu:
264 enabled: true
265 domain: sensu
266 limits:
267 - type: hard
268 item: as
269 value: 1000000
270
Filip Pytloun7fee0542015-10-15 11:19:24 +0200271Enable autologin on tty1 (may work only for Ubuntu 14.04):
272
273.. code-block:: yaml
274
275 linux:
276 system:
277 console:
278 tty1:
279 autologin: root
Filip Pytloun281d0202016-01-29 14:03:51 +0100280 # Enable serial console
281 ttyS0:
282 autologin: root
283 rate: 115200
284 term: xterm
Filip Pytloun7fee0542015-10-15 11:19:24 +0200285
286To disable set autologin to `false`.
287
Filip Pytloun7731b852016-02-01 11:13:47 +0100288Set ``policy-rc.d`` on Debian-based systems. Action can be any available
289command in ``while true`` loop and ``case`` context.
290Following will disallow dpkg to stop/start services for cassandra package automatically:
291
292.. code-block:: yaml
293
294 linux:
295 system:
296 policyrcd:
297 - package: cassandra
298 action: exit 101
299 - package: '*'
300 action: switch
301
Filip Pytlounc49445a2016-04-04 14:23:20 +0200302Set system locales:
303
304.. code-block:: yaml
305
306 linux:
307 system:
308 locale:
309 en_US.UTF-8:
310 default: true
Filip Pytlounee1745f2016-04-04 17:39:41 +0200311 "cs_CZ.UTF-8 UTF-8":
Filip Pytlounc49445a2016-04-04 14:23:20 +0200312 enabled: true
313
Andrey Shestakove7cca052017-05-24 23:06:24 +0300314Systemd settings:
315
316.. code-block:: yaml
317
318 linux:
319 system:
320 ...
321 systemd:
322 system:
323 Manager:
324 DefaultLimitNOFILE: 307200
325 DefaultLimitNPROC: 307200
326 user:
327 Manager:
328 DefaultLimitCPU: 2
329 DefaultLimitNPROC: 4
330
Filip Pytloun281034a2016-01-04 18:06:22 +0100331Kernel
332~~~~~~
333
334Install always up to date LTS kernel and headers from Ubuntu trusty:
335
336.. code-block:: yaml
337
338 linux:
339 system:
340 kernel:
341 type: generic
342 lts: trusty
343 headers: true
344
Tomáš Kukrálba35b212017-02-15 17:59:46 +0100345Load kernel modules and add them to `/etc/modules`:
346
347.. code-block:: yaml
348
349 linux:
350 system:
351 kernel:
352 modules:
353 - nf_conntrack
354 - tp_smapi
355 - 8021q
356
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300357Configure or blacklist kernel modules with additional options to `/etc/modprobe.d` following example
358will add `/etc/modprobe.d/nf_conntrack.conf` file with line `options nf_conntrack hashsize=262144`:
359
360.. code-block:: yaml
361
362 linux:
363 system:
364 kernel:
365 module:
366 nf_conntrack:
367 option:
368 hashsize: 262144
369
370
371
Filip Pytloun281034a2016-01-04 18:06:22 +0100372Install specific kernel version and ensure all other kernel packages are
373not present. Also install extra modules and headers for this kernel:
374
375.. code-block:: yaml
376
377 linux:
378 system:
379 kernel:
380 type: generic
381 extra: true
382 headers: true
383 version: 4.2.0-22
384
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100385Systcl kernel parameters
386
387.. code-block:: yaml
388
389 linux:
390 system:
391 kernel:
392 sysctl:
393 net.ipv4.tcp_keepalive_intvl: 3
394 net.ipv4.tcp_keepalive_time: 30
395 net.ipv4.tcp_keepalive_probes: 8
396
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100397
398CPU
399~~~
400
teoyaomiqui32b1f7c2017-05-24 14:36:09 +0300401Enable cpufreq governor for every cpu:
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100402
403.. code-block:: yaml
404
405 linux:
406 system:
407 cpu:
408 governor: performance
409
Filip Pytloun361096c2017-08-23 10:57:20 +0200410Sysfs
411~~~~~
412
413Install sysfsutils and set sysfs attributes:
414
415.. code-block:: yaml
416
417 linux:
418 system:
419 sysfs:
420 scheduler:
421 block/sda/queue/scheduler: deadline
422 power:
423 mode:
424 power/state: 0660
425 owner:
426 power/state: "root:power"
427 devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
428
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100429Huge Pages
430~~~~~~~~~~~~
431
432Huge Pages give a performance boost to applications that intensively deal
433with memory allocation/deallocation by decreasing memory fragmentation.
434
435.. code-block:: yaml
436
437 linux:
438 system:
439 kernel:
440 hugepages:
441 small:
442 size: 2M
443 count: 107520
444 mount_point: /mnt/hugepages_2MB
445 mount: false/true # default false
446 large:
447 default: true # default automatically mounted
448 size: 1G
449 count: 210
450 mount_point: /mnt/hugepages_1GB
451
452Note: not recommended to use both pagesizes in concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100453
Jakub Pavlik5398d872017-02-13 22:30:47 +0100454Intel SR-IOV
455~~~~~~~~~~~~
456
457PCI-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.
458
459.. code-block:: yaml
460
461 linux:
462 system:
463 kernel:
464 sriov: True
465 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
466 rc:
467 local: |
468 #!/bin/sh -e
469 # Enable 7 VF on eth1
470 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
471 exit 0
472
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100473Isolate CPU options
474~~~~~~~~~~~~~~~~~~~
475
476Remove the specified CPUs, as defined by the cpu_number values, from the general kernel
477SMP balancing and scheduler algroithms. The only way to move a process onto or off an
478"isolated" CPU is via the CPU affinity syscalls. cpu_number begins at 0, so the
479maximum value is 1 less than the number of CPUs on the system.
480
481.. code-block:: yaml
482
483 linux:
484 system:
485 kernel:
486 isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100487
Filip Pytlounf5383a42015-10-06 16:28:32 +0200488Repositories
489~~~~~~~~~~~~
490
491RedHat based Linux with additional OpenStack repo
492
493.. code-block:: yaml
494
495 linux:
496 system:
497 ...
498 repo:
499 rdo-icehouse:
500 enabled: true
501 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
502 pgpcheck: 0
503
504Ensure system repository to use czech Debian mirror (``default: true``)
505Also pin it's packages with priority 900.
506
507.. code-block:: yaml
508
509 linux:
510 system:
511 repo:
512 debian:
513 default: true
514 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
515 # Import signing key from URL if needed
516 key_url: "http://dummy.com/public.gpg"
517 pin:
518 - pin: 'origin "ftp.cz.debian.org"'
519 priority: 900
520 package: '*'
521
Petr Michalec10462bb2017-03-23 19:18:08 +0100522
523Package manager proxy setup globally:
524
525.. code-block:: yaml
526
527 linux:
528 system:
529 ...
530 repo:
531 apt-mk:
532 source: "deb http://apt-mk.mirantis.com/ stable main salt"
533 ...
534 proxy:
535 pkg:
536 enabled: true
537 ftp: ftp://ftp-proxy-for-apt.host.local:2121
538 ...
539 # NOTE: Global defaults for any other componet that configure proxy on the system.
540 # If your environment has just one simple proxy, set it on linux:system:proxy.
541 #
542 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
543 # as for https and http
544 ftp: ftp://proxy.host.local:2121
545 http: http://proxy.host.local:3142
546 https: https://proxy.host.local:3143
547
548Package manager proxy setup per repository:
549
550.. code-block:: yaml
551
552 linux:
553 system:
554 ...
555 repo:
556 debian:
557 source: "deb http://apt-mk.mirantis.com/ stable main salt"
558 ...
559 apt-mk:
560 source: "deb http://apt-mk.mirantis.com/ stable main salt"
561 # per repository proxy
562 proxy:
563 enabled: true
564 http: http://maas-01:8080
565 https: http://maas-01:8080
566 ...
567 proxy:
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600568 # package manager fallback defaults
Petr Michalec10462bb2017-03-23 19:18:08 +0100569 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
570 pkg:
571 enabled: true
572 ftp: ftp://proxy.host.local:2121
573 #http: http://proxy.host.local:3142
574 #https: https://proxy.host.local:3143
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600575 ...
Petr Michalec10462bb2017-03-23 19:18:08 +0100576 # global system fallback system defaults
577 ftp: ftp://proxy.host.local:2121
578 http: http://proxy.host.local:3142
579 https: https://proxy.host.local:3143
580
581
Jiri Broulik34a29b42017-04-25 14:42:54 +0200582Remove all repositories:
583
584.. code-block:: yaml
585
586 linux:
587 system:
588 purge_repos: true
589
590
Petr Michalec10462bb2017-03-23 19:18:08 +0100591RC
592~~
593
Jakub Pavlik78859382016-01-21 11:26:39 +0100594rc.local example
595
596.. code-block:: yaml
597
598 linux:
599 system:
600 rc:
601 local: |
602 #!/bin/sh -e
603 #
604 # rc.local
605 #
606 # This script is executed at the end of each multiuser runlevel.
607 # Make sure that the script will "exit 0" on success or any other
608 # value on error.
609 #
610 # In order to enable or disable this script just change the execution
611 # bits.
612 #
613 # By default this script does nothing.
614 exit 0
615
Petr Michalec10462bb2017-03-23 19:18:08 +0100616
Filip Pytloun1f40dac2016-01-22 15:52:57 +0100617Prompt
618~~~~~~
619
620Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
621user can have different prompt.
622
623.. code-block:: yaml
624
625 linux:
626 system:
627 prompt:
628 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\\]
629 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
630
631On Debian systems to set prompt system-wide it's necessary to remove setting
632PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
633``/etc/skel/.bashrc``). This formula will do this automatically, but will not
Filip Pytlound9b68da2016-01-22 15:58:41 +0100634touch existing user's ``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +0100635
Filip Pytlouneef11c12016-03-25 11:00:23 +0100636Bash
637~~~~
638
639Fix bash configuration to preserve history across sessions (like ZSH does by
640default).
641
642.. code-block:: yaml
643
644 linux:
645 system:
646 bash:
647 preserve_history: true
648
Filip Pytloune874dfb2016-01-22 16:57:34 +0100649Message of the day
650~~~~~~~~~~~~~~~~~~
651
652``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
653day. Setting custom motd will cleanup existing ones.
654
655.. code-block:: yaml
656
657 linux:
658 system:
659 motd:
660 - release: |
661 #!/bin/sh
662 [ -r /etc/lsb-release ] && . /etc/lsb-release
663
664 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
665 # Fall back to using the very slow lsb_release utility
666 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
667 fi
668
669 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
670 - warning: |
671 #!/bin/sh
672 printf "This is [company name] network.\n"
673 printf "Unauthorized access strictly prohibited.\n"
674
Marek Celoud713e9072017-05-18 15:20:25 +0200675Services
676~~~~~~~~
677
678Stop and disable linux service:
679
680.. code-block:: yaml
681
682 linux:
683 system:
684 service:
685 apt-daily.timer:
686 status: dead
687
688Possible status is dead (disable service by default), running (enable service by default), enabled, disabled.
689
Filip Pytloun2f70b492016-02-19 15:55:25 +0100690RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +0100691^^^^^^^^^^^^^
Filip Pytloun2f70b492016-02-19 15:55:25 +0100692
693Unfortunately ``update-motd`` is currently not available for RHEL so there's
694no native support for dynamic motd.
695You can still set static one, only pillar structure differs:
696
697.. code-block:: yaml
698
699 linux:
700 system:
701 motd: |
702 This is [company name] network.
703 Unauthorized access strictly prohibited.
704
Filip Pytloun8296bb92016-02-19 18:42:09 +0100705Haveged
706~~~~~~~
707
708If you are running headless server and are low on entropy, it may be a good
709idea to setup Haveged.
710
711.. code-block:: yaml
712
713 linux:
714 system:
715 haveged:
716 enabled: true
717
Filip Pytlounf5383a42015-10-06 16:28:32 +0200718Linux network
719-------------
720
721Linux with network manager
722
723.. code-block:: yaml
724
725 linux:
726 network:
727 enabled: true
728 network_manager: true
729
730Linux with default static network interfaces, default gateway interface and DNS servers
731
732.. code-block:: yaml
733
734 linux:
735 network:
736 enabled: true
737 interface:
738 eth0:
739 enabled: true
740 type: eth
741 address: 192.168.0.102
742 netmask: 255.255.255.0
743 gateway: 192.168.0.1
744 name_servers:
745 - 8.8.8.8
746 - 8.8.4.4
747 mtu: 1500
748
jan kaufman6d30adf2016-01-18 17:30:12 +0100749Linux with bonded interfaces and disabled NetworkManager
Filip Pytlounf5383a42015-10-06 16:28:32 +0200750
751.. code-block:: yaml
752
753 linux:
754 network:
755 enabled: true
756 interface:
757 eth0:
758 type: eth
759 ...
760 eth1:
761 type: eth
762 ...
763 bond0:
764 enabled: true
765 type: bond
766 address: 192.168.0.102
767 netmask: 255.255.255.0
768 mtu: 1500
769 use_in:
770 - interface: ${linux:interface:eth0}
771 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +0100772 network_manager:
773 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200774
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100775Linux with vlan interface_params
776
777.. code-block:: yaml
778
779 linux:
780 network:
781 enabled: true
782 interface:
783 vlan69:
784 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +0100785 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100786 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100787
Filip Pytlounf5383a42015-10-06 16:28:32 +0200788Linux with wireless interface parameters
789
790.. code-block:: yaml
791
792 linux:
793 network:
794 enabled: true
795 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100796 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200797 interface:
798 wlan0:
799 type: eth
800 wireless:
801 essid: example
802 key: example_key
803 security: wpa
804 priority: 1
805
806Linux networks with routes defined
807
808.. code-block:: yaml
809
810 linux:
811 network:
812 enabled: true
813 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100814 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200815 interface:
816 eth0:
817 type: eth
818 route:
819 default:
820 address: 192.168.0.123
821 netmask: 255.255.255.0
822 gateway: 192.168.0.1
823
824Native Linux Bridges
825
826.. code-block:: yaml
827
828 linux:
829 network:
830 interface:
831 eth1:
832 enabled: true
833 type: eth
834 proto: manual
835 up_cmds:
836 - ip address add 0/0 dev $IFACE
837 - ip link set $IFACE up
838 down_cmds:
839 - ip link set $IFACE down
840 br-ex:
841 enabled: true
842 type: bridge
843 address: ${linux:network:host:public_local:address}
844 netmask: 255.255.255.0
845 use_interfaces:
846 - eth1
847
848OpenVswitch Bridges
849
850.. code-block:: yaml
851
852 linux:
853 network:
854 bridge: openvswitch
855 interface:
856 eth1:
857 enabled: true
858 type: eth
859 proto: manual
860 up_cmds:
861 - ip address add 0/0 dev $IFACE
862 - ip link set $IFACE up
863 down_cmds:
864 - ip link set $IFACE down
865 br-ex:
866 enabled: true
867 type: bridge
868 address: ${linux:network:host:public_local:address}
869 netmask: 255.255.255.0
870 use_interfaces:
871 - eth1
872
Petr Jediný8f8ae542017-07-13 16:19:12 +0200873Debian manual proto interfaces
874
875When you are changing interface proto from static in up state to manual, you
876may need to flush ip addresses. For example, if you want to use the interface
877and the ip on the bridge. This can be done by setting the ``ipflush_onchange``
878to true.
879
880.. code-block:: yaml
881
882 linux:
883 network:
884 interface:
885 eth1:
886 enabled: true
887 type: eth
888 proto: manual
889 mtu: 9100
890 ipflush_onchange: true
891
892
Petr Jedinýd577cb52017-06-28 20:17:49 +0200893Concatinating and removing interface files
894
895Debian based distributions have `/etc/network/interfaces.d/` directory, where
896you can store configuration of network interfaces in separate files. You can
897concatinate the files to the defined destination when needed, this operation
898removes the file from the `/etc/network/interfaces.d/`. If you just need to
899remove iface files, you can use the `remove_iface_files` key.
900
901.. code-block:: yaml
902
903 linux:
904 network:
905 concat_iface_files:
906 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
907 dst: '/etc/network/interfaces'
908 remove_iface_files:
909 - '/etc/network/interfaces.d/90-custom.cfg'
910
911
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600912DHCP client configuration
913
914None of the keys is mandatory, include only those you really need. For full list
915of available options under send, supersede, prepend, append refer to dhcp-options(5)
916
917.. code-block:: yaml
918
919 linux:
920 network:
921 dhclient:
922 enabled: true
923 backoff_cutoff: 15
924 initial_interval: 10
925 reboot: 10
926 retry: 60
927 select_timeout: 0
928 timeout: 120
929 send:
930 - option: host-name
931 declaration: "= gethostname()"
932 supersede:
933 - option: host-name
934 declaration: "spaceship"
935 - option: domain-name
936 declaration: "domain.home"
937 #- option: arp-cache-timeout
938 # declaration: 20
939 prepend:
940 - option: domain-name-servers
941 declaration:
942 - 8.8.8.8
943 - 8.8.4.4
944 - option: domain-search
945 declaration:
946 - example.com
947 - eng.example.com
948 #append:
949 #- option: domain-name-servers
950 # declaration: 127.0.0.1
951 # ip or subnet to reject dhcp offer from
952 reject:
953 - 192.33.137.209
954 - 10.0.2.0/24
955 request:
956 - subnet-mask
957 - broadcast-address
958 - time-offset
959 - routers
960 - domain-name
961 - domain-name-servers
962 - domain-search
963 - host-name
964 - dhcp6.name-servers
965 - dhcp6.domain-search
966 - dhcp6.fqdn
967 - dhcp6.sntp-servers
968 - netbios-name-servers
969 - netbios-scope
970 - interface-mtu
971 - rfc3442-classless-static-routes
972 - ntp-servers
973 require:
974 - subnet-mask
975 - domain-name-servers
976 # if per interface configuration required add below
977 interface:
978 ens2:
979 initial_interval: 11
980 reject:
981 - 192.33.137.210
982 ens3:
983 initial_interval: 12
984 reject:
985 - 192.33.137.211
986
987
Petr Michalec10462bb2017-03-23 19:18:08 +0100988Configure global environment variables
Petr Michalec10462bb2017-03-23 19:18:08 +0100989
Ales Komarek417e8c52017-08-25 15:10:29 +0200990Use ``/etc/environment`` for static system wide variable assignment after
991boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +0200992
993.. code-block:: yaml
994
995 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +0100996 system:
997 env:
998 BOB_VARIABLE: Alice
999 ...
1000 BOB_PATH:
1001 - /srv/alice/bin
1002 - /srv/bob/bin
1003 ...
1004 ftp_proxy: none
1005 http_proxy: http://global-http-proxy.host.local:8080
1006 https_proxy: ${linux:system:proxy:https}
1007 no_proxy:
1008 - 192.168.0.80
1009 - 192.168.1.80
1010 - .domain.com
1011 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +02001012 ...
Petr Michalec10462bb2017-03-23 19:18:08 +01001013 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +02001014 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +01001015 ftp: ftp://proxy.host.local:2121
1016 http: http://proxy.host.local:3142
1017 https: https://proxy.host.local:3143
1018 noproxy:
1019 - .domain.com
1020 - .local
1021
1022Configure profile.d scripts
Petr Michalec10462bb2017-03-23 19:18:08 +01001023
Ales Komarek417e8c52017-08-25 15:10:29 +02001024The profile.d scripts are being sourced during .sh execution and support
1025variable expansion in opposite to /etc/environment global settings in
1026``/etc/environment``.
Petr Michalec10462bb2017-03-23 19:18:08 +01001027
1028.. code-block:: yaml
1029
1030 linux:
1031 system:
1032 profile:
1033 locales: |
1034 export LANG=C
1035 export LC_ALL=C
1036 ...
1037 vi_flavors.sh: |
1038 export PAGER=view
1039 export EDITOR=vim
1040 alias vi=vim
1041 shell_locales.sh: |
1042 export LANG=en_US
1043 export LC_ALL=en_US.UTF-8
1044 shell_proxies.sh: |
1045 export FTP_PROXY=ftp://127.0.3.3:2121
1046 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001047
1048Linux with hosts
1049
Filip Pytloun86506fe2017-01-26 14:36:16 +01001050Parameter purge_hosts will enforce whole /etc/hosts file, removing entries
1051that are not defined in model except defaults for both IPv4 and IPv6 localhost
1052and hostname + fqdn.
Ales Komarek417e8c52017-08-25 15:10:29 +02001053
Filip Pytloun86506fe2017-01-26 14:36:16 +01001054It's good to use this option if you want to ensure /etc/hosts is always in a
1055clean state however it's not enabled by default for safety.
1056
Filip Pytlounf5383a42015-10-06 16:28:32 +02001057.. code-block:: yaml
1058
1059 linux:
1060 network:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001061 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001062 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001063 # No need to define this one if purge_hosts is true
1064 hostname:
1065 address: 127.0.1.1
1066 names:
1067 - ${linux:network:fqdn}
1068 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001069 node1:
1070 address: 192.168.10.200
1071 names:
1072 - node2.domain.com
1073 - service2.domain.com
1074 node2:
1075 address: 192.168.10.201
1076 names:
1077 - node2.domain.com
1078 - service2.domain.com
1079
Ales Komarek417e8c52017-08-25 15:10:29 +02001080Linux with hosts collected from mine
1081
1082In this case all dns records defined within infrastrucuture will be passed to
1083local hosts records or any DNS server. Only hosts with `grain` parameter to
1084true will be propagated to the mine.
1085
1086.. code-block:: yaml
1087
1088 linux:
1089 network:
1090 purge_hosts: true
1091 mine_dns_records: true
1092 host:
1093 node1:
1094 address: 192.168.10.200
1095 grain: true
1096 names:
1097 - node2.domain.com
1098 - service2.domain.com
Filip Pytloun86506fe2017-01-26 14:36:16 +01001099
Filip Pytlounde9bea52016-01-11 15:39:10 +01001100Setup resolv.conf, nameservers, domain and search domains
1101
1102.. code-block:: yaml
1103
1104 linux:
1105 network:
1106 resolv:
1107 dns:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001108 - 8.8.4.4
1109 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01001110 domain: my.example.com
1111 search:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001112 - my.example.com
1113 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01001114 options:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001115 - ndots: 5
1116 - timeout: 2
1117 - attempts: 2
Filip Pytlounde9bea52016-01-11 15:39:10 +01001118
Ales Komarek417e8c52017-08-25 15:10:29 +02001119setting custom TX queue length for tap interfaces
Andrii Petrenko735761d2017-03-21 17:17:35 -07001120
1121.. code-block:: yaml
1122
1123 linux:
1124 network:
1125 tap_custom_txqueuelen: 10000
1126
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001127DPDK OVS interfaces
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001128
1129**DPDK OVS NIC**
1130
1131.. code-block:: yaml
1132
1133 linux:
1134 network:
1135 bridge: openvswitch
1136 dpdk:
1137 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001138 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001139 openvswitch:
1140 pmd_cpu_mask: "0x6"
1141 dpdk_socket_mem: "1024,1024"
1142 dpdk_lcore_mask: "0x400"
1143 memory_channels: 2
1144 interface:
1145 dpkd0:
1146 name: ${_param:dpdk_nic}
1147 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001148 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001149 enabled: true
1150 type: dpdk_ovs_port
1151 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001152 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001153 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01001154 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001155 br-prv:
1156 enabled: true
1157 type: dpdk_ovs_bridge
1158
1159**DPDK OVS Bond**
1160
1161.. code-block:: yaml
1162
1163 linux:
1164 network:
1165 bridge: openvswitch
1166 dpdk:
1167 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001168 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001169 openvswitch:
1170 pmd_cpu_mask: "0x6"
1171 dpdk_socket_mem: "1024,1024"
1172 dpdk_lcore_mask: "0x400"
1173 memory_channels: 2
1174 interface:
1175 dpdk_second_nic:
1176 name: ${_param:primary_second_nic}
1177 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001178 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001179 bond: dpdkbond0
1180 enabled: true
1181 type: dpdk_ovs_port
1182 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001183 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001184 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001185 dpdk_first_nic:
1186 name: ${_param:primary_first_nic}
1187 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001188 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001189 bond: dpdkbond0
1190 enabled: true
1191 type: dpdk_ovs_port
1192 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001193 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001194 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001195 dpdkbond0:
1196 enabled: true
1197 bridge: br-prv
1198 type: dpdk_ovs_bond
1199 mode: active-backup
1200 br-prv:
1201 enabled: true
1202 type: dpdk_ovs_bridge
1203
Jakub Pavlikaa759062017-03-13 15:57:26 +01001204**DPDK OVS bridge for VXLAN**
1205
1206If VXLAN is used as tenant segmentation then ip address must be set on br-prv
1207
1208.. code-block:: yaml
1209
1210 linux:
1211 network:
1212 ...
1213 interface:
1214 br-prv:
1215 enabled: true
1216 type: dpdk_ovs_bridge
1217 address: 192.168.50.0
1218 netmask: 255.255.255.0
1219 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001220
1221Linux storage
1222-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02001223
1224Linux with mounted Samba
1225
1226.. code-block:: yaml
1227
1228 linux:
1229 storage:
1230 enabled: true
1231 mount:
1232 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01001233 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001234 - path: /media/myuser/public/
1235 - device: //192.168.0.1/storage
1236 - file_system: cifs
1237 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
1238
Jiri Broulikb017f932017-03-31 13:55:36 +02001239NFS mount
1240
1241.. code-block:: yaml
1242
1243 linux:
1244 storage:
1245 enabled: true
1246 mount:
1247 nfs_glance:
1248 enabled: true
1249 path: /var/lib/glance/images
1250 device: 172.16.10.110:/var/nfs/glance
1251 file_system: nfs
1252 opts: rw,sync
1253
1254
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001255File swap configuration
Filip Pytlounf5383a42015-10-06 16:28:32 +02001256
1257.. code-block:: yaml
1258
1259 linux:
1260 storage:
1261 enabled: true
1262 swap:
1263 file:
1264 enabled: true
1265 engine: file
1266 device: /swapfile
1267 size: 1024
1268
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001269Partition swap configuration
Lachlan Evenson30676512016-01-22 15:43:28 -08001270
1271.. code-block:: yaml
1272
1273 linux:
1274 storage:
1275 enabled: true
1276 swap:
1277 partition:
1278 enabled: true
1279 engine: partition
1280 device: /dev/vg0/swap
1281
Filip Pytlounc8a001a2015-12-15 14:09:19 +01001282LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
1283
1284.. code-block:: yaml
1285
1286 parameters:
1287 linux:
1288 storage:
1289 mount:
1290 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01001291 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01001292 device: /dev/vg1/data
1293 file_system: ext4
1294 path: /mnt/data
1295 lvm:
1296 vg1:
1297 enabled: true
1298 devices:
1299 - /dev/sdb
1300 volume:
1301 data:
1302 size: 40G
1303 mount: ${linux:storage:mount:data}
1304
Jakub Pavlik4f742142017-08-08 15:05:50 +02001305Create partitions on disk. Specify size in MB. It expects empty
1306disk without any existing partitions.
1307
1308.. code-block:: yaml
1309
1310 linux:
1311 storage:
1312 disk:
1313 first_drive:
1314 name: /dev/loop1
1315 type: gpt
1316 partitions:
1317 - size: 200 #size in MB
1318 type: fat32
1319 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02001320 mkfs: True
1321 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02001322 /dev/vda1:
1323 partitions:
1324 - size: 5
1325 type: ext2
1326 - size: 10
1327 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02001328
1329Multipath with Fujitsu Eternus DXL
1330
1331.. code-block:: yaml
1332
1333 parameters:
1334 linux:
1335 storage:
1336 multipath:
1337 enabled: true
1338 blacklist_devices:
1339 - /dev/sda
1340 - /dev/sdb
1341 backends:
1342 - fujitsu_eternus_dxl
1343
1344Multipath with Hitachi VSP 1000
1345
1346.. code-block:: yaml
1347
1348 parameters:
1349 linux:
1350 storage:
1351 multipath:
1352 enabled: true
1353 blacklist_devices:
1354 - /dev/sda
1355 - /dev/sdb
1356 backends:
1357 - hitachi_vsp1000
1358
1359Multipath with IBM Storwize
1360
1361.. code-block:: yaml
1362
1363 parameters:
1364 linux:
1365 storage:
1366 multipath:
1367 enabled: true
1368 blacklist_devices:
1369 - /dev/sda
1370 - /dev/sdb
1371 backends:
1372 - ibm_storwize
1373
1374Multipath with multiple backends
1375
1376.. code-block:: yaml
1377
1378 parameters:
1379 linux:
1380 storage:
1381 multipath:
1382 enabled: true
1383 blacklist_devices:
1384 - /dev/sda
1385 - /dev/sdb
1386 - /dev/sdc
1387 - /dev/sdd
1388 backends:
1389 - ibm_storwize
1390 - fujitsu_eternus_dxl
1391 - hitachi_vsp1000
1392
1393Disabled multipath (the default setup)
1394
1395.. code-block:: yaml
1396
1397 parameters:
1398 linux:
1399 storage:
1400 multipath:
1401 enabled: false
1402
Simon Pasquier375001e2017-01-26 13:22:33 +01001403Linux with local loopback device
1404
1405.. code-block:: yaml
1406
1407 linux:
1408 storage:
1409 loopback:
1410 disk1:
1411 file: /srv/disk1
1412 size: 50G
1413
Filip Pytlounb2c8f852016-11-21 17:03:43 +01001414External config generation
1415--------------------------
1416
1417You are able to use config support metadata between formulas and only generate
1418config files for external use, eg. docker, etc.
1419
1420.. code-block:: yaml
1421
1422 parameters:
1423 linux:
1424 system:
1425 config:
1426 pillar:
1427 jenkins:
1428 master:
1429 home: /srv/volumes/jenkins
1430 approved_scripts:
1431 - method java.net.URL openConnection
1432 credentials:
1433 - type: username_password
1434 scope: global
1435 id: test
1436 desc: Testing credentials
1437 username: test
1438 password: test
1439
Vladimir Ereminccf28842017-04-10 23:52:10 +03001440Netconsole Remote Kernel Logging
1441--------------------------------
1442
1443Netconsole logger could be configured for configfs-enabled kernels
1444(`CONFIG_NETCONSOLE_DYNAMIC` should be enabled). Configuration applies both in
1445runtime (if network is already configured), and on-boot after interface
1446initialization. Notes:
1447
1448 * receiver could be located only in same L3 domain
1449 (or you need to configure gateway MAC manually)
1450 * receiver's MAC is detected only on configuration time
1451 * using broadcast MAC is not recommended
1452
1453.. code-block:: yaml
1454
1455 parameters:
1456 linux:
1457 system:
1458 netconsole:
1459 enabled: true
1460 port: 514 (optional)
1461 loglevel: debug (optional)
1462 target:
1463 192.168.0.1:
1464 interface: bond0
1465 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02001466
Filip Pytlounf5383a42015-10-06 16:28:32 +02001467Usage
1468=====
1469
1470Set mtu of network interface eth0 to 1400
1471
1472.. code-block:: bash
1473
1474 ip link set dev eth0 mtu 1400
1475
1476Read more
1477=========
1478
1479* https://www.archlinux.org/
1480* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu
Filip Pytloun018f8712017-02-02 13:02:03 +01001481
1482Documentation and Bugs
1483======================
1484
1485To learn how to install and update salt-formulas, consult the documentation
1486available online at:
1487
1488 http://salt-formulas.readthedocs.io/
1489
1490In the unfortunate event that bugs are discovered, they should be reported to
1491the appropriate issue tracker. Use Github issue tracker for specific salt
1492formula:
1493
1494 https://github.com/salt-formulas/salt-formula-linux/issues
1495
1496For feature requests, bug reports or blueprints affecting entire ecosystem,
1497use Launchpad salt-formulas project:
1498
1499 https://launchpad.net/salt-formulas
1500
1501You can also join salt-formulas-users team and subscribe to mailing list:
1502
1503 https://launchpad.net/~salt-formulas-users
1504
1505Developers wishing to work on the salt-formulas projects should always base
1506their work on master branch and submit pull request against specific formula.
1507
1508 https://github.com/salt-formulas/salt-formula-linux
1509
1510Any questions or feedback is always welcome so feel free to join our IRC
1511channel:
1512
1513 #salt-formulas @ irc.freenode.net