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 13KB

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