blob: fa422f7f9946b7d5cfa7f50fa1b1bb695bd4ece2 [file] [log] [blame]
Filip Pytlounf5383a42015-10-06 16:28:32 +02001
2=====
3Linux
4=====
5
6Linux Operating Systems.
7
8* Ubuntu
9* CentOS
10* RedHat
11* Fedora
12* Arch
13
14Sample pillars
15==============
16
17Linux system
18------------
19
20Basic Linux box
21
22.. code-block:: yaml
23
24 linux:
25 system:
26 enabled: true
27 name: 'node1'
28 domain: 'domain.com'
29 cluster: 'system'
30 environment: prod
31 timezone: 'Europe/Prague'
32 utc: true
33
34Linux with system users, sowe with password set
35
36.. code-block:: yaml
37
38 linux:
39 system:
40 ...
41 user:
42 jdoe:
43 name: 'jdoe'
44 enabled: true
45 sudo: true
46 shell: /bin/bash
47 full_name: 'Jonh Doe'
48 home: '/home/jdoe'
49 email: 'jonh@doe.com'
50 jsmith:
51 name: 'jsmith'
52 enabled: true
53 full_name: 'Password'
54 home: '/home/jsmith'
55 password: userpassword
56
57Linux with package, latest version
58
59.. code-block:: yaml
60
61 linux:
62 system:
63 ...
64 package:
65 package-name:
66 version: latest
67
68Linux with package from certail repo, version with no upgrades
69
70.. code-block:: yaml
71
72 linux:
73 system:
74 ...
75 package:
76 package-name:
77 version: 2132.323
78 repo: 'custom-repo'
79 hold: true
80
81Linux with package from certail repo, version with no GPG verification
82
83.. code-block:: yaml
84
85 linux:
86 system:
87 ...
88 package:
89 package-name:
90 version: 2132.323
91 repo: 'custom-repo'
92 verify: false
93
94Linux with cron jobs
95
96.. code-block:: yaml
97
98 linux:
99 system:
100 ...
101 job:
102 cmd1:
103 command: '/cmd/to/run'
104 enabled: true
105 user: 'root'
106 hour: 2
107 minute: 0
108
Filip Pytlound0a29e72015-11-30 15:23:34 +0100109Linux security limits (limit sensu user memory usage to max 1GB):
110
111.. code-block:: yaml
112
113 linux:
114 system:
115 ...
116 limit:
117 sensu:
118 enabled: true
119 domain: sensu
120 limits:
121 - type: hard
122 item: as
123 value: 1000000
124
Filip Pytloun7fee0542015-10-15 11:19:24 +0200125Enable autologin on tty1 (may work only for Ubuntu 14.04):
126
127.. code-block:: yaml
128
129 linux:
130 system:
131 console:
132 tty1:
133 autologin: root
Filip Pytloun281d0202016-01-29 14:03:51 +0100134 # Enable serial console
135 ttyS0:
136 autologin: root
137 rate: 115200
138 term: xterm
Filip Pytloun7fee0542015-10-15 11:19:24 +0200139
140To disable set autologin to `false`.
141
Filip Pytloun7731b852016-02-01 11:13:47 +0100142Set ``policy-rc.d`` on Debian-based systems. Action can be any available
143command in ``while true`` loop and ``case`` context.
144Following will disallow dpkg to stop/start services for cassandra package automatically:
145
146.. code-block:: yaml
147
148 linux:
149 system:
150 policyrcd:
151 - package: cassandra
152 action: exit 101
153 - package: '*'
154 action: switch
155
Filip Pytloun281034a2016-01-04 18:06:22 +0100156Kernel
157~~~~~~
158
159Install always up to date LTS kernel and headers from Ubuntu trusty:
160
161.. code-block:: yaml
162
163 linux:
164 system:
165 kernel:
166 type: generic
167 lts: trusty
168 headers: true
169
170Install specific kernel version and ensure all other kernel packages are
171not present. Also install extra modules and headers for this kernel:
172
173.. code-block:: yaml
174
175 linux:
176 system:
177 kernel:
178 type: generic
179 extra: true
180 headers: true
181 version: 4.2.0-22
182
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100183Systcl kernel parameters
184
185.. code-block:: yaml
186
187 linux:
188 system:
189 kernel:
190 sysctl:
191 net.ipv4.tcp_keepalive_intvl: 3
192 net.ipv4.tcp_keepalive_time: 30
193 net.ipv4.tcp_keepalive_probes: 8
194
Filip Pytlounf5383a42015-10-06 16:28:32 +0200195Repositories
196~~~~~~~~~~~~
197
198RedHat based Linux with additional OpenStack repo
199
200.. code-block:: yaml
201
202 linux:
203 system:
204 ...
205 repo:
206 rdo-icehouse:
207 enabled: true
208 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
209 pgpcheck: 0
210
211Ensure system repository to use czech Debian mirror (``default: true``)
212Also pin it's packages with priority 900.
213
214.. code-block:: yaml
215
216 linux:
217 system:
218 repo:
219 debian:
220 default: true
221 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
222 # Import signing key from URL if needed
223 key_url: "http://dummy.com/public.gpg"
224 pin:
225 - pin: 'origin "ftp.cz.debian.org"'
226 priority: 900
227 package: '*'
228
Jakub Pavlik78859382016-01-21 11:26:39 +0100229rc.local example
230
231.. code-block:: yaml
232
233 linux:
234 system:
235 rc:
236 local: |
237 #!/bin/sh -e
238 #
239 # rc.local
240 #
241 # This script is executed at the end of each multiuser runlevel.
242 # Make sure that the script will "exit 0" on success or any other
243 # value on error.
244 #
245 # In order to enable or disable this script just change the execution
246 # bits.
247 #
248 # By default this script does nothing.
249 exit 0
250
Filip Pytloun1f40dac2016-01-22 15:52:57 +0100251Prompt
252~~~~~~
253
254Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
255user can have different prompt.
256
257.. code-block:: yaml
258
259 linux:
260 system:
261 prompt:
262 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\\]
263 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
264
265On Debian systems to set prompt system-wide it's necessary to remove setting
266PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
267``/etc/skel/.bashrc``). This formula will do this automatically, but will not
Filip Pytlound9b68da2016-01-22 15:58:41 +0100268touch existing user's ``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +0100269
Filip Pytlouneef11c12016-03-25 11:00:23 +0100270Bash
271~~~~
272
273Fix bash configuration to preserve history across sessions (like ZSH does by
274default).
275
276.. code-block:: yaml
277
278 linux:
279 system:
280 bash:
281 preserve_history: true
282
Filip Pytloune874dfb2016-01-22 16:57:34 +0100283Message of the day
284~~~~~~~~~~~~~~~~~~
285
286``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
287day. Setting custom motd will cleanup existing ones.
288
289.. code-block:: yaml
290
291 linux:
292 system:
293 motd:
294 - release: |
295 #!/bin/sh
296 [ -r /etc/lsb-release ] && . /etc/lsb-release
297
298 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
299 # Fall back to using the very slow lsb_release utility
300 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
301 fi
302
303 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
304 - warning: |
305 #!/bin/sh
306 printf "This is [company name] network.\n"
307 printf "Unauthorized access strictly prohibited.\n"
308
Filip Pytloun2f70b492016-02-19 15:55:25 +0100309RHEL / CentOS
Filip Pytloun8296bb92016-02-19 18:42:09 +0100310^^^^^^^^^^^^^
Filip Pytloun2f70b492016-02-19 15:55:25 +0100311
312Unfortunately ``update-motd`` is currently not available for RHEL so there's
313no native support for dynamic motd.
314You can still set static one, only pillar structure differs:
315
316.. code-block:: yaml
317
318 linux:
319 system:
320 motd: |
321 This is [company name] network.
322 Unauthorized access strictly prohibited.
323
Filip Pytloun8296bb92016-02-19 18:42:09 +0100324Haveged
325~~~~~~~
326
327If you are running headless server and are low on entropy, it may be a good
328idea to setup Haveged.
329
330.. code-block:: yaml
331
332 linux:
333 system:
334 haveged:
335 enabled: true
336
Filip Pytlounf5383a42015-10-06 16:28:32 +0200337Linux network
338-------------
339
340Linux with network manager
341
342.. code-block:: yaml
343
344 linux:
345 network:
346 enabled: true
347 network_manager: true
348
349Linux with default static network interfaces, default gateway interface and DNS servers
350
351.. code-block:: yaml
352
353 linux:
354 network:
355 enabled: true
356 interface:
357 eth0:
358 enabled: true
359 type: eth
360 address: 192.168.0.102
361 netmask: 255.255.255.0
362 gateway: 192.168.0.1
363 name_servers:
364 - 8.8.8.8
365 - 8.8.4.4
366 mtu: 1500
367
jan kaufman6d30adf2016-01-18 17:30:12 +0100368Linux with bonded interfaces and disabled NetworkManager
Filip Pytlounf5383a42015-10-06 16:28:32 +0200369
370.. code-block:: yaml
371
372 linux:
373 network:
374 enabled: true
375 interface:
376 eth0:
377 type: eth
378 ...
379 eth1:
380 type: eth
381 ...
382 bond0:
383 enabled: true
384 type: bond
385 address: 192.168.0.102
386 netmask: 255.255.255.0
387 mtu: 1500
388 use_in:
389 - interface: ${linux:interface:eth0}
390 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +0100391 network_manager:
392 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200393
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100394Linux with vlan interface_params
395
396.. code-block:: yaml
397
398 linux:
399 network:
400 enabled: true
401 interface:
402 vlan69:
403 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +0100404 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100405 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100406
Filip Pytlounf5383a42015-10-06 16:28:32 +0200407Linux with wireless interface parameters
408
409.. code-block:: yaml
410
411 linux:
412 network:
413 enabled: true
414 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100415 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200416 interface:
417 wlan0:
418 type: eth
419 wireless:
420 essid: example
421 key: example_key
422 security: wpa
423 priority: 1
424
425Linux networks with routes defined
426
427.. code-block:: yaml
428
429 linux:
430 network:
431 enabled: true
432 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100433 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200434 interface:
435 eth0:
436 type: eth
437 route:
438 default:
439 address: 192.168.0.123
440 netmask: 255.255.255.0
441 gateway: 192.168.0.1
442
443Native Linux Bridges
444
445.. code-block:: yaml
446
447 linux:
448 network:
449 interface:
450 eth1:
451 enabled: true
452 type: eth
453 proto: manual
454 up_cmds:
455 - ip address add 0/0 dev $IFACE
456 - ip link set $IFACE up
457 down_cmds:
458 - ip link set $IFACE down
459 br-ex:
460 enabled: true
461 type: bridge
462 address: ${linux:network:host:public_local:address}
463 netmask: 255.255.255.0
464 use_interfaces:
465 - eth1
466
467OpenVswitch Bridges
468
469.. code-block:: yaml
470
471 linux:
472 network:
473 bridge: openvswitch
474 interface:
475 eth1:
476 enabled: true
477 type: eth
478 proto: manual
479 up_cmds:
480 - ip address add 0/0 dev $IFACE
481 - ip link set $IFACE up
482 down_cmds:
483 - ip link set $IFACE down
484 br-ex:
485 enabled: true
486 type: bridge
487 address: ${linux:network:host:public_local:address}
488 netmask: 255.255.255.0
489 use_interfaces:
490 - eth1
491
492Linux with proxy
493
494.. code-block:: yaml
495
496 linux:
497 network:
498 ...
499 proxy:
500 host: proxy.domain.com
501 port: 3128
502
503Linux with hosts
504
505.. code-block:: yaml
506
507 linux:
508 network:
509 ...
510 host:
511 node1:
512 address: 192.168.10.200
513 names:
514 - node2.domain.com
515 - service2.domain.com
516 node2:
517 address: 192.168.10.201
518 names:
519 - node2.domain.com
520 - service2.domain.com
521
Filip Pytlounde9bea52016-01-11 15:39:10 +0100522Setup resolv.conf, nameservers, domain and search domains
523
524.. code-block:: yaml
525
526 linux:
527 network:
528 resolv:
529 dns:
530 - 8.8.4.4
531 - 8.8.8.8
532 domain: my.example.com
533 search:
534 - my.example.com
535 - example.com
536
Filip Pytlounf5383a42015-10-06 16:28:32 +0200537Linux storage pillars
538---------------------
539
540Linux with mounted Samba
541
542.. code-block:: yaml
543
544 linux:
545 storage:
546 enabled: true
547 mount:
548 samba1:
549 - path: /media/myuser/public/
550 - device: //192.168.0.1/storage
551 - file_system: cifs
552 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
553
554Linux with file swap
555
556.. code-block:: yaml
557
558 linux:
559 storage:
560 enabled: true
561 swap:
562 file:
563 enabled: true
564 engine: file
565 device: /swapfile
566 size: 1024
567
Lachlan Evenson30676512016-01-22 15:43:28 -0800568Linux with partition swap
569
570.. code-block:: yaml
571
572 linux:
573 storage:
574 enabled: true
575 swap:
576 partition:
577 enabled: true
578 engine: partition
579 device: /dev/vg0/swap
580
Filip Pytlounc8a001a2015-12-15 14:09:19 +0100581LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
582
583.. code-block:: yaml
584
585 parameters:
586 linux:
587 storage:
588 mount:
589 data:
590 device: /dev/vg1/data
591 file_system: ext4
592 path: /mnt/data
593 lvm:
594 vg1:
595 enabled: true
596 devices:
597 - /dev/sdb
598 volume:
599 data:
600 size: 40G
601 mount: ${linux:storage:mount:data}
602
Filip Pytlounf5383a42015-10-06 16:28:32 +0200603Usage
604=====
605
606Set mtu of network interface eth0 to 1400
607
608.. code-block:: bash
609
610 ip link set dev eth0 mtu 1400
611
612Read more
613=========
614
615* https://www.archlinux.org/
616* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu