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

8 년 전
8 년 전
8 년 전
8 년 전
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433
  1. ============
  2. Linux Fomula
  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, some with password set:
  26. .. WARNING::
  27. If no 'password' variable has been passed - any predifined password
  28. will be removed.
  29. .. code-block:: yaml
  30. linux:
  31. system:
  32. ...
  33. user:
  34. jdoe:
  35. name: 'jdoe'
  36. enabled: true
  37. sudo: true
  38. shell: /bin/bash
  39. full_name: 'Jonh Doe'
  40. home: '/home/jdoe'
  41. email: 'jonh@doe.com'
  42. jsmith:
  43. name: 'jsmith'
  44. enabled: true
  45. full_name: 'With clear password'
  46. home: '/home/jsmith'
  47. hash_password: true
  48. password: "userpassword"
  49. mark:
  50. name: 'mark'
  51. enabled: true
  52. full_name: "unchange password'
  53. home: '/home/mark'
  54. password: false
  55. elizabeth:
  56. name: 'elizabeth'
  57. enabled: true
  58. full_name: 'With hased password'
  59. home: '/home/elizabeth'
  60. password: "$6$nUI7QEz3$dFYjzQqK5cJ6HQ38KqG4gTWA9eJu3aKx6TRVDFh6BVJxJgFWg2akfAA7f1fCxcSUeOJ2arCO6EEI6XXnHXxG10"
  61. Configure sudo for users and groups under ``/etc/sudoers.d/``.
  62. This ways ``linux.system.sudo`` pillar map to actual sudo attributes:
  63. .. code-block:: jinja
  64. # simplified template:
  65. Cmds_Alias {{ alias }}={{ commands }}
  66. {{ user }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
  67. %{{ group }} {{ hosts }}=({{ runas }}) NOPASSWD: {{ commands }}
  68. # when rendered:
  69. saltuser1 ALL=(ALL) NOPASSWD: ALL
  70. .. code-block:: yaml
  71. linux:
  72. system:
  73. sudo:
  74. enabled: true
  75. aliases:
  76. host:
  77. LOCAL:
  78. - localhost
  79. PRODUCTION:
  80. - db1
  81. - db2
  82. runas:
  83. DBA:
  84. - postgres
  85. - mysql
  86. SALT:
  87. - root
  88. command:
  89. # Note: This is not 100% safe when ALL keyword is used, user still may modify configs and hide his actions.
  90. # Best practice is to specify full list of commands user is allowed to run.
  91. SUPPORT_RESTRICTED:
  92. - /bin/vi /etc/sudoers*
  93. - /bin/vim /etc/sudoers*
  94. - /bin/nano /etc/sudoers*
  95. - /bin/emacs /etc/sudoers*
  96. - /bin/su - root
  97. - /bin/su -
  98. - /bin/su
  99. - /usr/sbin/visudo
  100. SUPPORT_SHELLS:
  101. - /bin/sh
  102. - /bin/ksh
  103. - /bin/bash
  104. - /bin/rbash
  105. - /bin/dash
  106. - /bin/zsh
  107. - /bin/csh
  108. - /bin/fish
  109. - /bin/tcsh
  110. - /usr/bin/login
  111. - /usr/bin/su
  112. - /usr/su
  113. ALL_SALT_SAFE:
  114. - /usr/bin/salt state*
  115. - /usr/bin/salt service*
  116. - /usr/bin/salt pillar*
  117. - /usr/bin/salt grains*
  118. - /usr/bin/salt saltutil*
  119. - /usr/bin/salt-call state*
  120. - /usr/bin/salt-call service*
  121. - /usr/bin/salt-call pillar*
  122. - /usr/bin/salt-call grains*
  123. - /usr/bin/salt-call saltutil*
  124. SALT_TRUSTED:
  125. - /usr/bin/salt*
  126. users:
  127. # saltuser1 with default values: saltuser1 ALL=(ALL) NOPASSWD: ALL
  128. saltuser1: {}
  129. saltuser2:
  130. hosts:
  131. - LOCAL
  132. # User Alias DBA
  133. DBA:
  134. hosts:
  135. - ALL
  136. commands:
  137. - ALL_SALT_SAFE
  138. groups:
  139. db-ops:
  140. hosts:
  141. - ALL
  142. - '!PRODUCTION'
  143. runas:
  144. - DBA
  145. commands:
  146. - /bin/cat *
  147. - /bin/less *
  148. - /bin/ls *
  149. salt-ops:
  150. hosts:
  151. - 'ALL'
  152. runas:
  153. - SALT
  154. commands:
  155. - SUPPORT_SHELLS
  156. salt-ops-2nd:
  157. name: salt-ops
  158. nopasswd: false
  159. setenv: true # Enable sudo -E option
  160. runas:
  161. - DBA
  162. commands:
  163. - ALL
  164. - '!SUPPORT_SHELLS'
  165. - '!SUPPORT_RESTRICTED'
  166. Linux with package, latest version
  167. .. code-block:: yaml
  168. linux:
  169. system:
  170. ...
  171. package:
  172. package-name:
  173. version: latest
  174. Linux with package from certail repo, version with no upgrades
  175. .. code-block:: yaml
  176. linux:
  177. system:
  178. ...
  179. package:
  180. package-name:
  181. version: 2132.323
  182. repo: 'custom-repo'
  183. hold: true
  184. Linux with package from certail repo, version with no GPG verification
  185. .. code-block:: yaml
  186. linux:
  187. system:
  188. ...
  189. package:
  190. package-name:
  191. version: 2132.323
  192. repo: 'custom-repo'
  193. verify: false
  194. Linux with autoupdates (automatically install security package updates)
  195. .. code-block:: yaml
  196. linux:
  197. system:
  198. ...
  199. autoupdates:
  200. enabled: true
  201. mail: root@localhost
  202. mail_only_on_error: true
  203. remove_unused_dependencies: false
  204. automatic_reboot: true
  205. automatic_reboot_time: "02:00"
  206. Linux with cron jobs
  207. .. code-block:: yaml
  208. linux:
  209. system:
  210. ...
  211. job:
  212. cmd1:
  213. command: '/cmd/to/run'
  214. enabled: true
  215. user: 'root'
  216. hour: 2
  217. minute: 0
  218. Linux security limits (limit sensu user memory usage to max 1GB):
  219. .. code-block:: yaml
  220. linux:
  221. system:
  222. ...
  223. limit:
  224. sensu:
  225. enabled: true
  226. domain: sensu
  227. limits:
  228. - type: hard
  229. item: as
  230. value: 1000000
  231. Enable autologin on tty1 (may work only for Ubuntu 14.04):
  232. .. code-block:: yaml
  233. linux:
  234. system:
  235. console:
  236. tty1:
  237. autologin: root
  238. # Enable serial console
  239. ttyS0:
  240. autologin: root
  241. rate: 115200
  242. term: xterm
  243. To disable set autologin to `false`.
  244. Set ``policy-rc.d`` on Debian-based systems. Action can be any available
  245. command in ``while true`` loop and ``case`` context.
  246. Following will disallow dpkg to stop/start services for cassandra package automatically:
  247. .. code-block:: yaml
  248. linux:
  249. system:
  250. policyrcd:
  251. - package: cassandra
  252. action: exit 101
  253. - package: '*'
  254. action: switch
  255. Set system locales:
  256. .. code-block:: yaml
  257. linux:
  258. system:
  259. locale:
  260. en_US.UTF-8:
  261. default: true
  262. "cs_CZ.UTF-8 UTF-8":
  263. enabled: true
  264. Systemd settings:
  265. .. code-block:: yaml
  266. linux:
  267. system:
  268. ...
  269. systemd:
  270. system:
  271. Manager:
  272. DefaultLimitNOFILE: 307200
  273. DefaultLimitNPROC: 307200
  274. user:
  275. Manager:
  276. DefaultLimitCPU: 2
  277. DefaultLimitNPROC: 4
  278. Kernel
  279. ~~~~~~
  280. Install always up to date LTS kernel and headers from Ubuntu trusty:
  281. .. code-block:: yaml
  282. linux:
  283. system:
  284. kernel:
  285. type: generic
  286. lts: trusty
  287. headers: true
  288. Load kernel modules and add them to `/etc/modules`:
  289. .. code-block:: yaml
  290. linux:
  291. system:
  292. kernel:
  293. modules:
  294. - nf_conntrack
  295. - tp_smapi
  296. - 8021q
  297. Configure or blacklist kernel modules with additional options to `/etc/modprobe.d` following example
  298. will add `/etc/modprobe.d/nf_conntrack.conf` file with line `options nf_conntrack hashsize=262144`:
  299. .. code-block:: yaml
  300. linux:
  301. system:
  302. kernel:
  303. module:
  304. nf_conntrack:
  305. option:
  306. hashsize: 262144
  307. Install specific kernel version and ensure all other kernel packages are
  308. not present. Also install extra modules and headers for this kernel:
  309. .. code-block:: yaml
  310. linux:
  311. system:
  312. kernel:
  313. type: generic
  314. extra: true
  315. headers: true
  316. version: 4.2.0-22
  317. Systcl kernel parameters
  318. .. code-block:: yaml
  319. linux:
  320. system:
  321. kernel:
  322. sysctl:
  323. net.ipv4.tcp_keepalive_intvl: 3
  324. net.ipv4.tcp_keepalive_time: 30
  325. net.ipv4.tcp_keepalive_probes: 8
  326. CPU
  327. ~~~
  328. Enable cpufreq governor for every cpu:
  329. .. code-block:: yaml
  330. linux:
  331. system:
  332. cpu:
  333. governor: performance
  334. Huge Pages
  335. ~~~~~~~~~~~~
  336. Huge Pages give a performance boost to applications that intensively deal
  337. with memory allocation/deallocation by decreasing memory fragmentation.
  338. .. code-block:: yaml
  339. linux:
  340. system:
  341. kernel:
  342. hugepages:
  343. small:
  344. size: 2M
  345. count: 107520
  346. mount_point: /mnt/hugepages_2MB
  347. mount: false/true # default false
  348. large:
  349. default: true # default automatically mounted
  350. size: 1G
  351. count: 210
  352. mount_point: /mnt/hugepages_1GB
  353. Note: not recommended to use both pagesizes in concurrently.
  354. Intel SR-IOV
  355. ~~~~~~~~~~~~
  356. 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.
  357. .. code-block:: yaml
  358. linux:
  359. system:
  360. kernel:
  361. sriov: True
  362. unsafe_interrupts: False # Default is false. for older platforms and AMD we need to add interrupt remapping workaround
  363. rc:
  364. local: |
  365. #!/bin/sh -e
  366. # Enable 7 VF on eth1
  367. echo 7 > /sys/class/net/eth1/device/sriov_numvfs; sleep 2; ifup -a
  368. exit 0
  369. Isolate CPU options
  370. ~~~~~~~~~~~~~~~~~~~
  371. Remove the specified CPUs, as defined by the cpu_number values, from the general kernel
  372. SMP balancing and scheduler algroithms. The only way to move a process onto or off an
  373. "isolated" CPU is via the CPU affinity syscalls. cpu_number begins at 0, so the
  374. maximum value is 1 less than the number of CPUs on the system.
  375. .. code-block:: yaml
  376. linux:
  377. system:
  378. kernel:
  379. isolcpu: 1,2,3,4,5,6,7 # isolate first cpu 0
  380. Repositories
  381. ~~~~~~~~~~~~
  382. RedHat based Linux with additional OpenStack repo
  383. .. code-block:: yaml
  384. linux:
  385. system:
  386. ...
  387. repo:
  388. rdo-icehouse:
  389. enabled: true
  390. source: 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6/'
  391. pgpcheck: 0
  392. Ensure system repository to use czech Debian mirror (``default: true``)
  393. Also pin it's packages with priority 900.
  394. .. code-block:: yaml
  395. linux:
  396. system:
  397. repo:
  398. debian:
  399. default: true
  400. source: "deb http://ftp.cz.debian.org/debian/ jessie main contrib non-free"
  401. # Import signing key from URL if needed
  402. key_url: "http://dummy.com/public.gpg"
  403. pin:
  404. - pin: 'origin "ftp.cz.debian.org"'
  405. priority: 900
  406. package: '*'
  407. Package manager proxy setup globally:
  408. .. code-block:: yaml
  409. linux:
  410. system:
  411. ...
  412. repo:
  413. apt-mk:
  414. source: "deb http://apt-mk.mirantis.com/ stable main salt"
  415. ...
  416. proxy:
  417. pkg:
  418. enabled: true
  419. ftp: ftp://ftp-proxy-for-apt.host.local:2121
  420. ...
  421. # NOTE: Global defaults for any other componet that configure proxy on the system.
  422. # If your environment has just one simple proxy, set it on linux:system:proxy.
  423. #
  424. # fall back system defaults if linux:system:proxy:pkg has no protocol specific entries
  425. # as for https and http
  426. ftp: ftp://proxy.host.local:2121
  427. http: http://proxy.host.local:3142
  428. https: https://proxy.host.local:3143
  429. Package manager proxy setup per repository:
  430. .. code-block:: yaml
  431. linux:
  432. system:
  433. ...
  434. repo:
  435. debian:
  436. source: "deb http://apt-mk.mirantis.com/ stable main salt"
  437. ...
  438. apt-mk:
  439. source: "deb http://apt-mk.mirantis.com/ stable main salt"
  440. # per repository proxy
  441. proxy:
  442. enabled: true
  443. http: http://maas-01:8080
  444. https: http://maas-01:8080
  445. ...
  446. proxy:
  447. # package manager fallback defaults
  448. # used if linux:system:repo:apt-mk:proxy has no protocol specific entries
  449. pkg:
  450. enabled: true
  451. ftp: ftp://proxy.host.local:2121
  452. #http: http://proxy.host.local:3142
  453. #https: https://proxy.host.local:3143
  454. ...
  455. # global system fallback system defaults
  456. ftp: ftp://proxy.host.local:2121
  457. http: http://proxy.host.local:3142
  458. https: https://proxy.host.local:3143
  459. Remove all repositories:
  460. .. code-block:: yaml
  461. linux:
  462. system:
  463. purge_repos: true
  464. RC
  465. ~~
  466. rc.local example
  467. .. code-block:: yaml
  468. linux:
  469. system:
  470. rc:
  471. local: |
  472. #!/bin/sh -e
  473. #
  474. # rc.local
  475. #
  476. # This script is executed at the end of each multiuser runlevel.
  477. # Make sure that the script will "exit 0" on success or any other
  478. # value on error.
  479. #
  480. # In order to enable or disable this script just change the execution
  481. # bits.
  482. #
  483. # By default this script does nothing.
  484. exit 0
  485. Prompt
  486. ~~~~~~
  487. Setting prompt is implemented by creating ``/etc/profile.d/prompt.sh``. Every
  488. user can have different prompt.
  489. .. code-block:: yaml
  490. linux:
  491. system:
  492. prompt:
  493. 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\\]
  494. default: \\n\\D{%y/%m/%d %H:%M:%S} $(hostname -f)\\n[\\u@\\h:\\w]
  495. On Debian systems to set prompt system-wide it's necessary to remove setting
  496. PS1 in ``/etc/bash.bashrc`` and ``~/.bashrc`` (which comes from
  497. ``/etc/skel/.bashrc``). This formula will do this automatically, but will not
  498. touch existing user's ``~/.bashrc`` files except root.
  499. Bash
  500. ~~~~
  501. Fix bash configuration to preserve history across sessions (like ZSH does by
  502. default).
  503. .. code-block:: yaml
  504. linux:
  505. system:
  506. bash:
  507. preserve_history: true
  508. Message of the day
  509. ~~~~~~~~~~~~~~~~~~
  510. ``pam_motd`` from package ``update-motd`` is used for dynamic messages of the
  511. day. Setting custom motd will cleanup existing ones.
  512. .. code-block:: yaml
  513. linux:
  514. system:
  515. motd:
  516. - release: |
  517. #!/bin/sh
  518. [ -r /etc/lsb-release ] && . /etc/lsb-release
  519. if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
  520. # Fall back to using the very slow lsb_release utility
  521. DISTRIB_DESCRIPTION=$(lsb_release -s -d)
  522. fi
  523. printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
  524. - warning: |
  525. #!/bin/sh
  526. printf "This is [company name] network.\n"
  527. printf "Unauthorized access strictly prohibited.\n"
  528. Services
  529. ~~~~~~~~
  530. Stop and disable linux service:
  531. .. code-block:: yaml
  532. linux:
  533. system:
  534. service:
  535. apt-daily.timer:
  536. status: dead
  537. Possible status is dead (disable service by default), running (enable service by default), enabled, disabled.
  538. RHEL / CentOS
  539. ^^^^^^^^^^^^^
  540. Unfortunately ``update-motd`` is currently not available for RHEL so there's
  541. no native support for dynamic motd.
  542. You can still set static one, only pillar structure differs:
  543. .. code-block:: yaml
  544. linux:
  545. system:
  546. motd: |
  547. This is [company name] network.
  548. Unauthorized access strictly prohibited.
  549. Haveged
  550. ~~~~~~~
  551. If you are running headless server and are low on entropy, it may be a good
  552. idea to setup Haveged.
  553. .. code-block:: yaml
  554. linux:
  555. system:
  556. haveged:
  557. enabled: true
  558. Linux network
  559. -------------
  560. Linux with network manager
  561. .. code-block:: yaml
  562. linux:
  563. network:
  564. enabled: true
  565. network_manager: true
  566. Linux with default static network interfaces, default gateway interface and DNS servers
  567. .. code-block:: yaml
  568. linux:
  569. network:
  570. enabled: true
  571. interface:
  572. eth0:
  573. enabled: true
  574. type: eth
  575. address: 192.168.0.102
  576. netmask: 255.255.255.0
  577. gateway: 192.168.0.1
  578. name_servers:
  579. - 8.8.8.8
  580. - 8.8.4.4
  581. mtu: 1500
  582. Linux with bonded interfaces and disabled NetworkManager
  583. .. code-block:: yaml
  584. linux:
  585. network:
  586. enabled: true
  587. interface:
  588. eth0:
  589. type: eth
  590. ...
  591. eth1:
  592. type: eth
  593. ...
  594. bond0:
  595. enabled: true
  596. type: bond
  597. address: 192.168.0.102
  598. netmask: 255.255.255.0
  599. mtu: 1500
  600. use_in:
  601. - interface: ${linux:interface:eth0}
  602. - interface: ${linux:interface:eth0}
  603. network_manager:
  604. disable: true
  605. Linux with vlan interface_params
  606. .. code-block:: yaml
  607. linux:
  608. network:
  609. enabled: true
  610. interface:
  611. vlan69:
  612. type: vlan
  613. use_interfaces:
  614. - interface: ${linux:interface:bond0}
  615. Linux with wireless interface parameters
  616. .. code-block:: yaml
  617. linux:
  618. network:
  619. enabled: true
  620. gateway: 10.0.0.1
  621. default_interface: eth0
  622. interface:
  623. wlan0:
  624. type: eth
  625. wireless:
  626. essid: example
  627. key: example_key
  628. security: wpa
  629. priority: 1
  630. Linux networks with routes defined
  631. .. code-block:: yaml
  632. linux:
  633. network:
  634. enabled: true
  635. gateway: 10.0.0.1
  636. default_interface: eth0
  637. interface:
  638. eth0:
  639. type: eth
  640. route:
  641. default:
  642. address: 192.168.0.123
  643. netmask: 255.255.255.0
  644. gateway: 192.168.0.1
  645. Native Linux Bridges
  646. .. code-block:: yaml
  647. linux:
  648. network:
  649. interface:
  650. eth1:
  651. enabled: true
  652. type: eth
  653. proto: manual
  654. up_cmds:
  655. - ip address add 0/0 dev $IFACE
  656. - ip link set $IFACE up
  657. down_cmds:
  658. - ip link set $IFACE down
  659. br-ex:
  660. enabled: true
  661. type: bridge
  662. address: ${linux:network:host:public_local:address}
  663. netmask: 255.255.255.0
  664. use_interfaces:
  665. - eth1
  666. OpenVswitch Bridges
  667. .. code-block:: yaml
  668. linux:
  669. network:
  670. bridge: openvswitch
  671. interface:
  672. eth1:
  673. enabled: true
  674. type: eth
  675. proto: manual
  676. up_cmds:
  677. - ip address add 0/0 dev $IFACE
  678. - ip link set $IFACE up
  679. down_cmds:
  680. - ip link set $IFACE down
  681. br-ex:
  682. enabled: true
  683. type: bridge
  684. address: ${linux:network:host:public_local:address}
  685. netmask: 255.255.255.0
  686. use_interfaces:
  687. - eth1
  688. Concatinating and removing interface files
  689. Debian based distributions have `/etc/network/interfaces.d/` directory, where
  690. you can store configuration of network interfaces in separate files. You can
  691. concatinate the files to the defined destination when needed, this operation
  692. removes the file from the `/etc/network/interfaces.d/`. If you just need to
  693. remove iface files, you can use the `remove_iface_files` key.
  694. .. code-block:: yaml
  695. linux:
  696. network:
  697. concat_iface_files:
  698. - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
  699. dst: '/etc/network/interfaces'
  700. remove_iface_files:
  701. - '/etc/network/interfaces.d/90-custom.cfg'
  702. DHCP client configuration
  703. None of the keys is mandatory, include only those you really need. For full list
  704. of available options under send, supersede, prepend, append refer to dhcp-options(5)
  705. .. code-block:: yaml
  706. linux:
  707. network:
  708. dhclient:
  709. enabled: true
  710. backoff_cutoff: 15
  711. initial_interval: 10
  712. reboot: 10
  713. retry: 60
  714. select_timeout: 0
  715. timeout: 120
  716. send:
  717. - option: host-name
  718. declaration: "= gethostname()"
  719. supersede:
  720. - option: host-name
  721. declaration: "spaceship"
  722. - option: domain-name
  723. declaration: "domain.home"
  724. #- option: arp-cache-timeout
  725. # declaration: 20
  726. prepend:
  727. - option: domain-name-servers
  728. declaration:
  729. - 8.8.8.8
  730. - 8.8.4.4
  731. - option: domain-search
  732. declaration:
  733. - example.com
  734. - eng.example.com
  735. #append:
  736. #- option: domain-name-servers
  737. # declaration: 127.0.0.1
  738. # ip or subnet to reject dhcp offer from
  739. reject:
  740. - 192.33.137.209
  741. - 10.0.2.0/24
  742. request:
  743. - subnet-mask
  744. - broadcast-address
  745. - time-offset
  746. - routers
  747. - domain-name
  748. - domain-name-servers
  749. - domain-search
  750. - host-name
  751. - dhcp6.name-servers
  752. - dhcp6.domain-search
  753. - dhcp6.fqdn
  754. - dhcp6.sntp-servers
  755. - netbios-name-servers
  756. - netbios-scope
  757. - interface-mtu
  758. - rfc3442-classless-static-routes
  759. - ntp-servers
  760. require:
  761. - subnet-mask
  762. - domain-name-servers
  763. # if per interface configuration required add below
  764. interface:
  765. ens2:
  766. initial_interval: 11
  767. reject:
  768. - 192.33.137.210
  769. ens3:
  770. initial_interval: 12
  771. reject:
  772. - 192.33.137.211
  773. Configure global environment variables
  774. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  775. Linux /etc/environment:
  776. ``/etc/environment`` is for static system wide variable assignment after boot. Variable expansion is frequently not supported.
  777. .. code-block:: yaml
  778. linux:
  779. system:
  780. env:
  781. BOB_VARIABLE: Alice
  782. ...
  783. BOB_PATH:
  784. - /srv/alice/bin
  785. - /srv/bob/bin
  786. ...
  787. ftp_proxy: none
  788. http_proxy: http://global-http-proxy.host.local:8080
  789. https_proxy: ${linux:system:proxy:https}
  790. no_proxy:
  791. - 192.168.0.80
  792. - 192.168.1.80
  793. - .domain.com
  794. - .local
  795. ...
  796. # NOTE: global defaults proxy configuration.
  797. proxy:
  798. ftp: ftp://proxy.host.local:2121
  799. http: http://proxy.host.local:3142
  800. https: https://proxy.host.local:3143
  801. noproxy:
  802. - .domain.com
  803. - .local
  804. Configure profile.d scripts
  805. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  806. Linux /etc/profile.d:
  807. The profile.d scripts are being sourced during .sh execution and support variable expansion in opposite to /etc/environment
  808. global settings in ``/etc/environment``.
  809. .. code-block:: yaml
  810. linux:
  811. system:
  812. profile:
  813. locales: |
  814. export LANG=C
  815. export LC_ALL=C
  816. ...
  817. vi_flavors.sh: |
  818. export PAGER=view
  819. export EDITOR=vim
  820. alias vi=vim
  821. shell_locales.sh: |
  822. export LANG=en_US
  823. export LC_ALL=en_US.UTF-8
  824. shell_proxies.sh: |
  825. export FTP_PROXY=ftp://127.0.3.3:2121
  826. export NO_PROXY='.local'
  827. Linux with hosts
  828. ~~~~~~~~~~~~~~~~
  829. Parameter purge_hosts will enforce whole /etc/hosts file, removing entries
  830. that are not defined in model except defaults for both IPv4 and IPv6 localhost
  831. and hostname + fqdn.
  832. It's good to use this option if you want to ensure /etc/hosts is always in a
  833. clean state however it's not enabled by default for safety.
  834. .. code-block:: yaml
  835. linux:
  836. network:
  837. ...
  838. purge_hosts: true
  839. host:
  840. # No need to define this one if purge_hosts is true
  841. hostname:
  842. address: 127.0.1.1
  843. names:
  844. - ${linux:network:fqdn}
  845. - ${linux:network:hostname}
  846. node1:
  847. address: 192.168.10.200
  848. names:
  849. - node2.domain.com
  850. - service2.domain.com
  851. node2:
  852. address: 192.168.10.201
  853. names:
  854. - node2.domain.com
  855. - service2.domain.com
  856. Setup resolv.conf, nameservers, domain and search domains
  857. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  858. .. code-block:: yaml
  859. linux:
  860. network:
  861. resolv:
  862. dns:
  863. - 8.8.4.4
  864. - 8.8.8.8
  865. domain: my.example.com
  866. search:
  867. - my.example.com
  868. - example.com
  869. options:
  870. - ndots: 5
  871. - timeout: 2
  872. - attempts: 2
  873. **setting custom TX queue length for tap interfaces**
  874. .. code-block:: yaml
  875. linux:
  876. network:
  877. tap_custom_txqueuelen: 10000
  878. DPDK OVS interfaces
  879. --------------------
  880. **DPDK OVS NIC**
  881. .. code-block:: yaml
  882. linux:
  883. network:
  884. bridge: openvswitch
  885. dpdk:
  886. enabled: true
  887. driver: uio/vfio
  888. openvswitch:
  889. pmd_cpu_mask: "0x6"
  890. dpdk_socket_mem: "1024,1024"
  891. dpdk_lcore_mask: "0x400"
  892. memory_channels: 2
  893. interface:
  894. dpkd0:
  895. name: ${_param:dpdk_nic}
  896. pci: 0000:06:00.0
  897. driver: igb_uio/vfio-pci
  898. enabled: true
  899. type: dpdk_ovs_port
  900. n_rxq: 2
  901. pmd_rxq_affinity: "0:1,1:2"
  902. bridge: br-prv
  903. mtu: 9000
  904. br-prv:
  905. enabled: true
  906. type: dpdk_ovs_bridge
  907. **DPDK OVS Bond**
  908. .. code-block:: yaml
  909. linux:
  910. network:
  911. bridge: openvswitch
  912. dpdk:
  913. enabled: true
  914. driver: uio/vfio
  915. openvswitch:
  916. pmd_cpu_mask: "0x6"
  917. dpdk_socket_mem: "1024,1024"
  918. dpdk_lcore_mask: "0x400"
  919. memory_channels: 2
  920. interface:
  921. dpdk_second_nic:
  922. name: ${_param:primary_second_nic}
  923. pci: 0000:06:00.0
  924. driver: igb_uio/vfio-pci
  925. bond: dpdkbond0
  926. enabled: true
  927. type: dpdk_ovs_port
  928. n_rxq: 2
  929. pmd_rxq_affinity: "0:1,1:2"
  930. mtu: 9000
  931. dpdk_first_nic:
  932. name: ${_param:primary_first_nic}
  933. pci: 0000:05:00.0
  934. driver: igb_uio/vfio-pci
  935. bond: dpdkbond0
  936. enabled: true
  937. type: dpdk_ovs_port
  938. n_rxq: 2
  939. pmd_rxq_affinity: "0:1,1:2"
  940. mtu: 9000
  941. dpdkbond0:
  942. enabled: true
  943. bridge: br-prv
  944. type: dpdk_ovs_bond
  945. mode: active-backup
  946. br-prv:
  947. enabled: true
  948. type: dpdk_ovs_bridge
  949. **DPDK OVS bridge for VXLAN**
  950. If VXLAN is used as tenant segmentation then ip address must be set on br-prv
  951. .. code-block:: yaml
  952. linux:
  953. network:
  954. ...
  955. interface:
  956. br-prv:
  957. enabled: true
  958. type: dpdk_ovs_bridge
  959. address: 192.168.50.0
  960. netmask: 255.255.255.0
  961. mtu: 9000
  962. Linux storage
  963. -------------
  964. Linux with mounted Samba
  965. .. code-block:: yaml
  966. linux:
  967. storage:
  968. enabled: true
  969. mount:
  970. samba1:
  971. - enabled: true
  972. - path: /media/myuser/public/
  973. - device: //192.168.0.1/storage
  974. - file_system: cifs
  975. - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
  976. NFS mount
  977. .. code-block:: yaml
  978. linux:
  979. storage:
  980. enabled: true
  981. mount:
  982. nfs_glance:
  983. enabled: true
  984. path: /var/lib/glance/images
  985. device: 172.16.10.110:/var/nfs/glance
  986. file_system: nfs
  987. opts: rw,sync
  988. File swap configuration
  989. .. code-block:: yaml
  990. linux:
  991. storage:
  992. enabled: true
  993. swap:
  994. file:
  995. enabled: true
  996. engine: file
  997. device: /swapfile
  998. size: 1024
  999. Partition swap configuration
  1000. .. code-block:: yaml
  1001. linux:
  1002. storage:
  1003. enabled: true
  1004. swap:
  1005. partition:
  1006. enabled: true
  1007. engine: partition
  1008. device: /dev/vg0/swap
  1009. LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
  1010. .. code-block:: yaml
  1011. parameters:
  1012. linux:
  1013. storage:
  1014. mount:
  1015. data:
  1016. enabled: true
  1017. device: /dev/vg1/data
  1018. file_system: ext4
  1019. path: /mnt/data
  1020. lvm:
  1021. vg1:
  1022. enabled: true
  1023. devices:
  1024. - /dev/sdb
  1025. volume:
  1026. data:
  1027. size: 40G
  1028. mount: ${linux:storage:mount:data}
  1029. Multipath with Fujitsu Eternus DXL
  1030. .. code-block:: yaml
  1031. parameters:
  1032. linux:
  1033. storage:
  1034. multipath:
  1035. enabled: true
  1036. blacklist_devices:
  1037. - /dev/sda
  1038. - /dev/sdb
  1039. backends:
  1040. - fujitsu_eternus_dxl
  1041. Multipath with Hitachi VSP 1000
  1042. .. code-block:: yaml
  1043. parameters:
  1044. linux:
  1045. storage:
  1046. multipath:
  1047. enabled: true
  1048. blacklist_devices:
  1049. - /dev/sda
  1050. - /dev/sdb
  1051. backends:
  1052. - hitachi_vsp1000
  1053. Multipath with IBM Storwize
  1054. .. code-block:: yaml
  1055. parameters:
  1056. linux:
  1057. storage:
  1058. multipath:
  1059. enabled: true
  1060. blacklist_devices:
  1061. - /dev/sda
  1062. - /dev/sdb
  1063. backends:
  1064. - ibm_storwize
  1065. Multipath with multiple backends
  1066. .. code-block:: yaml
  1067. parameters:
  1068. linux:
  1069. storage:
  1070. multipath:
  1071. enabled: true
  1072. blacklist_devices:
  1073. - /dev/sda
  1074. - /dev/sdb
  1075. - /dev/sdc
  1076. - /dev/sdd
  1077. backends:
  1078. - ibm_storwize
  1079. - fujitsu_eternus_dxl
  1080. - hitachi_vsp1000
  1081. Disabled multipath (the default setup)
  1082. .. code-block:: yaml
  1083. parameters:
  1084. linux:
  1085. storage:
  1086. multipath:
  1087. enabled: false
  1088. Linux with local loopback device
  1089. .. code-block:: yaml
  1090. linux:
  1091. storage:
  1092. loopback:
  1093. disk1:
  1094. file: /srv/disk1
  1095. size: 50G
  1096. External config generation
  1097. --------------------------
  1098. You are able to use config support metadata between formulas and only generate
  1099. config files for external use, eg. docker, etc.
  1100. .. code-block:: yaml
  1101. parameters:
  1102. linux:
  1103. system:
  1104. config:
  1105. pillar:
  1106. jenkins:
  1107. master:
  1108. home: /srv/volumes/jenkins
  1109. approved_scripts:
  1110. - method java.net.URL openConnection
  1111. credentials:
  1112. - type: username_password
  1113. scope: global
  1114. id: test
  1115. desc: Testing credentials
  1116. username: test
  1117. password: test
  1118. Netconsole Remote Kernel Logging
  1119. --------------------------------
  1120. Netconsole logger could be configured for configfs-enabled kernels
  1121. (`CONFIG_NETCONSOLE_DYNAMIC` should be enabled). Configuration applies both in
  1122. runtime (if network is already configured), and on-boot after interface
  1123. initialization. Notes:
  1124. * receiver could be located only in same L3 domain
  1125. (or you need to configure gateway MAC manually)
  1126. * receiver's MAC is detected only on configuration time
  1127. * using broadcast MAC is not recommended
  1128. .. code-block:: yaml
  1129. parameters:
  1130. linux:
  1131. system:
  1132. netconsole:
  1133. enabled: true
  1134. port: 514 (optional)
  1135. loglevel: debug (optional)
  1136. target:
  1137. 192.168.0.1:
  1138. interface: bond0
  1139. mac: "ff:ff:ff:ff:ff:ff" (optional)
  1140. Usage
  1141. =====
  1142. Set mtu of network interface eth0 to 1400
  1143. .. code-block:: bash
  1144. ip link set dev eth0 mtu 1400
  1145. Read more
  1146. =========
  1147. * https://www.archlinux.org/
  1148. * http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu
  1149. Documentation and Bugs
  1150. ======================
  1151. To learn how to install and update salt-formulas, consult the documentation
  1152. available online at:
  1153. http://salt-formulas.readthedocs.io/
  1154. In the unfortunate event that bugs are discovered, they should be reported to
  1155. the appropriate issue tracker. Use Github issue tracker for specific salt
  1156. formula:
  1157. https://github.com/salt-formulas/salt-formula-linux/issues
  1158. For feature requests, bug reports or blueprints affecting entire ecosystem,
  1159. use Launchpad salt-formulas project:
  1160. https://launchpad.net/salt-formulas
  1161. You can also join salt-formulas-users team and subscribe to mailing list:
  1162. https://launchpad.net/~salt-formulas-users
  1163. Developers wishing to work on the salt-formulas projects should always base
  1164. their work on master branch and submit pull request against specific formula.
  1165. https://github.com/salt-formulas/salt-formula-linux
  1166. Any questions or feedback is always welcome so feel free to join our IRC
  1167. channel:
  1168. #salt-formulas @ irc.freenode.net