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.

9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  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. RHEL / CentOS
  232. ^^^^^^^^^^^^^
  233. Unfortunately ``update-motd`` is currently not available for RHEL so there's
  234. no native support for dynamic motd.
  235. You can still set static one, only pillar structure differs:
  236. .. code-block:: yaml
  237. linux:
  238. system:
  239. motd: |
  240. This is [company name] network.
  241. Unauthorized access strictly prohibited.
  242. Haveged
  243. ~~~~~~~
  244. If you are running headless server and are low on entropy, it may be a good
  245. idea to setup Haveged.
  246. .. code-block:: yaml
  247. linux:
  248. system:
  249. haveged:
  250. enabled: true
  251. Linux network
  252. -------------
  253. Linux with network manager
  254. .. code-block:: yaml
  255. linux:
  256. network:
  257. enabled: true
  258. network_manager: true
  259. Linux with default static network interfaces, default gateway interface and DNS servers
  260. .. code-block:: yaml
  261. linux:
  262. network:
  263. enabled: true
  264. interface:
  265. eth0:
  266. enabled: true
  267. type: eth
  268. address: 192.168.0.102
  269. netmask: 255.255.255.0
  270. gateway: 192.168.0.1
  271. name_servers:
  272. - 8.8.8.8
  273. - 8.8.4.4
  274. mtu: 1500
  275. Linux with bonded interfaces and disabled NetworkManager
  276. .. code-block:: yaml
  277. linux:
  278. network:
  279. enabled: true
  280. interface:
  281. eth0:
  282. type: eth
  283. ...
  284. eth1:
  285. type: eth
  286. ...
  287. bond0:
  288. enabled: true
  289. type: bond
  290. address: 192.168.0.102
  291. netmask: 255.255.255.0
  292. mtu: 1500
  293. use_in:
  294. - interface: ${linux:interface:eth0}
  295. - interface: ${linux:interface:eth0}
  296. network_manager:
  297. disable: true
  298. Linux with vlan interface_params
  299. .. code-block:: yaml
  300. linux:
  301. network:
  302. enabled: true
  303. interface:
  304. vlan69:
  305. type: vlan
  306. use_interfaces:
  307. - interface: ${linux:interface:bond0}
  308. Linux with wireless interface parameters
  309. .. code-block:: yaml
  310. linux:
  311. network:
  312. enabled: true
  313. gateway: 10.0.0.1
  314. default_interface: eth0
  315. interface:
  316. wlan0:
  317. type: eth
  318. wireless:
  319. essid: example
  320. key: example_key
  321. security: wpa
  322. priority: 1
  323. Linux networks with routes defined
  324. .. code-block:: yaml
  325. linux:
  326. network:
  327. enabled: true
  328. gateway: 10.0.0.1
  329. default_interface: eth0
  330. interface:
  331. eth0:
  332. type: eth
  333. route:
  334. default:
  335. address: 192.168.0.123
  336. netmask: 255.255.255.0
  337. gateway: 192.168.0.1
  338. Native Linux Bridges
  339. .. code-block:: yaml
  340. linux:
  341. network:
  342. interface:
  343. eth1:
  344. enabled: true
  345. type: eth
  346. proto: manual
  347. up_cmds:
  348. - ip address add 0/0 dev $IFACE
  349. - ip link set $IFACE up
  350. down_cmds:
  351. - ip link set $IFACE down
  352. br-ex:
  353. enabled: true
  354. type: bridge
  355. address: ${linux:network:host:public_local:address}
  356. netmask: 255.255.255.0
  357. use_interfaces:
  358. - eth1
  359. OpenVswitch Bridges
  360. .. code-block:: yaml
  361. linux:
  362. network:
  363. bridge: openvswitch
  364. interface:
  365. eth1:
  366. enabled: true
  367. type: eth
  368. proto: manual
  369. up_cmds:
  370. - ip address add 0/0 dev $IFACE
  371. - ip link set $IFACE up
  372. down_cmds:
  373. - ip link set $IFACE down
  374. br-ex:
  375. enabled: true
  376. type: bridge
  377. address: ${linux:network:host:public_local:address}
  378. netmask: 255.255.255.0
  379. use_interfaces:
  380. - eth1
  381. Linux with proxy
  382. .. code-block:: yaml
  383. linux:
  384. network:
  385. ...
  386. proxy:
  387. host: proxy.domain.com
  388. port: 3128
  389. Linux with hosts
  390. .. code-block:: yaml
  391. linux:
  392. network:
  393. ...
  394. host:
  395. node1:
  396. address: 192.168.10.200
  397. names:
  398. - node2.domain.com
  399. - service2.domain.com
  400. node2:
  401. address: 192.168.10.201
  402. names:
  403. - node2.domain.com
  404. - service2.domain.com
  405. Setup resolv.conf, nameservers, domain and search domains
  406. .. code-block:: yaml
  407. linux:
  408. network:
  409. resolv:
  410. dns:
  411. - 8.8.4.4
  412. - 8.8.8.8
  413. domain: my.example.com
  414. search:
  415. - my.example.com
  416. - example.com
  417. Linux storage pillars
  418. ---------------------
  419. Linux with mounted Samba
  420. .. code-block:: yaml
  421. linux:
  422. storage:
  423. enabled: true
  424. mount:
  425. samba1:
  426. - path: /media/myuser/public/
  427. - device: //192.168.0.1/storage
  428. - file_system: cifs
  429. - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
  430. Linux with file swap
  431. .. code-block:: yaml
  432. linux:
  433. storage:
  434. enabled: true
  435. swap:
  436. file:
  437. enabled: true
  438. engine: file
  439. device: /swapfile
  440. size: 1024
  441. Linux with partition swap
  442. .. code-block:: yaml
  443. linux:
  444. storage:
  445. enabled: true
  446. swap:
  447. partition:
  448. enabled: true
  449. engine: partition
  450. device: /dev/vg0/swap
  451. LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
  452. .. code-block:: yaml
  453. parameters:
  454. linux:
  455. storage:
  456. mount:
  457. data:
  458. device: /dev/vg1/data
  459. file_system: ext4
  460. path: /mnt/data
  461. lvm:
  462. vg1:
  463. enabled: true
  464. devices:
  465. - /dev/sdb
  466. volume:
  467. data:
  468. size: 40G
  469. mount: ${linux:storage:mount:data}
  470. Usage
  471. =====
  472. Set mtu of network interface eth0 to 1400
  473. .. code-block:: bash
  474. ip link set dev eth0 mtu 1400
  475. Read more
  476. =========
  477. * https://www.archlinux.org/
  478. * http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu