blob: f3819ed4b0c1a944192f3b27b551e134c7ba92b7 [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 Pytloune874dfb2016-01-22 16:57:34 +0100270Message of the day
271~~~~~~~~~~~~~~~~~~
272
273``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
274day. Setting custom motd will cleanup existing ones.
275
276.. code-block:: yaml
277
278 linux:
279 system:
280 motd:
281 - release: |
282 #!/bin/sh
283 [ -r /etc/lsb-release ] && . /etc/lsb-release
284
285 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
286 # Fall back to using the very slow lsb_release utility
287 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
288 fi
289
290 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
291 - warning: |
292 #!/bin/sh
293 printf "This is [company name] network.\n"
294 printf "Unauthorized access strictly prohibited.\n"
295
Filip Pytloun2f70b492016-02-19 15:55:25 +0100296RHEL / CentOS
297~~~~~~~~~~~~~
298
299Unfortunately ``update-motd`` is currently not available for RHEL so there's
300no native support for dynamic motd.
301You can still set static one, only pillar structure differs:
302
303.. code-block:: yaml
304
305 linux:
306 system:
307 motd: |
308 This is [company name] network.
309 Unauthorized access strictly prohibited.
310
Filip Pytlounf5383a42015-10-06 16:28:32 +0200311Linux network
312-------------
313
314Linux with network manager
315
316.. code-block:: yaml
317
318 linux:
319 network:
320 enabled: true
321 network_manager: true
322
323Linux with default static network interfaces, default gateway interface and DNS servers
324
325.. code-block:: yaml
326
327 linux:
328 network:
329 enabled: true
330 interface:
331 eth0:
332 enabled: true
333 type: eth
334 address: 192.168.0.102
335 netmask: 255.255.255.0
336 gateway: 192.168.0.1
337 name_servers:
338 - 8.8.8.8
339 - 8.8.4.4
340 mtu: 1500
341
jan kaufman6d30adf2016-01-18 17:30:12 +0100342Linux with bonded interfaces and disabled NetworkManager
Filip Pytlounf5383a42015-10-06 16:28:32 +0200343
344.. code-block:: yaml
345
346 linux:
347 network:
348 enabled: true
349 interface:
350 eth0:
351 type: eth
352 ...
353 eth1:
354 type: eth
355 ...
356 bond0:
357 enabled: true
358 type: bond
359 address: 192.168.0.102
360 netmask: 255.255.255.0
361 mtu: 1500
362 use_in:
363 - interface: ${linux:interface:eth0}
364 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +0100365 network_manager:
366 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200367
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100368Linux with vlan interface_params
369
370.. code-block:: yaml
371
372 linux:
373 network:
374 enabled: true
375 interface:
376 vlan69:
377 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +0100378 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100379 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100380
Filip Pytlounf5383a42015-10-06 16:28:32 +0200381Linux with wireless interface parameters
382
383.. code-block:: yaml
384
385 linux:
386 network:
387 enabled: true
388 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100389 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200390 interface:
391 wlan0:
392 type: eth
393 wireless:
394 essid: example
395 key: example_key
396 security: wpa
397 priority: 1
398
399Linux networks with routes defined
400
401.. code-block:: yaml
402
403 linux:
404 network:
405 enabled: true
406 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100407 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200408 interface:
409 eth0:
410 type: eth
411 route:
412 default:
413 address: 192.168.0.123
414 netmask: 255.255.255.0
415 gateway: 192.168.0.1
416
417Native Linux Bridges
418
419.. code-block:: yaml
420
421 linux:
422 network:
423 interface:
424 eth1:
425 enabled: true
426 type: eth
427 proto: manual
428 up_cmds:
429 - ip address add 0/0 dev $IFACE
430 - ip link set $IFACE up
431 down_cmds:
432 - ip link set $IFACE down
433 br-ex:
434 enabled: true
435 type: bridge
436 address: ${linux:network:host:public_local:address}
437 netmask: 255.255.255.0
438 use_interfaces:
439 - eth1
440
441OpenVswitch Bridges
442
443.. code-block:: yaml
444
445 linux:
446 network:
447 bridge: openvswitch
448 interface:
449 eth1:
450 enabled: true
451 type: eth
452 proto: manual
453 up_cmds:
454 - ip address add 0/0 dev $IFACE
455 - ip link set $IFACE up
456 down_cmds:
457 - ip link set $IFACE down
458 br-ex:
459 enabled: true
460 type: bridge
461 address: ${linux:network:host:public_local:address}
462 netmask: 255.255.255.0
463 use_interfaces:
464 - eth1
465
466Linux with proxy
467
468.. code-block:: yaml
469
470 linux:
471 network:
472 ...
473 proxy:
474 host: proxy.domain.com
475 port: 3128
476
477Linux with hosts
478
479.. code-block:: yaml
480
481 linux:
482 network:
483 ...
484 host:
485 node1:
486 address: 192.168.10.200
487 names:
488 - node2.domain.com
489 - service2.domain.com
490 node2:
491 address: 192.168.10.201
492 names:
493 - node2.domain.com
494 - service2.domain.com
495
Filip Pytlounde9bea52016-01-11 15:39:10 +0100496Setup resolv.conf, nameservers, domain and search domains
497
498.. code-block:: yaml
499
500 linux:
501 network:
502 resolv:
503 dns:
504 - 8.8.4.4
505 - 8.8.8.8
506 domain: my.example.com
507 search:
508 - my.example.com
509 - example.com
510
Filip Pytlounf5383a42015-10-06 16:28:32 +0200511Linux storage pillars
512---------------------
513
514Linux with mounted Samba
515
516.. code-block:: yaml
517
518 linux:
519 storage:
520 enabled: true
521 mount:
522 samba1:
523 - path: /media/myuser/public/
524 - device: //192.168.0.1/storage
525 - file_system: cifs
526 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
527
528Linux with file swap
529
530.. code-block:: yaml
531
532 linux:
533 storage:
534 enabled: true
535 swap:
536 file:
537 enabled: true
538 engine: file
539 device: /swapfile
540 size: 1024
541
Lachlan Evenson30676512016-01-22 15:43:28 -0800542Linux with partition swap
543
544.. code-block:: yaml
545
546 linux:
547 storage:
548 enabled: true
549 swap:
550 partition:
551 enabled: true
552 engine: partition
553 device: /dev/vg0/swap
554
Filip Pytlounc8a001a2015-12-15 14:09:19 +0100555LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
556
557.. code-block:: yaml
558
559 parameters:
560 linux:
561 storage:
562 mount:
563 data:
564 device: /dev/vg1/data
565 file_system: ext4
566 path: /mnt/data
567 lvm:
568 vg1:
569 enabled: true
570 devices:
571 - /dev/sdb
572 volume:
573 data:
574 size: 40G
575 mount: ${linux:storage:mount:data}
576
Filip Pytlounf5383a42015-10-06 16:28:32 +0200577Usage
578=====
579
580Set mtu of network interface eth0 to 1400
581
582.. code-block:: bash
583
584 ip link set dev eth0 mtu 1400
585
586Read more
587=========
588
589* https://www.archlinux.org/
590* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu