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

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  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. Set ``policy-rc.d`` on Debian-based systems. Action can be any available
  112. command in ``while true`` loop and ``case`` context.
  113. Following will disallow dpkg to stop/start services for cassandra package automatically:
  114. .. code-block:: yaml
  115. linux:
  116. system:
  117. policyrcd:
  118. - package: cassandra
  119. action: exit 101
  120. - package: '*'
  121. action: switch
  122. Kernel
  123. ~~~~~~
  124. Install always up to date LTS kernel and headers from Ubuntu trusty:
  125. .. code-block:: yaml
  126. linux:
  127. system:
  128. kernel:
  129. type: generic
  130. lts: trusty
  131. headers: true
  132. Install specific kernel version and ensure all other kernel packages are
  133. not present. Also install extra modules and headers for this kernel:
  134. .. code-block:: yaml
  135. linux:
  136. system:
  137. kernel:
  138. type: generic
  139. extra: true
  140. headers: true
  141. version: 4.2.0-22
  142. Systcl kernel parameters
  143. .. code-block:: yaml
  144. linux:
  145. system:
  146. kernel:
  147. sysctl:
  148. net.ipv4.tcp_keepalive_intvl: 3
  149. net.ipv4.tcp_keepalive_time: 30
  150. net.ipv4.tcp_keepalive_probes: 8
  151. Repositories
  152. ~~~~~~~~~~~~
  153. RedHat based Linux with additional OpenStack repo
  154. .. code-block:: yaml
  155. linux:
  156. system:
  157. ...
  158. repo:
  159. rdo-icehouse:
  160. enabled: true
  161. source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
  162. pgpcheck: 0
  163. Ensure system repository to use czech Debian mirror (``default: true``)
  164. Also pin it's packages with priority 900.
  165. .. code-block:: yaml
  166. linux:
  167. system:
  168. repo:
  169. debian:
  170. default: true
  171. source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
  172. # Import signing key from URL if needed
  173. key_url: "http://dummy.com/public.gpg"
  174. pin:
  175. - pin: 'origin "ftp.cz.debian.org"'
  176. priority: 900
  177. package: '*'
  178. rc.local example
  179. .. code-block:: yaml
  180. linux:
  181. system:
  182. rc:
  183. local: |
  184. #!/bin/sh -e
  185. #
  186. # rc.local
  187. #
  188. # This script is executed at the end of each multiuser runlevel.
  189. # Make sure that the script will "exit 0" on success or any other
  190. # value on error.
  191. #
  192. # In order to enable or disable this script just change the execution
  193. # bits.
  194. #
  195. # By default this script does nothing.
  196. exit 0
  197. Prompt
  198. ~~~~~~
  199. Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
  200. user can have different prompt.
  201. .. code-block:: yaml
  202. linux:
  203. system:
  204. prompt:
  205. 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\\]
  206. default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
  207. On Debian systems to set prompt system-wide it's necessary to remove setting
  208. PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
  209. ``/etc/skel/.bashrc``). This formula will do this automatically, but will not
  210. touch existing user's ``~/.bashrc`` files except root.
  211. Message of the day
  212. ~~~~~~~~~~~~~~~~~~
  213. ``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
  214. day. Setting custom motd will cleanup existing ones.
  215. .. code-block:: yaml
  216. linux:
  217. system:
  218. motd:
  219. - release: |
  220. #!/bin/sh
  221. [ -r /etc/lsb-release ] && . /etc/lsb-release
  222. if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
  223. # Fall back to using the very slow lsb_release utility
  224. DISTRIB_DESCRIPTION=$(lsb_release -s -d)
  225. fi
  226. printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
  227. - warning: |
  228. #!/bin/sh
  229. printf "This is [company name] network.\n"
  230. printf "Unauthorized access strictly prohibited.\n"
  231. Linux network
  232. -------------
  233. Linux with network manager
  234. .. code-block:: yaml
  235. linux:
  236. network:
  237. enabled: true
  238. network_manager: true
  239. Linux with default static network interfaces, default gateway interface and DNS servers
  240. .. code-block:: yaml
  241. linux:
  242. network:
  243. enabled: true
  244. interface:
  245. eth0:
  246. enabled: true
  247. type: eth
  248. address: 192.168.0.102
  249. netmask: 255.255.255.0
  250. gateway: 192.168.0.1
  251. name_servers:
  252. - 8.8.8.8
  253. - 8.8.4.4
  254. mtu: 1500
  255. Linux with bonded interfaces and disabled NetworkManager
  256. .. code-block:: yaml
  257. linux:
  258. network:
  259. enabled: true
  260. interface:
  261. eth0:
  262. type: eth
  263. ...
  264. eth1:
  265. type: eth
  266. ...
  267. bond0:
  268. enabled: true
  269. type: bond
  270. address: 192.168.0.102
  271. netmask: 255.255.255.0
  272. mtu: 1500
  273. use_in:
  274. - interface: ${linux:interface:eth0}
  275. - interface: ${linux:interface:eth0}
  276. network_manager:
  277. disable: true
  278. Linux with vlan interface_params
  279. .. code-block:: yaml
  280. linux:
  281. network:
  282. enabled: true
  283. interface:
  284. vlan69:
  285. type: vlan
  286. use_interfaces:
  287. - interface: ${linux:interface:bond0}
  288. Linux with wireless interface parameters
  289. .. code-block:: yaml
  290. linux:
  291. network:
  292. enabled: true
  293. gateway: 10.0.0.1
  294. default_interface: eth0
  295. interface:
  296. wlan0:
  297. type: eth
  298. wireless:
  299. essid: example
  300. key: example_key
  301. security: wpa
  302. priority: 1
  303. Linux networks with routes defined
  304. .. code-block:: yaml
  305. linux:
  306. network:
  307. enabled: true
  308. gateway: 10.0.0.1
  309. default_interface: eth0
  310. interface:
  311. eth0:
  312. type: eth
  313. route:
  314. default:
  315. address: 192.168.0.123
  316. netmask: 255.255.255.0
  317. gateway: 192.168.0.1
  318. Native Linux Bridges
  319. .. code-block:: yaml
  320. linux:
  321. network:
  322. interface:
  323. eth1:
  324. enabled: true
  325. type: eth
  326. proto: manual
  327. up_cmds:
  328. - ip address add 0/0 dev $IFACE
  329. - ip link set $IFACE up
  330. down_cmds:
  331. - ip link set $IFACE down
  332. br-ex:
  333. enabled: true
  334. type: bridge
  335. address: ${linux:network:host:public_local:address}
  336. netmask: 255.255.255.0
  337. use_interfaces:
  338. - eth1
  339. OpenVswitch Bridges
  340. .. code-block:: yaml
  341. linux:
  342. network:
  343. bridge: openvswitch
  344. interface:
  345. eth1:
  346. enabled: true
  347. type: eth
  348. proto: manual
  349. up_cmds:
  350. - ip address add 0/0 dev $IFACE
  351. - ip link set $IFACE up
  352. down_cmds:
  353. - ip link set $IFACE down
  354. br-ex:
  355. enabled: true
  356. type: bridge
  357. address: ${linux:network:host:public_local:address}
  358. netmask: 255.255.255.0
  359. use_interfaces:
  360. - eth1
  361. Linux with proxy
  362. .. code-block:: yaml
  363. linux:
  364. network:
  365. ...
  366. proxy:
  367. host: proxy.domain.com
  368. port: 3128
  369. Linux with hosts
  370. .. code-block:: yaml
  371. linux:
  372. network:
  373. ...
  374. host:
  375. node1:
  376. address: 192.168.10.200
  377. names:
  378. - node2.domain.com
  379. - service2.domain.com
  380. node2:
  381. address: 192.168.10.201
  382. names:
  383. - node2.domain.com
  384. - service2.domain.com
  385. Setup resolv.conf, nameservers, domain and search domains
  386. .. code-block:: yaml
  387. linux:
  388. network:
  389. resolv:
  390. dns:
  391. - 8.8.4.4
  392. - 8.8.8.8
  393. domain: my.example.com
  394. search:
  395. - my.example.com
  396. - example.com
  397. Linux storage pillars
  398. ---------------------
  399. Linux with mounted Samba
  400. .. code-block:: yaml
  401. linux:
  402. storage:
  403. enabled: true
  404. mount:
  405. samba1:
  406. - path: /media/myuser/public/
  407. - device: //192.168.0.1/storage
  408. - file_system: cifs
  409. - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
  410. Linux with file swap
  411. .. code-block:: yaml
  412. linux:
  413. storage:
  414. enabled: true
  415. swap:
  416. file:
  417. enabled: true
  418. engine: file
  419. device: /swapfile
  420. size: 1024
  421. Linux with partition swap
  422. .. code-block:: yaml
  423. linux:
  424. storage:
  425. enabled: true
  426. swap:
  427. partition:
  428. enabled: true
  429. engine: partition
  430. device: /dev/vg0/swap
  431. LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
  432. .. code-block:: yaml
  433. parameters:
  434. linux:
  435. storage:
  436. mount:
  437. data:
  438. device: /dev/vg1/data
  439. file_system: ext4
  440. path: /mnt/data
  441. lvm:
  442. vg1:
  443. enabled: true
  444. devices:
  445. - /dev/sdb
  446. volume:
  447. data:
  448. size: 40G
  449. mount: ${linux:storage:mount:data}
  450. Usage
  451. =====
  452. Set mtu of network interface eth0 to 1400
  453. .. code-block:: bash
  454. ip link set dev eth0 mtu 1400
  455. Read more
  456. =========
  457. * https://www.archlinux.org/
  458. * http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu