blob: f5146e60fe488bc53ee62b983aa088310bb097f3 [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
134
135To disable set autologin to `false`.
136
Filip Pytloun281034a2016-01-04 18:06:22 +0100137Kernel
138~~~~~~
139
140Install always up to date LTS kernel and headers from Ubuntu trusty:
141
142.. code-block:: yaml
143
144 linux:
145 system:
146 kernel:
147 type: generic
148 lts: trusty
149 headers: true
150
151Install specific kernel version and ensure all other kernel packages are
152not present. Also install extra modules and headers for this kernel:
153
154.. code-block:: yaml
155
156 linux:
157 system:
158 kernel:
159 type: generic
160 extra: true
161 headers: true
162 version: 4.2.0-22
163
Filip Pytlounf5383a42015-10-06 16:28:32 +0200164Repositories
165~~~~~~~~~~~~
166
167RedHat based Linux with additional OpenStack repo
168
169.. code-block:: yaml
170
171 linux:
172 system:
173 ...
174 repo:
175 rdo-icehouse:
176 enabled: true
177 source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
178 pgpcheck: 0
179
180Ensure system repository to use czech Debian mirror (``default: true``)
181Also pin it's packages with priority 900.
182
183.. code-block:: yaml
184
185 linux:
186 system:
187 repo:
188 debian:
189 default: true
190 source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
191 # Import signing key from URL if needed
192 key_url: "http://dummy.com/public.gpg"
193 pin:
194 - pin: 'origin "ftp.cz.debian.org"'
195 priority: 900
196 package: '*'
197
Jakub Pavlik78859382016-01-21 11:26:39 +0100198rc.local example
199
200.. code-block:: yaml
201
202 linux:
203 system:
204 rc:
205 local: |
206 #!/bin/sh -e
207 #
208 # rc.local
209 #
210 # This script is executed at the end of each multiuser runlevel.
211 # Make sure that the script will "exit 0" on success or any other
212 # value on error.
213 #
214 # In order to enable or disable this script just change the execution
215 # bits.
216 #
217 # By default this script does nothing.
218 exit 0
219
Filip Pytloun1f40dac2016-01-22 15:52:57 +0100220Prompt
221~~~~~~
222
223Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
224user can have different prompt.
225
226.. code-block:: yaml
227
228 linux:
229 system:
230 prompt:
231 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\\]
232 default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
233
234On Debian systems to set prompt system-wide it's necessary to remove setting
235PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
236``/etc/skel/.bashrc``). This formula will do this automatically, but will not
237touch existing user's ``~/.bashrc`` files.
Jakub Pavlik78859382016-01-21 11:26:39 +0100238
Filip Pytlounf5383a42015-10-06 16:28:32 +0200239Linux network
240-------------
241
242Linux with network manager
243
244.. code-block:: yaml
245
246 linux:
247 network:
248 enabled: true
249 network_manager: true
250
251Linux with default static network interfaces, default gateway interface and DNS servers
252
253.. code-block:: yaml
254
255 linux:
256 network:
257 enabled: true
258 interface:
259 eth0:
260 enabled: true
261 type: eth
262 address: 192.168.0.102
263 netmask: 255.255.255.0
264 gateway: 192.168.0.1
265 name_servers:
266 - 8.8.8.8
267 - 8.8.4.4
268 mtu: 1500
269
jan kaufman6d30adf2016-01-18 17:30:12 +0100270Linux with bonded interfaces and disabled NetworkManager
Filip Pytlounf5383a42015-10-06 16:28:32 +0200271
272.. code-block:: yaml
273
274 linux:
275 network:
276 enabled: true
277 interface:
278 eth0:
279 type: eth
280 ...
281 eth1:
282 type: eth
283 ...
284 bond0:
285 enabled: true
286 type: bond
287 address: 192.168.0.102
288 netmask: 255.255.255.0
289 mtu: 1500
290 use_in:
291 - interface: ${linux:interface:eth0}
292 - interface: ${linux:interface:eth0}
jan kaufman6d30adf2016-01-18 17:30:12 +0100293 network_manager:
294 disable: true
Filip Pytlounf5383a42015-10-06 16:28:32 +0200295
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100296Linux with vlan interface_params
297
298.. code-block:: yaml
299
300 linux:
301 network:
302 enabled: true
303 interface:
304 vlan69:
305 type: vlan
jan kaufmanc0bd76f2015-12-15 16:45:44 +0100306 use_interfaces:
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100307 - interface: ${linux:interface:bond0}
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100308
Filip Pytlounf5383a42015-10-06 16:28:32 +0200309Linux with wireless interface parameters
310
311.. code-block:: yaml
312
313 linux:
314 network:
315 enabled: true
316 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100317 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200318 interface:
319 wlan0:
320 type: eth
321 wireless:
322 essid: example
323 key: example_key
324 security: wpa
325 priority: 1
326
327Linux networks with routes defined
328
329.. code-block:: yaml
330
331 linux:
332 network:
333 enabled: true
334 gateway: 10.0.0.1
Jan Kaufman6a1ad712015-12-11 14:44:19 +0100335 default_interface: eth0
Filip Pytlounf5383a42015-10-06 16:28:32 +0200336 interface:
337 eth0:
338 type: eth
339 route:
340 default:
341 address: 192.168.0.123
342 netmask: 255.255.255.0
343 gateway: 192.168.0.1
344
345Native Linux Bridges
346
347.. code-block:: yaml
348
349 linux:
350 network:
351 interface:
352 eth1:
353 enabled: true
354 type: eth
355 proto: manual
356 up_cmds:
357 - ip address add 0/0 dev $IFACE
358 - ip link set $IFACE up
359 down_cmds:
360 - ip link set $IFACE down
361 br-ex:
362 enabled: true
363 type: bridge
364 address: ${linux:network:host:public_local:address}
365 netmask: 255.255.255.0
366 use_interfaces:
367 - eth1
368
369OpenVswitch Bridges
370
371.. code-block:: yaml
372
373 linux:
374 network:
375 bridge: openvswitch
376 interface:
377 eth1:
378 enabled: true
379 type: eth
380 proto: manual
381 up_cmds:
382 - ip address add 0/0 dev $IFACE
383 - ip link set $IFACE up
384 down_cmds:
385 - ip link set $IFACE down
386 br-ex:
387 enabled: true
388 type: bridge
389 address: ${linux:network:host:public_local:address}
390 netmask: 255.255.255.0
391 use_interfaces:
392 - eth1
393
394Linux with proxy
395
396.. code-block:: yaml
397
398 linux:
399 network:
400 ...
401 proxy:
402 host: proxy.domain.com
403 port: 3128
404
405Linux with hosts
406
407.. code-block:: yaml
408
409 linux:
410 network:
411 ...
412 host:
413 node1:
414 address: 192.168.10.200
415 names:
416 - node2.domain.com
417 - service2.domain.com
418 node2:
419 address: 192.168.10.201
420 names:
421 - node2.domain.com
422 - service2.domain.com
423
Filip Pytlounde9bea52016-01-11 15:39:10 +0100424Setup resolv.conf, nameservers, domain and search domains
425
426.. code-block:: yaml
427
428 linux:
429 network:
430 resolv:
431 dns:
432 - 8.8.4.4
433 - 8.8.8.8
434 domain: my.example.com
435 search:
436 - my.example.com
437 - example.com
438
Filip Pytlounf5383a42015-10-06 16:28:32 +0200439Linux storage pillars
440---------------------
441
442Linux with mounted Samba
443
444.. code-block:: yaml
445
446 linux:
447 storage:
448 enabled: true
449 mount:
450 samba1:
451 - path: /media/myuser/public/
452 - device: //192.168.0.1/storage
453 - file_system: cifs
454 - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
455
456Linux with file swap
457
458.. code-block:: yaml
459
460 linux:
461 storage:
462 enabled: true
463 swap:
464 file:
465 enabled: true
466 engine: file
467 device: /swapfile
468 size: 1024
469
Filip Pytlounc8a001a2015-12-15 14:09:19 +0100470LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
471
472.. code-block:: yaml
473
474 parameters:
475 linux:
476 storage:
477 mount:
478 data:
479 device: /dev/vg1/data
480 file_system: ext4
481 path: /mnt/data
482 lvm:
483 vg1:
484 enabled: true
485 devices:
486 - /dev/sdb
487 volume:
488 data:
489 size: 40G
490 mount: ${linux:storage:mount:data}
491
Filip Pytlounf5383a42015-10-06 16:28:32 +0200492Usage
493=====
494
495Set mtu of network interface eth0 to 1400
496
497.. code-block:: bash
498
499 ip link set dev eth0 mtu 1400
500
501Read more
502=========
503
504* https://www.archlinux.org/
505* http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu