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

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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555
  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. Linux with atop service:
  558. .. code-block:: yaml
  559. linux:
  560. system:
  561. atop:
  562. enabled: true
  563. interval: 20
  564. logpath: "/var/log/atop"
  565. outfile: "/var/log/atop/daily.log"
  566. RHEL / CentOS
  567. ^^^^^^^^^^^^^
  568. Unfortunately ``update-motd`` is currently not available for RHEL so there's
  569. no native support for dynamic motd.
  570. You can still set static one, only pillar structure differs:
  571. .. code-block:: yaml
  572. linux:
  573. system:
  574. motd: |
  575. This is [company name] network.
  576. Unauthorized access strictly prohibited.
  577. Haveged
  578. ~~~~~~~
  579. If you are running headless server and are low on entropy, it may be a good
  580. idea to setup Haveged.
  581. .. code-block:: yaml
  582. linux:
  583. system:
  584. haveged:
  585. enabled: true
  586. Linux network
  587. -------------
  588. Linux with network manager
  589. .. code-block:: yaml
  590. linux:
  591. network:
  592. enabled: true
  593. network_manager: true
  594. Linux with default static network interfaces, default gateway interface and DNS servers
  595. .. code-block:: yaml
  596. linux:
  597. network:
  598. enabled: true
  599. interface:
  600. eth0:
  601. enabled: true
  602. type: eth
  603. address: 192.168.0.102
  604. netmask: 255.255.255.0
  605. gateway: 192.168.0.1
  606. name_servers:
  607. - 8.8.8.8
  608. - 8.8.4.4
  609. mtu: 1500
  610. Linux with bonded interfaces and disabled NetworkManager
  611. .. code-block:: yaml
  612. linux:
  613. network:
  614. enabled: true
  615. interface:
  616. eth0:
  617. type: eth
  618. ...
  619. eth1:
  620. type: eth
  621. ...
  622. bond0:
  623. enabled: true
  624. type: bond
  625. address: 192.168.0.102
  626. netmask: 255.255.255.0
  627. mtu: 1500
  628. use_in:
  629. - interface: ${linux:interface:eth0}
  630. - interface: ${linux:interface:eth0}
  631. network_manager:
  632. disable: true
  633. Linux with vlan interface_params
  634. .. code-block:: yaml
  635. linux:
  636. network:
  637. enabled: true
  638. interface:
  639. vlan69:
  640. type: vlan
  641. use_interfaces:
  642. - interface: ${linux:interface:bond0}
  643. Linux with wireless interface parameters
  644. .. code-block:: yaml
  645. linux:
  646. network:
  647. enabled: true
  648. gateway: 10.0.0.1
  649. default_interface: eth0
  650. interface:
  651. wlan0:
  652. type: eth
  653. wireless:
  654. essid: example
  655. key: example_key
  656. security: wpa
  657. priority: 1
  658. Linux networks with routes defined
  659. .. code-block:: yaml
  660. linux:
  661. network:
  662. enabled: true
  663. gateway: 10.0.0.1
  664. default_interface: eth0
  665. interface:
  666. eth0:
  667. type: eth
  668. route:
  669. default:
  670. address: 192.168.0.123
  671. netmask: 255.255.255.0
  672. gateway: 192.168.0.1
  673. Native Linux Bridges
  674. .. code-block:: yaml
  675. linux:
  676. network:
  677. interface:
  678. eth1:
  679. enabled: true
  680. type: eth
  681. proto: manual
  682. up_cmds:
  683. - ip address add 0/0 dev $IFACE
  684. - ip link set $IFACE up
  685. down_cmds:
  686. - ip link set $IFACE down
  687. br-ex:
  688. enabled: true
  689. type: bridge
  690. address: ${linux:network:host:public_local:address}
  691. netmask: 255.255.255.0
  692. use_interfaces:
  693. - eth1
  694. OpenVswitch Bridges
  695. .. code-block:: yaml
  696. linux:
  697. network:
  698. bridge: openvswitch
  699. interface:
  700. eth1:
  701. enabled: true
  702. type: eth
  703. proto: manual
  704. up_cmds:
  705. - ip address add 0/0 dev $IFACE
  706. - ip link set $IFACE up
  707. down_cmds:
  708. - ip link set $IFACE down
  709. br-ex:
  710. enabled: true
  711. type: bridge
  712. address: ${linux:network:host:public_local:address}
  713. netmask: 255.255.255.0
  714. use_interfaces:
  715. - eth1
  716. Debian manual proto interfaces
  717. When you are changing interface proto from static in up state to manual, you
  718. may need to flush ip addresses. For example, if you want to use the interface
  719. and the ip on the bridge. This can be done by setting the ``ipflush_onchange``
  720. to true.
  721. .. code-block:: yaml
  722. linux:
  723. network:
  724. interface:
  725. eth1:
  726. enabled: true
  727. type: eth
  728. proto: manual
  729. mtu: 9100
  730. ipflush_onchange: true
  731. Concatinating and removing interface files
  732. Debian based distributions have `/etc/network/interfaces.d/` directory, where
  733. you can store configuration of network interfaces in separate files. You can
  734. concatinate the files to the defined destination when needed, this operation
  735. removes the file from the `/etc/network/interfaces.d/`. If you just need to
  736. remove iface files, you can use the `remove_iface_files` key.
  737. .. code-block:: yaml
  738. linux:
  739. network:
  740. concat_iface_files:
  741. - src: '/etc/network/interfaces.d/50-cloud-init.cfg'
  742. dst: '/etc/network/interfaces'
  743. remove_iface_files:
  744. - '/etc/network/interfaces.d/90-custom.cfg'
  745. DHCP client configuration
  746. None of the keys is mandatory, include only those you really need. For full list
  747. of available options under send, supersede, prepend, append refer to dhcp-options(5)
  748. .. code-block:: yaml
  749. linux:
  750. network:
  751. dhclient:
  752. enabled: true
  753. backoff_cutoff: 15
  754. initial_interval: 10
  755. reboot: 10
  756. retry: 60
  757. select_timeout: 0
  758. timeout: 120
  759. send:
  760. - option: host-name
  761. declaration: "= gethostname()"
  762. supersede:
  763. - option: host-name
  764. declaration: "spaceship"
  765. - option: domain-name
  766. declaration: "domain.home"
  767. #- option: arp-cache-timeout
  768. # declaration: 20
  769. prepend:
  770. - option: domain-name-servers
  771. declaration:
  772. - 8.8.8.8
  773. - 8.8.4.4
  774. - option: domain-search
  775. declaration:
  776. - example.com
  777. - eng.example.com
  778. #append:
  779. #- option: domain-name-servers
  780. # declaration: 127.0.0.1
  781. # ip or subnet to reject dhcp offer from
  782. reject:
  783. - 192.33.137.209
  784. - 10.0.2.0/24
  785. request:
  786. - subnet-mask
  787. - broadcast-address
  788. - time-offset
  789. - routers
  790. - domain-name
  791. - domain-name-servers
  792. - domain-search
  793. - host-name
  794. - dhcp6.name-servers
  795. - dhcp6.domain-search
  796. - dhcp6.fqdn
  797. - dhcp6.sntp-servers
  798. - netbios-name-servers
  799. - netbios-scope
  800. - interface-mtu
  801. - rfc3442-classless-static-routes
  802. - ntp-servers
  803. require:
  804. - subnet-mask
  805. - domain-name-servers
  806. # if per interface configuration required add below
  807. interface:
  808. ens2:
  809. initial_interval: 11
  810. reject:
  811. - 192.33.137.210
  812. ens3:
  813. initial_interval: 12
  814. reject:
  815. - 192.33.137.211
  816. Linux network systemd settings:
  817. .. code-block:: yaml
  818. linux:
  819. network:
  820. ...
  821. systemd:
  822. link:
  823. 10-iface-dmz:
  824. Match:
  825. MACAddress: c8:5b:67:fa:1a:af
  826. OriginalName: eth0
  827. Link:
  828. Name: dmz0
  829. netdev:
  830. 20-bridge-dmz:
  831. match:
  832. name: dmz0
  833. network:
  834. mescription: bridge
  835. bridge: br-dmz0
  836. network:
  837. # works with lowercase, keys are by default capitalized
  838. 40-dhcp:
  839. match:
  840. name: '*'
  841. network:
  842. DHCP: yes
  843. Configure global environment variables
  844. Use ``/etc/environment`` for static system wide variable assignment after
  845. boot. Variable expansion is frequently not supported.
  846. .. code-block:: yaml
  847. linux:
  848. system:
  849. env:
  850. BOB_VARIABLE: Alice
  851. ...
  852. BOB_PATH:
  853. - /srv/alice/bin
  854. - /srv/bob/bin
  855. ...
  856. ftp_proxy: none
  857. http_proxy: http://global-http-proxy.host.local:8080
  858. https_proxy: ${linux:system:proxy:https}
  859. no_proxy:
  860. - 192.168.0.80
  861. - 192.168.1.80
  862. - .domain.com
  863. - .local
  864. ...
  865. # NOTE: global defaults proxy configuration.
  866. proxy:
  867. ftp: ftp://proxy.host.local:2121
  868. http: http://proxy.host.local:3142
  869. https: https://proxy.host.local:3143
  870. noproxy:
  871. - .domain.com
  872. - .local
  873. Configure profile.d scripts
  874. The profile.d scripts are being sourced during .sh execution and support
  875. variable expansion in opposite to /etc/environment global settings in
  876. ``/etc/environment``.
  877. .. code-block:: yaml
  878. linux:
  879. system:
  880. profile:
  881. locales: |
  882. export LANG=C
  883. export LC_ALL=C
  884. ...
  885. vi_flavors.sh: |
  886. export PAGER=view
  887. export EDITOR=vim
  888. alias vi=vim
  889. shell_locales.sh: |
  890. export LANG=en_US
  891. export LC_ALL=en_US.UTF-8
  892. shell_proxies.sh: |
  893. export FTP_PROXY=ftp://127.0.3.3:2121
  894. export NO_PROXY='.local'
  895. Linux with hosts
  896. Parameter purge_hosts will enforce whole /etc/hosts file, removing entries
  897. that are not defined in model except defaults for both IPv4 and IPv6 localhost
  898. and hostname + fqdn.
  899. It's good to use this option if you want to ensure /etc/hosts is always in a
  900. clean state however it's not enabled by default for safety.
  901. .. code-block:: yaml
  902. linux:
  903. network:
  904. purge_hosts: true
  905. host:
  906. # No need to define this one if purge_hosts is true
  907. hostname:
  908. address: 127.0.1.1
  909. names:
  910. - ${linux:network:fqdn}
  911. - ${linux:network:hostname}
  912. node1:
  913. address: 192.168.10.200
  914. names:
  915. - node2.domain.com
  916. - service2.domain.com
  917. node2:
  918. address: 192.168.10.201
  919. names:
  920. - node2.domain.com
  921. - service2.domain.com
  922. Linux with hosts collected from mine
  923. In this case all dns records defined within infrastrucuture will be passed to
  924. local hosts records or any DNS server. Only hosts with `grain` parameter to
  925. true will be propagated to the mine.
  926. .. code-block:: yaml
  927. linux:
  928. network:
  929. purge_hosts: true
  930. mine_dns_records: true
  931. host:
  932. node1:
  933. address: 192.168.10.200
  934. grain: true
  935. names:
  936. - node2.domain.com
  937. - service2.domain.com
  938. Setup resolv.conf, nameservers, domain and search domains
  939. .. code-block:: yaml
  940. linux:
  941. network:
  942. resolv:
  943. dns:
  944. - 8.8.4.4
  945. - 8.8.8.8
  946. domain: my.example.com
  947. search:
  948. - my.example.com
  949. - example.com
  950. options:
  951. - ndots: 5
  952. - timeout: 2
  953. - attempts: 2
  954. setting custom TX queue length for tap interfaces
  955. .. code-block:: yaml
  956. linux:
  957. network:
  958. tap_custom_txqueuelen: 10000
  959. DPDK OVS interfaces
  960. **DPDK OVS NIC**
  961. .. code-block:: yaml
  962. linux:
  963. network:
  964. bridge: openvswitch
  965. dpdk:
  966. enabled: true
  967. driver: uio/vfio
  968. openvswitch:
  969. pmd_cpu_mask: "0x6"
  970. dpdk_socket_mem: "1024,1024"
  971. dpdk_lcore_mask: "0x400"
  972. memory_channels: 2
  973. interface:
  974. dpkd0:
  975. name: ${_param:dpdk_nic}
  976. pci: 0000:06:00.0
  977. driver: igb_uio/vfio-pci
  978. enabled: true
  979. type: dpdk_ovs_port
  980. n_rxq: 2
  981. pmd_rxq_affinity: "0:1,1:2"
  982. bridge: br-prv
  983. mtu: 9000
  984. br-prv:
  985. enabled: true
  986. type: dpdk_ovs_bridge
  987. **DPDK OVS Bond**
  988. .. code-block:: yaml
  989. linux:
  990. network:
  991. bridge: openvswitch
  992. dpdk:
  993. enabled: true
  994. driver: uio/vfio
  995. openvswitch:
  996. pmd_cpu_mask: "0x6"
  997. dpdk_socket_mem: "1024,1024"
  998. dpdk_lcore_mask: "0x400"
  999. memory_channels: 2
  1000. interface:
  1001. dpdk_second_nic:
  1002. name: ${_param:primary_second_nic}
  1003. pci: 0000:06:00.0
  1004. driver: igb_uio/vfio-pci
  1005. bond: dpdkbond0
  1006. enabled: true
  1007. type: dpdk_ovs_port
  1008. n_rxq: 2
  1009. pmd_rxq_affinity: "0:1,1:2"
  1010. mtu: 9000
  1011. dpdk_first_nic:
  1012. name: ${_param:primary_first_nic}
  1013. pci: 0000:05:00.0
  1014. driver: igb_uio/vfio-pci
  1015. bond: dpdkbond0
  1016. enabled: true
  1017. type: dpdk_ovs_port
  1018. n_rxq: 2
  1019. pmd_rxq_affinity: "0:1,1:2"
  1020. mtu: 9000
  1021. dpdkbond0:
  1022. enabled: true
  1023. bridge: br-prv
  1024. type: dpdk_ovs_bond
  1025. mode: active-backup
  1026. br-prv:
  1027. enabled: true
  1028. type: dpdk_ovs_bridge
  1029. **DPDK OVS bridge for VXLAN**
  1030. If VXLAN is used as tenant segmentation then ip address must be set on br-prv
  1031. .. code-block:: yaml
  1032. linux:
  1033. network:
  1034. ...
  1035. interface:
  1036. br-prv:
  1037. enabled: true
  1038. type: dpdk_ovs_bridge
  1039. address: 192.168.50.0
  1040. netmask: 255.255.255.0
  1041. mtu: 9000
  1042. Linux storage
  1043. -------------
  1044. Linux with mounted Samba
  1045. .. code-block:: yaml
  1046. linux:
  1047. storage:
  1048. enabled: true
  1049. mount:
  1050. samba1:
  1051. - enabled: true
  1052. - path: /media/myuser/public/
  1053. - device: //192.168.0.1/storage
  1054. - file_system: cifs
  1055. - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
  1056. NFS mount
  1057. .. code-block:: yaml
  1058. linux:
  1059. storage:
  1060. enabled: true
  1061. mount:
  1062. nfs_glance:
  1063. enabled: true
  1064. path: /var/lib/glance/images
  1065. device: 172.16.10.110:/var/nfs/glance
  1066. file_system: nfs
  1067. opts: rw,sync
  1068. File swap configuration
  1069. .. code-block:: yaml
  1070. linux:
  1071. storage:
  1072. enabled: true
  1073. swap:
  1074. file:
  1075. enabled: true
  1076. engine: file
  1077. device: /swapfile
  1078. size: 1024
  1079. Partition swap configuration
  1080. .. code-block:: yaml
  1081. linux:
  1082. storage:
  1083. enabled: true
  1084. swap:
  1085. partition:
  1086. enabled: true
  1087. engine: partition
  1088. device: /dev/vg0/swap
  1089. LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
  1090. .. code-block:: yaml
  1091. parameters:
  1092. linux:
  1093. storage:
  1094. mount:
  1095. data:
  1096. enabled: true
  1097. device: /dev/vg1/data
  1098. file_system: ext4
  1099. path: /mnt/data
  1100. lvm:
  1101. vg1:
  1102. enabled: true
  1103. devices:
  1104. - /dev/sdb
  1105. volume:
  1106. data:
  1107. size: 40G
  1108. mount: ${linux:storage:mount:data}
  1109. Create partitions on disk. Specify size in MB. It expects empty
  1110. disk without any existing partitions.
  1111. .. code-block:: yaml
  1112. linux:
  1113. storage:
  1114. disk:
  1115. first_drive:
  1116. name: /dev/loop1
  1117. type: gpt
  1118. partitions:
  1119. - size: 200 #size in MB
  1120. type: fat32
  1121. - size: 300 #size in MB
  1122. mkfs: True
  1123. type: xfs
  1124. /dev/vda1:
  1125. partitions:
  1126. - size: 5
  1127. type: ext2
  1128. - size: 10
  1129. type: ext4
  1130. Multipath with Fujitsu Eternus DXL
  1131. .. code-block:: yaml
  1132. parameters:
  1133. linux:
  1134. storage:
  1135. multipath:
  1136. enabled: true
  1137. blacklist_devices:
  1138. - /dev/sda
  1139. - /dev/sdb
  1140. backends:
  1141. - fujitsu_eternus_dxl
  1142. Multipath with Hitachi VSP 1000
  1143. .. code-block:: yaml
  1144. parameters:
  1145. linux:
  1146. storage:
  1147. multipath:
  1148. enabled: true
  1149. blacklist_devices:
  1150. - /dev/sda
  1151. - /dev/sdb
  1152. backends:
  1153. - hitachi_vsp1000
  1154. Multipath with IBM Storwize
  1155. .. code-block:: yaml
  1156. parameters:
  1157. linux:
  1158. storage:
  1159. multipath:
  1160. enabled: true
  1161. blacklist_devices:
  1162. - /dev/sda
  1163. - /dev/sdb
  1164. backends:
  1165. - ibm_storwize
  1166. Multipath with multiple backends
  1167. .. code-block:: yaml
  1168. parameters:
  1169. linux:
  1170. storage:
  1171. multipath:
  1172. enabled: true
  1173. blacklist_devices:
  1174. - /dev/sda
  1175. - /dev/sdb
  1176. - /dev/sdc
  1177. - /dev/sdd
  1178. backends:
  1179. - ibm_storwize
  1180. - fujitsu_eternus_dxl
  1181. - hitachi_vsp1000
  1182. Disabled multipath (the default setup)
  1183. .. code-block:: yaml
  1184. parameters:
  1185. linux:
  1186. storage:
  1187. multipath:
  1188. enabled: false
  1189. Linux with local loopback device
  1190. .. code-block:: yaml
  1191. linux:
  1192. storage:
  1193. loopback:
  1194. disk1:
  1195. file: /srv/disk1
  1196. size: 50G
  1197. External config generation
  1198. --------------------------
  1199. You are able to use config support metadata between formulas and only generate
  1200. config files for external use, eg. docker, etc.
  1201. .. code-block:: yaml
  1202. parameters:
  1203. linux:
  1204. system:
  1205. config:
  1206. pillar:
  1207. jenkins:
  1208. master:
  1209. home: /srv/volumes/jenkins
  1210. approved_scripts:
  1211. - method java.net.URL openConnection
  1212. credentials:
  1213. - type: username_password
  1214. scope: global
  1215. id: test
  1216. desc: Testing credentials
  1217. username: test
  1218. password: test
  1219. Netconsole Remote Kernel Logging
  1220. --------------------------------
  1221. Netconsole logger could be configured for configfs-enabled kernels
  1222. (`CONFIG_NETCONSOLE_DYNAMIC` should be enabled). Configuration applies both in
  1223. runtime (if network is already configured), and on-boot after interface
  1224. initialization. Notes:
  1225. * receiver could be located only in same L3 domain
  1226. (or you need to configure gateway MAC manually)
  1227. * receiver's MAC is detected only on configuration time
  1228. * using broadcast MAC is not recommended
  1229. .. code-block:: yaml
  1230. parameters:
  1231. linux:
  1232. system:
  1233. netconsole:
  1234. enabled: true
  1235. port: 514 (optional)
  1236. loglevel: debug (optional)
  1237. target:
  1238. 192.168.0.1:
  1239. interface: bond0
  1240. mac: "ff:ff:ff:ff:ff:ff" (optional)
  1241. Usage
  1242. =====
  1243. Set mtu of network interface eth0 to 1400
  1244. .. code-block:: bash
  1245. ip link set dev eth0 mtu 1400
  1246. Read more
  1247. =========
  1248. * https://www.archlinux.org/
  1249. * http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu
  1250. Documentation and Bugs
  1251. ======================
  1252. To learn how to install and update salt-formulas, consult the documentation
  1253. available online at:
  1254. http://salt-formulas.readthedocs.io/
  1255. In the unfortunate event that bugs are discovered, they should be reported to
  1256. the appropriate issue tracker. Use Github issue tracker for specific salt
  1257. formula:
  1258. https://github.com/salt-formulas/salt-formula-linux/issues
  1259. For feature requests, bug reports or blueprints affecting entire ecosystem,
  1260. use Launchpad salt-formulas project:
  1261. https://launchpad.net/salt-formulas
  1262. You can also join salt-formulas-users team and subscribe to mailing list:
  1263. https://launchpad.net/~salt-formulas-users
  1264. Developers wishing to work on the salt-formulas projects should always base
  1265. their work on master branch and submit pull request against specific formula.
  1266. https://github.com/salt-formulas/salt-formula-linux
  1267. Any questions or feedback is always welcome so feel free to join our IRC
  1268. channel:
  1269. #salt-formulas @ irc.freenode.net