blob: 9d1ae82a1b0d36e0b1fd56b202b7fa5fd4a9d059 [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 Pytlounf5383a42015-10-06 16:28:32 +0200296Linux network
297-------------
298
299Linux with network manager
300
301.. code-block:: yaml
302
303 linux:
304 network:
305 enabled: true
306 network_manager: true
307
308Linux with default static network interfaces, default gateway interface and DNS servers
309
310.. code-block:: yaml
311
312 linux:
313 network:
314 enabled: true
315 interface:
316 eth0:
317 enabled: true
318 type: eth
319 address: 192.168.0.102
320 netmask: 255.255.255.0
321 gateway: 192.168.0.1
322 name_servers:
323 - 8.8.8.8
324 - 8.8.4.4
325 mtu: 1500
326
jan kaufman6d30adf2016-01-18 17:30:12 +0100327Linux with bonded interfaces and disabled NetworkManager
Filip Pytlounf5383a42015-10-06 16:28:32 +0200328
329.. code-block:: yaml
330
331 linux:
332 network:
333 enabled: true
334 interface:
335 eth0:
336 type: eth
337 ...
338 eth1:
339 type: eth
340 ...
341 bond0:
342 enabled: true
343 type: bond
344 address: 192.168.0.102
345 netmask: 255.255.255.0
346 mtu: 1500
347 use_in:
348 - interface: ${linux:interface:eth0}
349 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +0100350 network_manager:
351 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200352
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100353Linux with vlan interface_params
354
355.. code-block:: yaml
356
357 linux:
358 network:
359 enabled: true
360 interface:
361 vlan69:
362 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +0100363 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100364 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100365
Filip Pytlounf5383a42015-10-06 16:28:32 +0200366Linux with wireless interface parameters
367
368.. code-block:: yaml
369
370 linux:
371 network:
372 enabled: true
373 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100374 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200375 interface:
376 wlan0:
377 type: eth
378 wireless:
379 essid: example
380 key: example_key
381 security: wpa
382 priority: 1
383
384Linux networks with routes defined
385
386.. code-block:: yaml
387
388 linux:
389 network:
390 enabled: true
391 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100392 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200393 interface:
394 eth0:
395 type: eth
396 route:
397 default:
398 address: 192.168.0.123
399 netmask: 255.255.255.0
400 gateway: 192.168.0.1
401
402Native Linux Bridges
403
404.. code-block:: yaml
405
406 linux:
407 network:
408 interface:
409 eth1:
410 enabled: true
411 type: eth
412 proto: manual
413 up_cmds:
414 - ip address add 0/0 dev $IFACE
415 - ip link set $IFACE up
416 down_cmds:
417 - ip link set $IFACE down
418 br-ex:
419 enabled: true
420 type: bridge
421 address: ${linux:network:host:public_local:address}
422 netmask: 255.255.255.0
423 use_interfaces:
424 - eth1
425
426OpenVswitch Bridges
427
428.. code-block:: yaml
429
430 linux:
431 network:
432 bridge: openvswitch
433 interface:
434 eth1:
435 enabled: true
436 type: eth
437 proto: manual
438 up_cmds:
439 - ip address add 0/0 dev $IFACE
440 - ip link set $IFACE up
441 down_cmds:
442 - ip link set $IFACE down
443 br-ex:
444 enabled: true
445 type: bridge
446 address: ${linux:network:host:public_local:address}
447 netmask: 255.255.255.0
448 use_interfaces:
449 - eth1
450
451Linux with proxy
452
453.. code-block:: yaml
454
455 linux:
456 network:
457 ...
458 proxy:
459 host: proxy.domain.com
460 port: 3128
461
462Linux with hosts
463
464.. code-block:: yaml
465
466 linux:
467 network:
468 ...
469 host:
470 node1:
471 address: 192.168.10.200
472 names:
473 - node2.domain.com
474 - service2.domain.com
475 node2:
476 address: 192.168.10.201
477 names:
478 - node2.domain.com
479 - service2.domain.com
480
Filip Pytlounde9bea52016-01-11 15:39:10 +0100481Setup resolv.conf, nameservers, domain and search domains
482
483.. code-block:: yaml
484
485 linux:
486 network:
487 resolv:
488 dns:
489 - 8.8.4.4
490 - 8.8.8.8
491 domain: my.example.com
492 search:
493 - my.example.com
494 - example.com
495
Filip Pytlounf5383a42015-10-06 16:28:32 +0200496Linux storage pillars
497---------------------
498
499Linux with mounted Samba
500
501.. code-block:: yaml
502
503 linux:
504 storage:
505 enabled: true
506 mount:
507 samba1:
508 - path: /media/myuser/public/
509 - device: //192.168.0.1/storage
510 - file_system: cifs
511 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
512
513Linux with file swap
514
515.. code-block:: yaml
516
517 linux:
518 storage:
519 enabled: true
520 swap:
521 file:
522 enabled: true
523 engine: file
524 device: /swapfile
525 size: 1024
526
Lachlan Evenson30676512016-01-22 15:43:28 -0800527Linux with partition swap
528
529.. code-block:: yaml
530
531 linux:
532 storage:
533 enabled: true
534 swap:
535 partition:
536 enabled: true
537 engine: partition
538 device: /dev/vg0/swap
539
Filip Pytlounc8a001a2015-12-15 14:09:19 +0100540LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
541
542.. code-block:: yaml
543
544 parameters:
545 linux:
546 storage:
547 mount:
548 data:
549 device: /dev/vg1/data
550 file_system: ext4
551 path: /mnt/data
552 lvm:
553 vg1:
554 enabled: true
555 devices:
556 - /dev/sdb
557 volume:
558 data:
559 size: 40G
560 mount: ${linux:storage:mount:data}
561
Filip Pytlounf5383a42015-10-06 16:28:32 +0200562Usage
563=====
564
565Set mtu of network interface eth0 to 1400
566
567.. code-block:: bash
568
569 ip link set dev eth0 mtu 1400
570
571Read more
572=========
573
574* https://www.archlinux.org/
575* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu