blob: cd43da261c8fca34648905f9f8fa25434a47fce6 [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 Pytloun281034a2016-01-04 18:06:22 +0100142Kernel
143~~~~~~
144
145Install always up to date LTS kernel and headers from Ubuntu trusty:
146
147.. code-block:: yaml
148
149 linux:
150 system:
151 kernel:
152 type: generic
153 lts: trusty
154 headers: true
155
156Install specific kernel version and ensure all other kernel packages are
157not present. Also install extra modules and headers for this kernel:
158
159.. code-block:: yaml
160
161 linux:
162 system:
163 kernel:
164 type: generic
165 extra: true
166 headers: true
167 version: 4.2.0-22
168
Jakub Pavlik32c2cb02016-01-29 12:45:29 +0100169Systcl kernel parameters
170
171.. code-block:: yaml
172
173 linux:
174 system:
175 kernel:
176 sysctl:
177 net.ipv4.tcp_keepalive_intvl: 3
178 net.ipv4.tcp_keepalive_time: 30
179 net.ipv4.tcp_keepalive_probes: 8
180
Filip Pytlounf5383a42015-10-06 16:28:32 +0200181Repositories
182~~~~~~~~~~~~
183
184RedHat based Linux with additional OpenStack repo
185
186.. code-block:: yaml
187
188 linux:
189 system:
190 ...
191 repo:
192 rdo-icehouse:
193 enabled: true
194 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
195 pgpcheck: 0
196
197Ensure system repository to use czech Debian mirror (``default: true``)
198Also pin it's packages with priority 900.
199
200.. code-block:: yaml
201
202 linux:
203 system:
204 repo:
205 debian:
206 default: true
207 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
208 # Import signing key from URL if needed
209 key_url: "http://dummy.com/public.gpg"
210 pin:
211 - pin: 'origin "ftp.cz.debian.org"'
212 priority: 900
213 package: '*'
214
Jakub Pavlik78859382016-01-21 11:26:39 +0100215rc.local example
216
217.. code-block:: yaml
218
219 linux:
220 system:
221 rc:
222 local: |
223 #!/bin/sh -e
224 #
225 # rc.local
226 #
227 # This script is executed at the end of each multiuser runlevel.
228 # Make sure that the script will "exit 0" on success or any other
229 # value on error.
230 #
231 # In order to enable or disable this script just change the execution
232 # bits.
233 #
234 # By default this script does nothing.
235 exit 0
236
Filip Pytloun1f40dac2016-01-22 15:52:57 +0100237Prompt
238~~~~~~
239
240Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
241user can have different prompt.
242
243.. code-block:: yaml
244
245 linux:
246 system:
247 prompt:
248 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\\]
249 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
250
251On Debian systems to set prompt system-wide it's necessary to remove setting
252PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
253``/etc/skel/.bashrc``). This formula will do this automatically, but will not
Filip Pytlound9b68da2016-01-22 15:58:41 +0100254touch existing user's ``~/.bashrc`` files except root.
Jakub Pavlik78859382016-01-21 11:26:39 +0100255
Filip Pytloune874dfb2016-01-22 16:57:34 +0100256Message of the day
257~~~~~~~~~~~~~~~~~~
258
259``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
260day. Setting custom motd will cleanup existing ones.
261
262.. code-block:: yaml
263
264 linux:
265 system:
266 motd:
267 - release: |
268 #!/bin/sh
269 [ -r /etc/lsb-release ] && . /etc/lsb-release
270
271 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
272 # Fall back to using the very slow lsb_release utility
273 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
274 fi
275
276 printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
277 - warning: |
278 #!/bin/sh
279 printf "This is [company name] network.\n"
280 printf "Unauthorized access strictly prohibited.\n"
281
Filip Pytlounf5383a42015-10-06 16:28:32 +0200282Linux network
283-------------
284
285Linux with network manager
286
287.. code-block:: yaml
288
289 linux:
290 network:
291 enabled: true
292 network_manager: true
293
294Linux with default static network interfaces, default gateway interface and DNS servers
295
296.. code-block:: yaml
297
298 linux:
299 network:
300 enabled: true
301 interface:
302 eth0:
303 enabled: true
304 type: eth
305 address: 192.168.0.102
306 netmask: 255.255.255.0
307 gateway: 192.168.0.1
308 name_servers:
309 - 8.8.8.8
310 - 8.8.4.4
311 mtu: 1500
312
jan kaufman6d30adf2016-01-18 17:30:12 +0100313Linux with bonded interfaces and disabled NetworkManager
Filip Pytlounf5383a42015-10-06 16:28:32 +0200314
315.. code-block:: yaml
316
317 linux:
318 network:
319 enabled: true
320 interface:
321 eth0:
322 type: eth
323 ...
324 eth1:
325 type: eth
326 ...
327 bond0:
328 enabled: true
329 type: bond
330 address: 192.168.0.102
331 netmask: 255.255.255.0
332 mtu: 1500
333 use_in:
334 - interface: ${linux:interface:eth0}
335 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +0100336 network_manager:
337 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200338
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100339Linux with vlan interface_params
340
341.. code-block:: yaml
342
343 linux:
344 network:
345 enabled: true
346 interface:
347 vlan69:
348 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +0100349 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100350 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100351
Filip Pytlounf5383a42015-10-06 16:28:32 +0200352Linux with wireless interface parameters
353
354.. code-block:: yaml
355
356 linux:
357 network:
358 enabled: true
359 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100360 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200361 interface:
362 wlan0:
363 type: eth
364 wireless:
365 essid: example
366 key: example_key
367 security: wpa
368 priority: 1
369
370Linux networks with routes defined
371
372.. code-block:: yaml
373
374 linux:
375 network:
376 enabled: true
377 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100378 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200379 interface:
380 eth0:
381 type: eth
382 route:
383 default:
384 address: 192.168.0.123
385 netmask: 255.255.255.0
386 gateway: 192.168.0.1
387
388Native Linux Bridges
389
390.. code-block:: yaml
391
392 linux:
393 network:
394 interface:
395 eth1:
396 enabled: true
397 type: eth
398 proto: manual
399 up_cmds:
400 - ip address add 0/0 dev $IFACE
401 - ip link set $IFACE up
402 down_cmds:
403 - ip link set $IFACE down
404 br-ex:
405 enabled: true
406 type: bridge
407 address: ${linux:network:host:public_local:address}
408 netmask: 255.255.255.0
409 use_interfaces:
410 - eth1
411
412OpenVswitch Bridges
413
414.. code-block:: yaml
415
416 linux:
417 network:
418 bridge: openvswitch
419 interface:
420 eth1:
421 enabled: true
422 type: eth
423 proto: manual
424 up_cmds:
425 - ip address add 0/0 dev $IFACE
426 - ip link set $IFACE up
427 down_cmds:
428 - ip link set $IFACE down
429 br-ex:
430 enabled: true
431 type: bridge
432 address: ${linux:network:host:public_local:address}
433 netmask: 255.255.255.0
434 use_interfaces:
435 - eth1
436
437Linux with proxy
438
439.. code-block:: yaml
440
441 linux:
442 network:
443 ...
444 proxy:
445 host: proxy.domain.com
446 port: 3128
447
448Linux with hosts
449
450.. code-block:: yaml
451
452 linux:
453 network:
454 ...
455 host:
456 node1:
457 address: 192.168.10.200
458 names:
459 - node2.domain.com
460 - service2.domain.com
461 node2:
462 address: 192.168.10.201
463 names:
464 - node2.domain.com
465 - service2.domain.com
466
Filip Pytlounde9bea52016-01-11 15:39:10 +0100467Setup resolv.conf, nameservers, domain and search domains
468
469.. code-block:: yaml
470
471 linux:
472 network:
473 resolv:
474 dns:
475 - 8.8.4.4
476 - 8.8.8.8
477 domain: my.example.com
478 search:
479 - my.example.com
480 - example.com
481
Filip Pytlounf5383a42015-10-06 16:28:32 +0200482Linux storage pillars
483---------------------
484
485Linux with mounted Samba
486
487.. code-block:: yaml
488
489 linux:
490 storage:
491 enabled: true
492 mount:
493 samba1:
494 - path: /media/myuser/public/
495 - device: //192.168.0.1/storage
496 - file_system: cifs
497 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
498
499Linux with file swap
500
501.. code-block:: yaml
502
503 linux:
504 storage:
505 enabled: true
506 swap:
507 file:
508 enabled: true
509 engine: file
510 device: /swapfile
511 size: 1024
512
Lachlan Evenson30676512016-01-22 15:43:28 -0800513Linux with partition swap
514
515.. code-block:: yaml
516
517 linux:
518 storage:
519 enabled: true
520 swap:
521 partition:
522 enabled: true
523 engine: partition
524 device: /dev/vg0/swap
525
Filip Pytlounc8a001a2015-12-15 14:09:19 +0100526LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
527
528.. code-block:: yaml
529
530 parameters:
531 linux:
532 storage:
533 mount:
534 data:
535 device: /dev/vg1/data
536 file_system: ext4
537 path: /mnt/data
538 lvm:
539 vg1:
540 enabled: true
541 devices:
542 - /dev/sdb
543 volume:
544 data:
545 size: 40G
546 mount: ${linux:storage:mount:data}
547
Filip Pytlounf5383a42015-10-06 16:28:32 +0200548Usage
549=====
550
551Set mtu of network interface eth0 to 1400
552
553.. code-block:: bash
554
555 ip link set dev eth0 mtu 1400
556
557Read more
558=========
559
560* https://www.archlinux.org/
561* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu