Saltstack Official Linux Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.rst 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. =====
  2. Linux
  3. =====
  4. Linux Operating Systems.
  5. * Ubuntu
  6. * CentOS
  7. * RedHat
  8. * Fedora
  9. * Arch
  10. Sample pillars
  11. ==============
  12. Linux system
  13. ------------
  14. Basic Linux box
  15. .. code-block:: yaml
  16. linux:
  17. system:
  18. enabled: true
  19. name: 'node1'
  20. domain: 'domain.com'
  21. cluster: 'system'
  22. environment: prod
  23. timezone: 'Europe/Prague'
  24. utc: true
  25. Linux with system users, sowe with password set
  26. .. code-block:: yaml
  27. linux:
  28. system:
  29. ...
  30. user:
  31. jdoe:
  32. name: 'jdoe'
  33. enabled: true
  34. sudo: true
  35. shell: /bin/bash
  36. full_name: 'Jonh Doe'
  37. home: '/home/jdoe'
  38. email: 'jonh@doe.com'
  39. jsmith:
  40. name: 'jsmith'
  41. enabled: true
  42. full_name: 'Password'
  43. home: '/home/jsmith'
  44. password: userpassword
  45. Linux with package, latest version
  46. .. code-block:: yaml
  47. linux:
  48. system:
  49. ...
  50. package:
  51. package-name:
  52. version: latest
  53. Linux with package from certail repo, version with no upgrades
  54. .. code-block:: yaml
  55. linux:
  56. system:
  57. ...
  58. package:
  59. package-name:
  60. version: 2132.323
  61. repo: 'custom-repo'
  62. hold: true
  63. Linux with package from certail repo, version with no GPG verification
  64. .. code-block:: yaml
  65. linux:
  66. system:
  67. ...
  68. package:
  69. package-name:
  70. version: 2132.323
  71. repo: 'custom-repo'
  72. verify: false
  73. Linux with cron jobs
  74. .. code-block:: yaml
  75. linux:
  76. system:
  77. ...
  78. job:
  79. cmd1:
  80. command: '/cmd/to/run'
  81. enabled: true
  82. user: 'root'
  83. hour: 2
  84. minute: 0
  85. Linux security limits (limit sensu user memory usage to max 1GB):
  86. .. code-block:: yaml
  87. linux:
  88. system:
  89. ...
  90. limit:
  91. sensu:
  92. enabled: true
  93. domain: sensu
  94. limits:
  95. - type: hard
  96. item: as
  97. value: 1000000
  98. Enable autologin on tty1 (may work only for Ubuntu 14.04):
  99. .. code-block:: yaml
  100. linux:
  101. system:
  102. console:
  103. tty1:
  104. autologin: root
  105. # Enable serial console
  106. ttyS0:
  107. autologin: root
  108. rate: 115200
  109. term: xterm
  110. To disable set autologin to `false`.
  111. Kernel
  112. ~~~~~~
  113. Install always up to date LTS kernel and headers from Ubuntu trusty:
  114. .. code-block:: yaml
  115. linux:
  116. system:
  117. kernel:
  118. type: generic
  119. lts: trusty
  120. headers: true
  121. Install specific kernel version and ensure all other kernel packages are
  122. not present. Also install extra modules and headers for this kernel:
  123. .. code-block:: yaml
  124. linux:
  125. system:
  126. kernel:
  127. type: generic
  128. extra: true
  129. headers: true
  130. version: 4.2.0-22
  131. Systcl kernel parameters
  132. .. code-block:: yaml
  133. linux:
  134. system:
  135. kernel:
  136. sysctl:
  137. net.ipv4.tcp_keepalive_intvl: 3
  138. net.ipv4.tcp_keepalive_time: 30
  139. net.ipv4.tcp_keepalive_probes: 8
  140. Repositories
  141. ~~~~~~~~~~~~
  142. RedHat based Linux with additional OpenStack repo
  143. .. code-block:: yaml
  144. linux:
  145. system:
  146. ...
  147. repo:
  148. rdo-icehouse:
  149. enabled: true
  150. source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
  151. pgpcheck: 0
  152. Ensure system repository to use czech Debian mirror (``default: true``)
  153. Also pin it's packages with priority 900.
  154. .. code-block:: yaml
  155. linux:
  156. system:
  157. repo:
  158. debian:
  159. default: true
  160. source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
  161. # Import signing key from URL if needed
  162. key_url: "http://dummy.com/public.gpg"
  163. pin:
  164. - pin: 'origin "ftp.cz.debian.org"'
  165. priority: 900
  166. package: '*'
  167. rc.local example
  168. .. code-block:: yaml
  169. linux:
  170. system:
  171. rc:
  172. local: |
  173. #!/bin/sh -e
  174. #
  175. # rc.local
  176. #
  177. # This script is executed at the end of each multiuser runlevel.
  178. # Make sure that the script will "exit 0" on success or any other
  179. # value on error.
  180. #
  181. # In order to enable or disable this script just change the execution
  182. # bits.
  183. #
  184. # By default this script does nothing.
  185. exit 0
  186. Prompt
  187. ~~~~~~
  188. Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
  189. user can have different prompt.
  190. .. code-block:: yaml
  191. linux:
  192. system:
  193. prompt:
  194. 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\\]
  195. default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
  196. On Debian systems to set prompt system-wide it's necessary to remove setting
  197. PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
  198. ``/etc/skel/.bashrc``). This formula will do this automatically, but will not
  199. touch existing user's ``~/.bashrc`` files except root.
  200. Message of the day
  201. ~~~~~~~~~~~~~~~~~~
  202. ``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
  203. day. Setting custom motd will cleanup existing ones.
  204. .. code-block:: yaml
  205. linux:
  206. system:
  207. motd:
  208. - release: |
  209. #!/bin/sh
  210. [ -r /etc/lsb-release ] && . /etc/lsb-release
  211. if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
  212. # Fall back to using the very slow lsb_release utility
  213. DISTRIB_DESCRIPTION=$(lsb_release -s -d)
  214. fi
  215. printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
  216. - warning: |
  217. #!/bin/sh
  218. printf "This is [company name] network.\n"
  219. printf "Unauthorized access strictly prohibited.\n"
  220. Linux network
  221. -------------
  222. Linux with network manager
  223. .. code-block:: yaml
  224. linux:
  225. network:
  226. enabled: true
  227. network_manager: true
  228. Linux with default static network interfaces, default gateway interface and DNS servers
  229. .. code-block:: yaml
  230. linux:
  231. network:
  232. enabled: true
  233. interface:
  234. eth0:
  235. enabled: true
  236. type: eth
  237. address: 192.168.0.102
  238. netmask: 255.255.255.0
  239. gateway: 192.168.0.1
  240. name_servers:
  241. - 8.8.8.8
  242. - 8.8.4.4
  243. mtu: 1500
  244. Linux with bonded interfaces and disabled NetworkManager
  245. .. code-block:: yaml
  246. linux:
  247. network:
  248. enabled: true
  249. interface:
  250. eth0:
  251. type: eth
  252. ...
  253. eth1:
  254. type: eth
  255. ...
  256. bond0:
  257. enabled: true
  258. type: bond
  259. address: 192.168.0.102
  260. netmask: 255.255.255.0
  261. mtu: 1500
  262. use_in:
  263. - interface: ${linux:interface:eth0}
  264. - interface: ${linux:interface:eth0}
  265. network_manager:
  266. disable: true
  267. Linux with vlan interface_params
  268. .. code-block:: yaml
  269. linux:
  270. network:
  271. enabled: true
  272. interface:
  273. vlan69:
  274. type: vlan
  275. use_interfaces:
  276. - interface: ${linux:interface:bond0}
  277. Linux with wireless interface parameters
  278. .. code-block:: yaml
  279. linux:
  280. network:
  281. enabled: true
  282. gateway: 10.0.0.1
  283. default_interface: eth0
  284. interface:
  285. wlan0:
  286. type: eth
  287. wireless:
  288. essid: example
  289. key: example_key
  290. security: wpa
  291. priority: 1
  292. Linux networks with routes defined
  293. .. code-block:: yaml
  294. linux:
  295. network:
  296. enabled: true
  297. gateway: 10.0.0.1
  298. default_interface: eth0
  299. interface:
  300. eth0:
  301. type: eth
  302. route:
  303. default:
  304. address: 192.168.0.123
  305. netmask: 255.255.255.0
  306. gateway: 192.168.0.1
  307. Native Linux Bridges
  308. .. code-block:: yaml
  309. linux:
  310. network:
  311. interface:
  312. eth1:
  313. enabled: true
  314. type: eth
  315. proto: manual
  316. up_cmds:
  317. - ip address add 0/0 dev $IFACE
  318. - ip link set $IFACE up
  319. down_cmds:
  320. - ip link set $IFACE down
  321. br-ex:
  322. enabled: true
  323. type: bridge
  324. address: ${linux:network:host:public_local:address}
  325. netmask: 255.255.255.0
  326. use_interfaces:
  327. - eth1
  328. OpenVswitch Bridges
  329. .. code-block:: yaml
  330. linux:
  331. network:
  332. bridge: openvswitch
  333. interface:
  334. eth1:
  335. enabled: true
  336. type: eth
  337. proto: manual
  338. up_cmds:
  339. - ip address add 0/0 dev $IFACE
  340. - ip link set $IFACE up
  341. down_cmds:
  342. - ip link set $IFACE down
  343. br-ex:
  344. enabled: true
  345. type: bridge
  346. address: ${linux:network:host:public_local:address}
  347. netmask: 255.255.255.0
  348. use_interfaces:
  349. - eth1
  350. Linux with proxy
  351. .. code-block:: yaml
  352. linux:
  353. network:
  354. ...
  355. proxy:
  356. host: proxy.domain.com
  357. port: 3128
  358. Linux with hosts
  359. .. code-block:: yaml
  360. linux:
  361. network:
  362. ...
  363. host:
  364. node1:
  365. address: 192.168.10.200
  366. names:
  367. - node2.domain.com
  368. - service2.domain.com
  369. node2:
  370. address: 192.168.10.201
  371. names:
  372. - node2.domain.com
  373. - service2.domain.com
  374. Setup resolv.conf, nameservers, domain and search domains
  375. .. code-block:: yaml
  376. linux:
  377. network:
  378. resolv:
  379. dns:
  380. - 8.8.4.4
  381. - 8.8.8.8
  382. domain: my.example.com
  383. search:
  384. - my.example.com
  385. - example.com
  386. Linux storage pillars
  387. ---------------------
  388. Linux with mounted Samba
  389. .. code-block:: yaml
  390. linux:
  391. storage:
  392. enabled: true
  393. mount:
  394. samba1:
  395. - path: /media/myuser/public/
  396. - device: //192.168.0.1/storage
  397. - file_system: cifs
  398. - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
  399. Linux with file swap
  400. .. code-block:: yaml
  401. linux:
  402. storage:
  403. enabled: true
  404. swap:
  405. file:
  406. enabled: true
  407. engine: file
  408. device: /swapfile
  409. size: 1024
  410. Linux with partition swap
  411. .. code-block:: yaml
  412. linux:
  413. storage:
  414. enabled: true
  415. swap:
  416. partition:
  417. enabled: true
  418. engine: partition
  419. device: /dev/vg0/swap
  420. LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
  421. .. code-block:: yaml
  422. parameters:
  423. linux:
  424. storage:
  425. mount:
  426. data:
  427. device: /dev/vg1/data
  428. file_system: ext4
  429. path: /mnt/data
  430. lvm:
  431. vg1:
  432. enabled: true
  433. devices:
  434. - /dev/sdb
  435. volume:
  436. data:
  437. size: 40G
  438. mount: ${linux:storage:mount:data}
  439. Usage
  440. =====
  441. Set mtu of network interface eth0 to 1400
  442. .. code-block:: bash
  443. ip link set dev eth0 mtu 1400
  444. Read more
  445. =========
  446. * https://www.archlinux.org/
  447. * http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu