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

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