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

9 years ago
9 years ago
8 years ago
8 years ago
8 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
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  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 autoupdates (automatically install security package updates)
  74. .. code-block:: yaml
  75. linux:
  76. system:
  77. ...
  78. autoupdates:
  79. enabled: true
  80. mail: root@localhost
  81. mail_only_on_error: true
  82. remove_unused_dependencies: false
  83. automatic_reboot: true
  84. automatic_reboot_time: "02:00"
  85. Linux with cron jobs
  86. .. code-block:: yaml
  87. linux:
  88. system:
  89. ...
  90. job:
  91. cmd1:
  92. command: '/cmd/to/run'
  93. enabled: true
  94. user: 'root'
  95. hour: 2
  96. minute: 0
  97. Linux security limits (limit sensu user memory usage to max 1GB):
  98. .. code-block:: yaml
  99. linux:
  100. system:
  101. ...
  102. limit:
  103. sensu:
  104. enabled: true
  105. domain: sensu
  106. limits:
  107. - type: hard
  108. item: as
  109. value: 1000000
  110. Enable autologin on tty1 (may work only for Ubuntu 14.04):
  111. .. code-block:: yaml
  112. linux:
  113. system:
  114. console:
  115. tty1:
  116. autologin: root
  117. # Enable serial console
  118. ttyS0:
  119. autologin: root
  120. rate: 115200
  121. term: xterm
  122. To disable set autologin to `false`.
  123. Set ``policy-rc.d`` on Debian-based systems. Action can be any available
  124. command in ``while true`` loop and ``case`` context.
  125. Following will disallow dpkg to stop/start services for cassandra package automatically:
  126. .. code-block:: yaml
  127. linux:
  128. system:
  129. policyrcd:
  130. - package: cassandra
  131. action: exit 101
  132. - package: '*'
  133. action: switch
  134. Set system locales:
  135. .. code-block:: yaml
  136. linux:
  137. system:
  138. locale:
  139. en_US.UTF-8:
  140. default: true
  141. "cs_CZ.UTF-8 UTF-8":
  142. enabled: true
  143. Kernel
  144. ~~~~~~
  145. Install always up to date LTS kernel and headers from Ubuntu trusty:
  146. .. code-block:: yaml
  147. linux:
  148. system:
  149. kernel:
  150. type: generic
  151. lts: trusty
  152. headers: true
  153. Load kernel modules and add them to `/etc/modules`:
  154. .. code-block:: yaml
  155. linux:
  156. system:
  157. kernel:
  158. modules:
  159. - nf_conntrack
  160. - tp_smapi
  161. - 8021q
  162. Install specific kernel version and ensure all other kernel packages are
  163. not present. Also install extra modules and headers for this kernel:
  164. .. code-block:: yaml
  165. linux:
  166. system:
  167. kernel:
  168. type: generic
  169. extra: true
  170. headers: true
  171. version: 4.2.0-22
  172. Systcl kernel parameters
  173. .. code-block:: yaml
  174. linux:
  175. system:
  176. kernel:
  177. sysctl:
  178. net.ipv4.tcp_keepalive_intvl: 3
  179. net.ipv4.tcp_keepalive_time: 30
  180. net.ipv4.tcp_keepalive_probes: 8
  181. CPU
  182. ~~~
  183. Disable ondemand cpu mode service:
  184. .. code-block:: yaml
  185. linux:
  186. system:
  187. cpu:
  188. governor: performance
  189. Huge Pages
  190. ~~~~~~~~~~~~
  191. Huge Pages give a performance boost to applications that intensively deal
  192. with memory allocation/deallocation by decreasing memory fragmentation.
  193. .. code-block:: yaml
  194. linux:
  195. system:
  196. kernel:
  197. hugepages:
  198. small:
  199. size: 2M
  200. count: 107520
  201. mount_point: /mnt/hugepages_2MB
  202. mount: false/true # default false
  203. large:
  204. default: true # default automatically mounted
  205. size: 1G
  206. count: 210
  207. mount_point: /mnt/hugepages_1GB
  208. Note: not recommended to use both pagesizes in concurrently.
  209. Intel SR-IOV
  210. ~~~~~~~~~~~~
  211. PCI-SIG Single Root I/O Virtualization and Sharing (SR-IOV) specification defines a standardized mechanism to virtualize PCIe devices. The mechanism can virtualize a single PCIe Ethernet controller to appear as multiple PCIe devices.
  212. .. code-block:: yaml
  213. linux:
  214. system:
  215. kernel:
  216. sriov: True
  217. unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
  218. rc:
  219. local: |
  220. #!/bin/sh -e
  221. # Enable 7 VF on eth1
  222. echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
  223. exit 0
  224. Repositories
  225. ~~~~~~~~~~~~
  226. RedHat based Linux with additional OpenStack repo
  227. .. code-block:: yaml
  228. linux:
  229. system:
  230. ...
  231. repo:
  232. rdo-icehouse:
  233. enabled: true
  234. source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
  235. pgpcheck: 0
  236. Ensure system repository to use czech Debian mirror (``default: true``)
  237. Also pin it's packages with priority 900.
  238. .. code-block:: yaml
  239. linux:
  240. system:
  241. repo:
  242. debian:
  243. default: true
  244. source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
  245. # Import signing key from URL if needed
  246. key_url: "http://dummy.com/public.gpg"
  247. pin:
  248. - pin: 'origin "ftp.cz.debian.org"'
  249. priority: 900
  250. package: '*'
  251. rc.local example
  252. .. code-block:: yaml
  253. linux:
  254. system:
  255. rc:
  256. local: |
  257. #!/bin/sh -e
  258. #
  259. # rc.local
  260. #
  261. # This script is executed at the end of each multiuser runlevel.
  262. # Make sure that the script will "exit 0" on success or any other
  263. # value on error.
  264. #
  265. # In order to enable or disable this script just change the execution
  266. # bits.
  267. #
  268. # By default this script does nothing.
  269. exit 0
  270. Prompt
  271. ~~~~~~
  272. Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
  273. user can have different prompt.
  274. .. code-block:: yaml
  275. linux:
  276. system:
  277. prompt:
  278. 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\\]
  279. default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
  280. On Debian systems to set prompt system-wide it's necessary to remove setting
  281. PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
  282. ``/etc/skel/.bashrc``). This formula will do this automatically, but will not
  283. touch existing user's ``~/.bashrc`` files except root.
  284. Bash
  285. ~~~~
  286. Fix bash configuration to preserve history across sessions (like ZSH does by
  287. default).
  288. .. code-block:: yaml
  289. linux:
  290. system:
  291. bash:
  292. preserve_history: true
  293. Message of the day
  294. ~~~~~~~~~~~~~~~~~~
  295. ``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
  296. day. Setting custom motd will cleanup existing ones.
  297. .. code-block:: yaml
  298. linux:
  299. system:
  300. motd:
  301. - release: |
  302. #!/bin/sh
  303. [ -r /etc/lsb-release ] && . /etc/lsb-release
  304. if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
  305. # Fall back to using the very slow lsb_release utility
  306. DISTRIB_DESCRIPTION=$(lsb_release -s -d)
  307. fi
  308. printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
  309. - warning: |
  310. #!/bin/sh
  311. printf "This is [company name] network.\n"
  312. printf "Unauthorized access strictly prohibited.\n"
  313. RHEL / CentOS
  314. ^^^^^^^^^^^^^
  315. Unfortunately ``update-motd`` is currently not available for RHEL so there's
  316. no native support for dynamic motd.
  317. You can still set static one, only pillar structure differs:
  318. .. code-block:: yaml
  319. linux:
  320. system:
  321. motd: |
  322. This is [company name] network.
  323. Unauthorized access strictly prohibited.
  324. Haveged
  325. ~~~~~~~
  326. If you are running headless server and are low on entropy, it may be a good
  327. idea to setup Haveged.
  328. .. code-block:: yaml
  329. linux:
  330. system:
  331. haveged:
  332. enabled: true
  333. Linux network
  334. -------------
  335. Linux with network manager
  336. .. code-block:: yaml
  337. linux:
  338. network:
  339. enabled: true
  340. network_manager: true
  341. Linux with default static network interfaces, default gateway interface and DNS servers
  342. .. code-block:: yaml
  343. linux:
  344. network:
  345. enabled: true
  346. interface:
  347. eth0:
  348. enabled: true
  349. type: eth
  350. address: 192.168.0.102
  351. netmask: 255.255.255.0
  352. gateway: 192.168.0.1
  353. name_servers:
  354. - 8.8.8.8
  355. - 8.8.4.4
  356. mtu: 1500
  357. Linux with bonded interfaces and disabled NetworkManager
  358. .. code-block:: yaml
  359. linux:
  360. network:
  361. enabled: true
  362. interface:
  363. eth0:
  364. type: eth
  365. ...
  366. eth1:
  367. type: eth
  368. ...
  369. bond0:
  370. enabled: true
  371. type: bond
  372. address: 192.168.0.102
  373. netmask: 255.255.255.0
  374. mtu: 1500
  375. use_in:
  376. - interface: ${linux:interface:eth0}
  377. - interface: ${linux:interface:eth0}
  378. network_manager:
  379. disable: true
  380. Linux with vlan interface_params
  381. .. code-block:: yaml
  382. linux:
  383. network:
  384. enabled: true
  385. interface:
  386. vlan69:
  387. type: vlan
  388. use_interfaces:
  389. - interface: ${linux:interface:bond0}
  390. Linux with wireless interface parameters
  391. .. code-block:: yaml
  392. linux:
  393. network:
  394. enabled: true
  395. gateway: 10.0.0.1
  396. default_interface: eth0
  397. interface:
  398. wlan0:
  399. type: eth
  400. wireless:
  401. essid: example
  402. key: example_key
  403. security: wpa
  404. priority: 1
  405. Linux networks with routes defined
  406. .. code-block:: yaml
  407. linux:
  408. network:
  409. enabled: true
  410. gateway: 10.0.0.1
  411. default_interface: eth0
  412. interface:
  413. eth0:
  414. type: eth
  415. route:
  416. default:
  417. address: 192.168.0.123
  418. netmask: 255.255.255.0
  419. gateway: 192.168.0.1
  420. Native Linux Bridges
  421. .. code-block:: yaml
  422. linux:
  423. network:
  424. interface:
  425. eth1:
  426. enabled: true
  427. type: eth
  428. proto: manual
  429. up_cmds:
  430. - ip address add 0/0 dev $IFACE
  431. - ip link set $IFACE up
  432. down_cmds:
  433. - ip link set $IFACE down
  434. br-ex:
  435. enabled: true
  436. type: bridge
  437. address: ${linux:network:host:public_local:address}
  438. netmask: 255.255.255.0
  439. use_interfaces:
  440. - eth1
  441. OpenVswitch Bridges
  442. .. code-block:: yaml
  443. linux:
  444. network:
  445. bridge: openvswitch
  446. interface:
  447. eth1:
  448. enabled: true
  449. type: eth
  450. proto: manual
  451. up_cmds:
  452. - ip address add 0/0 dev $IFACE
  453. - ip link set $IFACE up
  454. down_cmds:
  455. - ip link set $IFACE down
  456. br-ex:
  457. enabled: true
  458. type: bridge
  459. address: ${linux:network:host:public_local:address}
  460. netmask: 255.255.255.0
  461. use_interfaces:
  462. - eth1
  463. Linux with proxy
  464. .. code-block:: yaml
  465. linux:
  466. network:
  467. ...
  468. proxy:
  469. host: proxy.domain.com
  470. port: 3128
  471. Linux with hosts
  472. Parameter purge_hosts will enforce whole /etc/hosts file, removing entries
  473. that are not defined in model except defaults for both IPv4 and IPv6 localhost
  474. and hostname + fqdn.
  475. It's good to use this option if you want to ensure /etc/hosts is always in a
  476. clean state however it's not enabled by default for safety.
  477. .. code-block:: yaml
  478. linux:
  479. network:
  480. ...
  481. purge_hosts: true
  482. host:
  483. # No need to define this one if purge_hosts is true
  484. hostname:
  485. address: 127.0.1.1
  486. names:
  487. - ${linux:network:fqdn}
  488. - ${linux:network:hostname}
  489. node1:
  490. address: 192.168.10.200
  491. names:
  492. - node2.domain.com
  493. - service2.domain.com
  494. node2:
  495. address: 192.168.10.201
  496. names:
  497. - node2.domain.com
  498. - service2.domain.com
  499. Setup resolv.conf, nameservers, domain and search domains
  500. .. code-block:: yaml
  501. linux:
  502. network:
  503. resolv:
  504. dns:
  505. - 8.8.4.4
  506. - 8.8.8.8
  507. domain: my.example.com
  508. search:
  509. - my.example.com
  510. - example.com
  511. options:
  512. - ndots:5
  513. - timeout:2
  514. - attempts:2
  515. Linux storage pillars
  516. ---------------------
  517. Linux with mounted Samba
  518. .. code-block:: yaml
  519. linux:
  520. storage:
  521. enabled: true
  522. mount:
  523. samba1:
  524. - enabled: true
  525. - path: /media/myuser/public/
  526. - device: //192.168.0.1/storage
  527. - file_system: cifs
  528. - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
  529. Linux with file swap
  530. .. code-block:: yaml
  531. linux:
  532. storage:
  533. enabled: true
  534. swap:
  535. file:
  536. enabled: true
  537. engine: file
  538. device: /swapfile
  539. size: 1024
  540. Linux with partition swap
  541. .. code-block:: yaml
  542. linux:
  543. storage:
  544. enabled: true
  545. swap:
  546. partition:
  547. enabled: true
  548. engine: partition
  549. device: /dev/vg0/swap
  550. LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
  551. .. code-block:: yaml
  552. parameters:
  553. linux:
  554. storage:
  555. mount:
  556. data:
  557. enabled: true
  558. device: /dev/vg1/data
  559. file_system: ext4
  560. path: /mnt/data
  561. lvm:
  562. vg1:
  563. enabled: true
  564. devices:
  565. - /dev/sdb
  566. volume:
  567. data:
  568. size: 40G
  569. mount: ${linux:storage:mount:data}
  570. Multipath with Fujitsu Eternus DXL
  571. .. code-block:: yaml
  572. parameters:
  573. linux:
  574. storage:
  575. multipath:
  576. enabled: true
  577. blacklist_devices:
  578. - /dev/sda
  579. - /dev/sdb
  580. backends:
  581. - fujitsu_eternus_dxl
  582. Multipath with Hitachi VSP 1000
  583. .. code-block:: yaml
  584. parameters:
  585. linux:
  586. storage:
  587. multipath:
  588. enabled: true
  589. blacklist_devices:
  590. - /dev/sda
  591. - /dev/sdb
  592. backends:
  593. - hitachi_vsp1000
  594. Multipath with IBM Storwize
  595. .. code-block:: yaml
  596. parameters:
  597. linux:
  598. storage:
  599. multipath:
  600. enabled: true
  601. blacklist_devices:
  602. - /dev/sda
  603. - /dev/sdb
  604. backends:
  605. - ibm_storwize
  606. Multipath with multiple backends
  607. .. code-block:: yaml
  608. parameters:
  609. linux:
  610. storage:
  611. multipath:
  612. enabled: true
  613. blacklist_devices:
  614. - /dev/sda
  615. - /dev/sdb
  616. - /dev/sdc
  617. - /dev/sdd
  618. backends:
  619. - ibm_storwize
  620. - fujitsu_eternus_dxl
  621. - hitachi_vsp1000
  622. Disabled multipath (the default setup)
  623. .. code-block:: yaml
  624. parameters:
  625. linux:
  626. storage:
  627. multipath:
  628. enabled: false
  629. Linux with local loopback device
  630. .. code-block:: yaml
  631. linux:
  632. storage:
  633. loopback:
  634. disk1:
  635. file: /srv/disk1
  636. size: 50G
  637. External config generation
  638. --------------------------
  639. You are able to use config support metadata between formulas and only generate
  640. config files for external use, eg. docker, etc.
  641. .. code-block:: yaml
  642. parameters:
  643. linux:
  644. system:
  645. config:
  646. pillar:
  647. jenkins:
  648. master:
  649. home: /srv/volumes/jenkins
  650. approved_scripts:
  651. - method java.net.URL openConnection
  652. credentials:
  653. - type: username_password
  654. scope: global
  655. id: test
  656. desc: Testing credentials
  657. username: test
  658. password: test
  659. Usage
  660. =====
  661. Set mtu of network interface eth0 to 1400
  662. .. code-block:: bash
  663. ip link set dev eth0 mtu 1400
  664. Read more
  665. =========
  666. * https://www.archlinux.org/
  667. * http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu
  668. Documentation and Bugs
  669. ======================
  670. To learn how to install and update salt-formulas, consult the documentation
  671. available online at:
  672. http://salt-formulas.readthedocs.io/
  673. In the unfortunate event that bugs are discovered, they should be reported to
  674. the appropriate issue tracker. Use Github issue tracker for specific salt
  675. formula:
  676. https://github.com/salt-formulas/salt-formula-linux/issues
  677. For feature requests, bug reports or blueprints affecting entire ecosystem,
  678. use Launchpad salt-formulas project:
  679. https://launchpad.net/salt-formulas
  680. You can also join salt-formulas-users team and subscribe to mailing list:
  681. https://launchpad.net/~salt-formulas-users
  682. Developers wishing to work on the salt-formulas projects should always base
  683. their work on master branch and submit pull request against specific formula.
  684. https://github.com/salt-formulas/salt-formula-linux
  685. Any questions or feedback is always welcome so feel free to join our IRC
  686. channel:
  687. #salt-formulas @ irc.freenode.net