blob: 9e1692b8910bde1158c46b74125c920e7115c2a6 [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
Jakub Pavlikb148c8c2017-02-12 21:30:48 +0100410Huge Pages
411~~~~~~~~~~~~
412
413Huge Pages give a performance boost to applications that intensively deal
414with memory allocation/deallocation by decreasing memory fragmentation.
415
416.. code-block:: yaml
417
418 linux:
419 system:
420 kernel:
421 hugepages:
422 small:
423 size: 2M
424 count: 107520
425 mount_point: /mnt/hugepages_2MB
426 mount: false/true # default false
427 large:
428 default: true # default automatically mounted
429 size: 1G
430 count: 210
431 mount_point: /mnt/hugepages_1GB
432
433Note: not recommended to use both pagesizes in concurrently.
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100434
Jakub Pavlik5398d872017-02-13 22:30:47 +0100435Intel SR-IOV
436~~~~~~~~~~~~
437
438PCI-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.
439
440.. code-block:: yaml
441
442 linux:
443 system:
444 kernel:
445 sriov: True
446 unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
447 rc:
448 local: |
449 #!/bin/sh -e
450 # Enable 7 VF on eth1
451 echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
452 exit 0
453
Jakub Pavlik6c9ead12017-02-16 21:53:13 +0100454Isolate CPU options
455~~~~~~~~~~~~~~~~~~~
456
457Remove the specified CPUs, as defined by the cpu_number values, from the general kernel
458SMP balancing and scheduler algroithms. The only way to move a process onto or off an
459"isolated" CPU is via the CPU affinity syscalls. cpu_number begins at 0, so the
460maximum value is 1 less than the number of CPUs on the system.
461
462.. code-block:: yaml
463
464 linux:
465 system:
466 kernel:
467 isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
Jiri Broulikf8f55a22017-01-26 14:36:46 +0100468
Filip Pytlounf5383a42015-10-06 16:28:32 +0200469Repositories
470~~~~~~~~~~~~
471
472RedHat based Linux with additional OpenStack repo
473
474.. code-block:: yaml
475
476 linux:
477 system:
478 ...
479 repo:
480 rdo-icehouse:
481 enabled: true
482 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
483 pgpcheck: 0
484
485Ensure system repository to use czech Debian mirror (``default: true``)
486Also pin it's packages with priority 900.
487
488.. code-block:: yaml
489
490 linux:
491 system:
492 repo:
493 debian:
494 default: true
495 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
496 # Import signing key from URL if needed
497 key_url: "http://dummy.com/public.gpg"
498 pin:
499 - pin: 'origin "ftp.cz.debian.org"'
500 priority: 900
501 package: '*'
502
Petr Michalec10462bb2017-03-23 19:18:08 +0100503
504Package manager proxy setup globally:
505
506.. code-block:: yaml
507
508 linux:
509 system:
510 ...
511 repo:
512 apt-mk:
513 source: "deb http://apt-mk.mirantis.com/ stable main salt"
514 ...
515 proxy:
516 pkg:
517 enabled: true
518 ftp: ftp://ftp-proxy-for-apt.host.local:2121
519 ...
520 # NOTE: Global defaults for any other componet that configure proxy on the system.
521 # If your environment has just one simple proxy, set it on linux:system:proxy.
522 #
523 # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
524 # as for https and http
525 ftp: ftp://proxy.host.local:2121
526 http: http://proxy.host.local:3142
527 https: https://proxy.host.local:3143
528
529Package manager proxy setup per repository:
530
531.. code-block:: yaml
532
533 linux:
534 system:
535 ...
536 repo:
537 debian:
538 source: "deb http://apt-mk.mirantis.com/ stable main salt"
539 ...
540 apt-mk:
541 source: "deb http://apt-mk.mirantis.com/ stable main salt"
542 # per repository proxy
543 proxy:
544 enabled: true
545 http: http://maas-01:8080
546 https: http://maas-01:8080
547 ...
548 proxy:
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600549 # package manager fallback defaults
Petr Michalec10462bb2017-03-23 19:18:08 +0100550 # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
551 pkg:
552 enabled: true
553 ftp: ftp://proxy.host.local:2121
554 #http: http://proxy.host.local:3142
555 #https: https://proxy.host.local:3143
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600556 ...
Petr Michalec10462bb2017-03-23 19:18:08 +0100557 # global system fallback system defaults
558 ftp: ftp://proxy.host.local:2121
559 http: http://proxy.host.local:3142
560 https: https://proxy.host.local:3143
561
562
Jiri Broulik34a29b42017-04-25 14:42:54 +0200563Remove all repositories:
564
565.. code-block:: yaml
566
567 linux:
568 system:
569 purge_repos: true
570
571
Petr Michalec10462bb2017-03-23 19:18:08 +0100572RC
573~~
574
Jakub Pavlik78859382016-01-21 11:26:39 +0100575rc.local example
576
577.. code-block:: yaml
578
579 linux:
580 system:
581 rc:
582 local: |
583 #!/bin/sh -e
584 #
585 # rc.local
586 #
587 # This script is executed at the end of each multiuser runlevel.
588 # Make sure that the script will "exit 0" on success or any other
589 # value on error.
590 #
591 # In order to enable or disable this script just change the execution
592 # bits.
593 #
594 # By default this script does nothing.
595 exit 0
596
Petr Michalec10462bb2017-03-23 19:18:08 +0100597
Filip Pytloun1f40dac2016-01-22 15:52:57 +0100598Prompt
599~~~~~~
600
601Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
602user can have different prompt.
603
604.. code-block:: yaml
605
606 linux:
607 system:
608 prompt:
609 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\\]
610 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
611
612On Debian systems to set prompt system-wide it's necessary to remove setting
613PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
614``/etc/skel/.bashrc``). This formula will do this automatically, but will not
Filip Pytlound9b68da2016-01-22 15:58:41 +0100615touch existing user's ``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +0100616
Filip Pytlouneef11c12016-03-25 11:00:23 +0100617Bash
618~~~~
619
620Fix bash configuration to preserve history across sessions (like ZSH does by
621default).
622
623.. code-block:: yaml
624
625 linux:
626 system:
627 bash:
628 preserve_history: true
629
Filip Pytloune874dfb2016-01-22 16:57:34 +0100630Message of the day
631~~~~~~~~~~~~~~~~~~
632
633``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
634day. Setting custom motd will cleanup existing ones.
635
636.. code-block:: yaml
637
638 linux:
639 system:
640 motd:
641 - release: |
642 #!/bin/sh
643 [ -r /etc/lsb-release ] && . /etc/lsb-release
644
645 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
646 # Fall back to using the very slow lsb_release utility
647 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
648 fi
649
650 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
651 - warning: |
652 #!/bin/sh
653 printf "This is [company name] network.\n"
654 printf "Unauthorized access strictly prohibited.\n"
655
Marek Celoud713e9072017-05-18 15:20:25 +0200656Services
657~~~~~~~~
658
659Stop and disable linux service:
660
661.. code-block:: yaml
662
663 linux:
664 system:
665 service:
666 apt-daily.timer:
667 status: dead
668
669Possible status is dead (disable service by default), running (enable service by default), enabled, disabled.
670
Filip Pytloun2f70b492016-02-19 15:55:25 +0100671RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +0100672^^^^^^^^^^^^^
Filip Pytloun2f70b492016-02-19 15:55:25 +0100673
674Unfortunately ``update-motd`` is currently not available for RHEL so there's
675no native support for dynamic motd.
676You can still set static one, only pillar structure differs:
677
678.. code-block:: yaml
679
680 linux:
681 system:
682 motd: |
683 This is [company name] network.
684 Unauthorized access strictly prohibited.
685
Filip Pytloun8296bb92016-02-19 18:42:09 +0100686Haveged
687~~~~~~~
688
689If you are running headless server and are low on entropy, it may be a good
690idea to setup Haveged.
691
692.. code-block:: yaml
693
694 linux:
695 system:
696 haveged:
697 enabled: true
698
Filip Pytlounf5383a42015-10-06 16:28:32 +0200699Linux network
700-------------
701
702Linux with network manager
703
704.. code-block:: yaml
705
706 linux:
707 network:
708 enabled: true
709 network_manager: true
710
711Linux with default static network interfaces, default gateway interface and DNS servers
712
713.. code-block:: yaml
714
715 linux:
716 network:
717 enabled: true
718 interface:
719 eth0:
720 enabled: true
721 type: eth
722 address: 192.168.0.102
723 netmask: 255.255.255.0
724 gateway: 192.168.0.1
725 name_servers:
726 - 8.8.8.8
727 - 8.8.4.4
728 mtu: 1500
729
jan kaufman6d30adf2016-01-18 17:30:12 +0100730Linux with bonded interfaces and disabled NetworkManager
Filip Pytlounf5383a42015-10-06 16:28:32 +0200731
732.. code-block:: yaml
733
734 linux:
735 network:
736 enabled: true
737 interface:
738 eth0:
739 type: eth
740 ...
741 eth1:
742 type: eth
743 ...
744 bond0:
745 enabled: true
746 type: bond
747 address: 192.168.0.102
748 netmask: 255.255.255.0
749 mtu: 1500
750 use_in:
751 - interface: ${linux:interface:eth0}
752 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +0100753 network_manager:
754 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200755
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100756Linux with vlan interface_params
757
758.. code-block:: yaml
759
760 linux:
761 network:
762 enabled: true
763 interface:
764 vlan69:
765 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +0100766 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100767 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100768
Filip Pytlounf5383a42015-10-06 16:28:32 +0200769Linux with wireless interface parameters
770
771.. code-block:: yaml
772
773 linux:
774 network:
775 enabled: true
776 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100777 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200778 interface:
779 wlan0:
780 type: eth
781 wireless:
782 essid: example
783 key: example_key
784 security: wpa
785 priority: 1
786
787Linux networks with routes defined
788
789.. code-block:: yaml
790
791 linux:
792 network:
793 enabled: true
794 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100795 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200796 interface:
797 eth0:
798 type: eth
799 route:
800 default:
801 address: 192.168.0.123
802 netmask: 255.255.255.0
803 gateway: 192.168.0.1
804
805Native Linux Bridges
806
807.. code-block:: yaml
808
809 linux:
810 network:
811 interface:
812 eth1:
813 enabled: true
814 type: eth
815 proto: manual
816 up_cmds:
817 - ip address add 0/0 dev $IFACE
818 - ip link set $IFACE up
819 down_cmds:
820 - ip link set $IFACE down
821 br-ex:
822 enabled: true
823 type: bridge
824 address: ${linux:network:host:public_local:address}
825 netmask: 255.255.255.0
826 use_interfaces:
827 - eth1
828
829OpenVswitch Bridges
830
831.. code-block:: yaml
832
833 linux:
834 network:
835 bridge: openvswitch
836 interface:
837 eth1:
838 enabled: true
839 type: eth
840 proto: manual
841 up_cmds:
842 - ip address add 0/0 dev $IFACE
843 - ip link set $IFACE up
844 down_cmds:
845 - ip link set $IFACE down
846 br-ex:
847 enabled: true
848 type: bridge
849 address: ${linux:network:host:public_local:address}
850 netmask: 255.255.255.0
851 use_interfaces:
852 - eth1
853
Petr Jediný8f8ae542017-07-13 16:19:12 +0200854Debian manual proto interfaces
855
856When you are changing interface proto from static in up state to manual, you
857may need to flush ip addresses. For example, if you want to use the interface
858and the ip on the bridge. This can be done by setting the ``ipflush_onchange``
859to true.
860
861.. code-block:: yaml
862
863 linux:
864 network:
865 interface:
866 eth1:
867 enabled: true
868 type: eth
869 proto: manual
870 mtu: 9100
871 ipflush_onchange: true
872
873
Petr Jedinýd577cb52017-06-28 20:17:49 +0200874Concatinating and removing interface files
875
876Debian based distributions have `/etc/network/interfaces.d/` directory, where
877you can store configuration of network interfaces in separate files. You can
878concatinate the files to the defined destination when needed, this operation
879removes the file from the `/etc/network/interfaces.d/`. If you just need to
880remove iface files, you can use the `remove_iface_files` key.
881
882.. code-block:: yaml
883
884 linux:
885 network:
886 concat_iface_files:
887 - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
888 dst: '/etc/network/interfaces'
889 remove_iface_files:
890 - '/etc/network/interfaces.d/90-custom.cfg'
891
892
Oleksandr Vlasov27a6c3a2017-04-11 16:01:19 -0600893DHCP client configuration
894
895None of the keys is mandatory, include only those you really need. For full list
896of available options under send, supersede, prepend, append refer to dhcp-options(5)
897
898.. code-block:: yaml
899
900 linux:
901 network:
902 dhclient:
903 enabled: true
904 backoff_cutoff: 15
905 initial_interval: 10
906 reboot: 10
907 retry: 60
908 select_timeout: 0
909 timeout: 120
910 send:
911 - option: host-name
912 declaration: "= gethostname()"
913 supersede:
914 - option: host-name
915 declaration: "spaceship"
916 - option: domain-name
917 declaration: "domain.home"
918 #- option: arp-cache-timeout
919 # declaration: 20
920 prepend:
921 - option: domain-name-servers
922 declaration:
923 - 8.8.8.8
924 - 8.8.4.4
925 - option: domain-search
926 declaration:
927 - example.com
928 - eng.example.com
929 #append:
930 #- option: domain-name-servers
931 # declaration: 127.0.0.1
932 # ip or subnet to reject dhcp offer from
933 reject:
934 - 192.33.137.209
935 - 10.0.2.0/24
936 request:
937 - subnet-mask
938 - broadcast-address
939 - time-offset
940 - routers
941 - domain-name
942 - domain-name-servers
943 - domain-search
944 - host-name
945 - dhcp6.name-servers
946 - dhcp6.domain-search
947 - dhcp6.fqdn
948 - dhcp6.sntp-servers
949 - netbios-name-servers
950 - netbios-scope
951 - interface-mtu
952 - rfc3442-classless-static-routes
953 - ntp-servers
954 require:
955 - subnet-mask
956 - domain-name-servers
957 # if per interface configuration required add below
958 interface:
959 ens2:
960 initial_interval: 11
961 reject:
962 - 192.33.137.210
963 ens3:
964 initial_interval: 12
965 reject:
966 - 192.33.137.211
967
968
Petr Michalec10462bb2017-03-23 19:18:08 +0100969Configure global environment variables
970~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
971
972Linux /etc/environment:
973``/etc/environment`` is for static system wide variable assignment after boot. Variable expansion is frequently not supported.
Filip Pytlounf5383a42015-10-06 16:28:32 +0200974
975.. code-block:: yaml
976
977 linux:
Petr Michalec10462bb2017-03-23 19:18:08 +0100978 system:
979 env:
980 BOB_VARIABLE: Alice
981 ...
982 BOB_PATH:
983 - /srv/alice/bin
984 - /srv/bob/bin
985 ...
986 ftp_proxy: none
987 http_proxy: http://global-http-proxy.host.local:8080
988 https_proxy: ${linux:system:proxy:https}
989 no_proxy:
990 - 192.168.0.80
991 - 192.168.1.80
992 - .domain.com
993 - .local
Filip Pytlounf5383a42015-10-06 16:28:32 +0200994 ...
Petr Michalec10462bb2017-03-23 19:18:08 +0100995 # NOTE: global defaults proxy configuration.
Filip Pytlounf5383a42015-10-06 16:28:32 +0200996 proxy:
Petr Michalec10462bb2017-03-23 19:18:08 +0100997 ftp: ftp://proxy.host.local:2121
998 http: http://proxy.host.local:3142
999 https: https://proxy.host.local:3143
1000 noproxy:
1001 - .domain.com
1002 - .local
1003
1004Configure profile.d scripts
1005~~~~~~~~~~~~~~~~~~~~~~~~~~~
1006
1007Linux /etc/profile.d:
1008The profile.d scripts are being sourced during .sh execution and support variable expansion in opposite to /etc/environment
1009global settings in ``/etc/environment``.
1010
1011.. code-block:: yaml
1012
1013 linux:
1014 system:
1015 profile:
1016 locales: |
1017 export LANG=C
1018 export LC_ALL=C
1019 ...
1020 vi_flavors.sh: |
1021 export PAGER=view
1022 export EDITOR=vim
1023 alias vi=vim
1024 shell_locales.sh: |
1025 export LANG=en_US
1026 export LC_ALL=en_US.UTF-8
1027 shell_proxies.sh: |
1028 export FTP_PROXY=ftp://127.0.3.3:2121
1029 export NO_PROXY='.local'
Filip Pytlounf5383a42015-10-06 16:28:32 +02001030
1031Linux with hosts
Petr Michalec10462bb2017-03-23 19:18:08 +01001032~~~~~~~~~~~~~~~~
Filip Pytlounf5383a42015-10-06 16:28:32 +02001033
Filip Pytloun86506fe2017-01-26 14:36:16 +01001034Parameter purge_hosts will enforce whole /etc/hosts file, removing entries
1035that are not defined in model except defaults for both IPv4 and IPv6 localhost
1036and hostname + fqdn.
1037It's good to use this option if you want to ensure /etc/hosts is always in a
1038clean state however it's not enabled by default for safety.
1039
Filip Pytlounf5383a42015-10-06 16:28:32 +02001040.. code-block:: yaml
1041
1042 linux:
1043 network:
1044 ...
Filip Pytloun86506fe2017-01-26 14:36:16 +01001045 purge_hosts: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001046 host:
Filip Pytloun86506fe2017-01-26 14:36:16 +01001047 # No need to define this one if purge_hosts is true
1048 hostname:
1049 address: 127.0.1.1
1050 names:
1051 - ${linux:network:fqdn}
1052 - ${linux:network:hostname}
Filip Pytlounf5383a42015-10-06 16:28:32 +02001053 node1:
1054 address: 192.168.10.200
1055 names:
1056 - node2.domain.com
1057 - service2.domain.com
1058 node2:
1059 address: 192.168.10.201
1060 names:
1061 - node2.domain.com
1062 - service2.domain.com
1063
Filip Pytloun86506fe2017-01-26 14:36:16 +01001064
Filip Pytlounde9bea52016-01-11 15:39:10 +01001065Setup resolv.conf, nameservers, domain and search domains
Petr Michalec10462bb2017-03-23 19:18:08 +01001066~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filip Pytlounde9bea52016-01-11 15:39:10 +01001067
1068.. code-block:: yaml
1069
1070 linux:
1071 network:
1072 resolv:
1073 dns:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001074 - 8.8.4.4
1075 - 8.8.8.8
Filip Pytlounde9bea52016-01-11 15:39:10 +01001076 domain: my.example.com
1077 search:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001078 - my.example.com
1079 - example.com
Marek Celoudf6cd1922016-12-05 13:39:49 +01001080 options:
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001081 - ndots: 5
1082 - timeout: 2
1083 - attempts: 2
Filip Pytlounde9bea52016-01-11 15:39:10 +01001084
Andrii Petrenko735761d2017-03-21 17:17:35 -07001085**setting custom TX queue length for tap interfaces**
1086
1087.. code-block:: yaml
1088
1089 linux:
1090 network:
1091 tap_custom_txqueuelen: 10000
1092
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001093DPDK OVS interfaces
1094--------------------
1095
1096**DPDK OVS NIC**
1097
1098.. code-block:: yaml
1099
1100 linux:
1101 network:
1102 bridge: openvswitch
1103 dpdk:
1104 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001105 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001106 openvswitch:
1107 pmd_cpu_mask: "0x6"
1108 dpdk_socket_mem: "1024,1024"
1109 dpdk_lcore_mask: "0x400"
1110 memory_channels: 2
1111 interface:
1112 dpkd0:
1113 name: ${_param:dpdk_nic}
1114 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001115 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001116 enabled: true
1117 type: dpdk_ovs_port
1118 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001119 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001120 bridge: br-prv
Jakub Pavlikaa759062017-03-13 15:57:26 +01001121 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001122 br-prv:
1123 enabled: true
1124 type: dpdk_ovs_bridge
1125
1126**DPDK OVS Bond**
1127
1128.. code-block:: yaml
1129
1130 linux:
1131 network:
1132 bridge: openvswitch
1133 dpdk:
1134 enabled: true
Oleg Bondarev9a466792017-05-25 15:55:42 +04001135 driver: uio/vfio
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001136 openvswitch:
1137 pmd_cpu_mask: "0x6"
1138 dpdk_socket_mem: "1024,1024"
1139 dpdk_lcore_mask: "0x400"
1140 memory_channels: 2
1141 interface:
1142 dpdk_second_nic:
1143 name: ${_param:primary_second_nic}
1144 pci: 0000:06:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001145 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001146 bond: dpdkbond0
1147 enabled: true
1148 type: dpdk_ovs_port
1149 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001150 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001151 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001152 dpdk_first_nic:
1153 name: ${_param:primary_first_nic}
1154 pci: 0000:05:00.0
Oleg Bondarev9a466792017-05-25 15:55:42 +04001155 driver: igb_uio/vfio-pci
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001156 bond: dpdkbond0
1157 enabled: true
1158 type: dpdk_ovs_port
1159 n_rxq: 2
Oleg Bondarev43dbbd32017-05-24 17:06:19 +04001160 pmd_rxq_affinity: "0:1,1:2"
Jakub Pavlikaa759062017-03-13 15:57:26 +01001161 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001162 dpdkbond0:
1163 enabled: true
1164 bridge: br-prv
1165 type: dpdk_ovs_bond
1166 mode: active-backup
1167 br-prv:
1168 enabled: true
1169 type: dpdk_ovs_bridge
1170
Jakub Pavlikaa759062017-03-13 15:57:26 +01001171**DPDK OVS bridge for VXLAN**
1172
1173If VXLAN is used as tenant segmentation then ip address must be set on br-prv
1174
1175.. code-block:: yaml
1176
1177 linux:
1178 network:
1179 ...
1180 interface:
1181 br-prv:
1182 enabled: true
1183 type: dpdk_ovs_bridge
1184 address: 192.168.50.0
1185 netmask: 255.255.255.0
1186 mtu: 9000
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001187
1188Linux storage
1189-------------
Filip Pytlounf5383a42015-10-06 16:28:32 +02001190
1191Linux with mounted Samba
1192
1193.. code-block:: yaml
1194
1195 linux:
1196 storage:
1197 enabled: true
1198 mount:
1199 samba1:
Simon Pasquier376262a2016-11-16 15:21:51 +01001200 - enabled: true
Filip Pytlounf5383a42015-10-06 16:28:32 +02001201 - path: /media/myuser/public/
1202 - device: //192.168.0.1/storage
1203 - file_system: cifs
1204 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
1205
Jiri Broulikb017f932017-03-31 13:55:36 +02001206NFS mount
1207
1208.. code-block:: yaml
1209
1210 linux:
1211 storage:
1212 enabled: true
1213 mount:
1214 nfs_glance:
1215 enabled: true
1216 path: /var/lib/glance/images
1217 device: 172.16.10.110:/var/nfs/glance
1218 file_system: nfs
1219 opts: rw,sync
1220
1221
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001222File swap configuration
Filip Pytlounf5383a42015-10-06 16:28:32 +02001223
1224.. code-block:: yaml
1225
1226 linux:
1227 storage:
1228 enabled: true
1229 swap:
1230 file:
1231 enabled: true
1232 engine: file
1233 device: /swapfile
1234 size: 1024
1235
Jakub Pavlik21ca2152017-02-27 22:21:09 +01001236Partition swap configuration
Lachlan Evenson30676512016-01-22 15:43:28 -08001237
1238.. code-block:: yaml
1239
1240 linux:
1241 storage:
1242 enabled: true
1243 swap:
1244 partition:
1245 enabled: true
1246 engine: partition
1247 device: /dev/vg0/swap
1248
Filip Pytlounc8a001a2015-12-15 14:09:19 +01001249LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
1250
1251.. code-block:: yaml
1252
1253 parameters:
1254 linux:
1255 storage:
1256 mount:
1257 data:
Simon Pasquier376262a2016-11-16 15:21:51 +01001258 enabled: true
Filip Pytlounc8a001a2015-12-15 14:09:19 +01001259 device: /dev/vg1/data
1260 file_system: ext4
1261 path: /mnt/data
1262 lvm:
1263 vg1:
1264 enabled: true
1265 devices:
1266 - /dev/sdb
1267 volume:
1268 data:
1269 size: 40G
1270 mount: ${linux:storage:mount:data}
1271
Jakub Pavlik4f742142017-08-08 15:05:50 +02001272Create partitions on disk. Specify size in MB. It expects empty
1273disk without any existing partitions.
1274
1275.. code-block:: yaml
1276
1277 linux:
1278 storage:
1279 disk:
1280 first_drive:
1281 name: /dev/loop1
1282 type: gpt
1283 partitions:
1284 - size: 200 #size in MB
1285 type: fat32
1286 - size: 300 #size in MB
Jakub Pavlik8e2140a2017-08-14 23:29:57 +02001287 mkfs: True
1288 type: xfs
Jakub Pavlik4f742142017-08-08 15:05:50 +02001289 /dev/vda1:
1290 partitions:
1291 - size: 5
1292 type: ext2
1293 - size: 10
1294 type: ext4
Ales Komareka634f4b2016-10-02 13:11:04 +02001295
1296Multipath with Fujitsu Eternus DXL
1297
1298.. code-block:: yaml
1299
1300 parameters:
1301 linux:
1302 storage:
1303 multipath:
1304 enabled: true
1305 blacklist_devices:
1306 - /dev/sda
1307 - /dev/sdb
1308 backends:
1309 - fujitsu_eternus_dxl
1310
1311Multipath with Hitachi VSP 1000
1312
1313.. code-block:: yaml
1314
1315 parameters:
1316 linux:
1317 storage:
1318 multipath:
1319 enabled: true
1320 blacklist_devices:
1321 - /dev/sda
1322 - /dev/sdb
1323 backends:
1324 - hitachi_vsp1000
1325
1326Multipath with IBM Storwize
1327
1328.. code-block:: yaml
1329
1330 parameters:
1331 linux:
1332 storage:
1333 multipath:
1334 enabled: true
1335 blacklist_devices:
1336 - /dev/sda
1337 - /dev/sdb
1338 backends:
1339 - ibm_storwize
1340
1341Multipath with multiple backends
1342
1343.. code-block:: yaml
1344
1345 parameters:
1346 linux:
1347 storage:
1348 multipath:
1349 enabled: true
1350 blacklist_devices:
1351 - /dev/sda
1352 - /dev/sdb
1353 - /dev/sdc
1354 - /dev/sdd
1355 backends:
1356 - ibm_storwize
1357 - fujitsu_eternus_dxl
1358 - hitachi_vsp1000
1359
1360Disabled multipath (the default setup)
1361
1362.. code-block:: yaml
1363
1364 parameters:
1365 linux:
1366 storage:
1367 multipath:
1368 enabled: false
1369
Simon Pasquier375001e2017-01-26 13:22:33 +01001370Linux with local loopback device
1371
1372.. code-block:: yaml
1373
1374 linux:
1375 storage:
1376 loopback:
1377 disk1:
1378 file: /srv/disk1
1379 size: 50G
1380
Filip Pytlounb2c8f852016-11-21 17:03:43 +01001381External config generation
1382--------------------------
1383
1384You are able to use config support metadata between formulas and only generate
1385config files for external use, eg. docker, etc.
1386
1387.. code-block:: yaml
1388
1389 parameters:
1390 linux:
1391 system:
1392 config:
1393 pillar:
1394 jenkins:
1395 master:
1396 home: /srv/volumes/jenkins
1397 approved_scripts:
1398 - method java.net.URL openConnection
1399 credentials:
1400 - type: username_password
1401 scope: global
1402 id: test
1403 desc: Testing credentials
1404 username: test
1405 password: test
1406
Vladimir Ereminccf28842017-04-10 23:52:10 +03001407Netconsole Remote Kernel Logging
1408--------------------------------
1409
1410Netconsole logger could be configured for configfs-enabled kernels
1411(`CONFIG_NETCONSOLE_DYNAMIC` should be enabled). Configuration applies both in
1412runtime (if network is already configured), and on-boot after interface
1413initialization. Notes:
1414
1415 * receiver could be located only in same L3 domain
1416 (or you need to configure gateway MAC manually)
1417 * receiver's MAC is detected only on configuration time
1418 * using broadcast MAC is not recommended
1419
1420.. code-block:: yaml
1421
1422 parameters:
1423 linux:
1424 system:
1425 netconsole:
1426 enabled: true
1427 port: 514 (optional)
1428 loglevel: debug (optional)
1429 target:
1430 192.168.0.1:
1431 interface: bond0
1432 mac: "ff:ff:ff:ff:ff:ff" (optional)
Ales Komareka634f4b2016-10-02 13:11:04 +02001433
Filip Pytlounf5383a42015-10-06 16:28:32 +02001434Usage
1435=====
1436
1437Set mtu of network interface eth0 to 1400
1438
1439.. code-block:: bash
1440
1441 ip link set dev eth0 mtu 1400
1442
1443Read more
1444=========
1445
1446* https://www.archlinux.org/
1447* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu
Filip Pytloun018f8712017-02-02 13:02:03 +01001448
1449Documentation and Bugs
1450======================
1451
1452To learn how to install and update salt-formulas, consult the documentation
1453available online at:
1454
1455 http://salt-formulas.readthedocs.io/
1456
1457In the unfortunate event that bugs are discovered, they should be reported to
1458the appropriate issue tracker. Use Github issue tracker for specific salt
1459formula:
1460
1461 https://github.com/salt-formulas/salt-formula-linux/issues
1462
1463For feature requests, bug reports or blueprints affecting entire ecosystem,
1464use Launchpad salt-formulas project:
1465
1466 https://launchpad.net/salt-formulas
1467
1468You can also join salt-formulas-users team and subscribe to mailing list:
1469
1470 https://launchpad.net/~salt-formulas-users
1471
1472Developers wishing to work on the salt-formulas projects should always base
1473their work on master branch and submit pull request against specific formula.
1474
1475 https://github.com/salt-formulas/salt-formula-linux
1476
1477Any questions or feedback is always welcome so feel free to join our IRC
1478channel:
1479
1480 #salt-formulas @ irc.freenode.net