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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513
  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. Use ``/etc/environment`` for static system wide variable assignment after
  809. boot. Variable expansion is frequently not supported.
  810. .. code-block:: yaml
  811. linux:
  812. system:
  813. env:
  814. BOB_VARIABLE: Alice
  815. ...
  816. BOB_PATH:
  817. - /srv/alice/bin
  818. - /srv/bob/bin
  819. ...
  820. ftp_proxy: none
  821. http_proxy: http://global-http-proxy.host.local:8080
  822. https_proxy: ${linux:system:proxy:https}
  823. no_proxy:
  824. - 192.168.0.80
  825. - 192.168.1.80
  826. - .domain.com
  827. - .local
  828. ...
  829. # NOTE: global defaults proxy configuration.
  830. proxy:
  831. ftp: ftp://proxy.host.local:2121
  832. http: http://proxy.host.local:3142
  833. https: https://proxy.host.local:3143
  834. noproxy:
  835. - .domain.com
  836. - .local
  837. Configure profile.d scripts
  838. The profile.d scripts are being sourced during .sh execution and support
  839. variable expansion in opposite to /etc/environment global settings in
  840. ``/etc/environment``.
  841. .. code-block:: yaml
  842. linux:
  843. system:
  844. profile:
  845. locales: |
  846. export LANG=C
  847. export LC_ALL=C
  848. ...
  849. vi_flavors.sh: |
  850. export PAGER=view
  851. export EDITOR=vim
  852. alias vi=vim
  853. shell_locales.sh: |
  854. export LANG=en_US
  855. export LC_ALL=en_US.UTF-8
  856. shell_proxies.sh: |
  857. export FTP_PROXY=ftp://127.0.3.3:2121
  858. export NO_PROXY='.local'
  859. Linux with hosts
  860. Parameter purge_hosts will enforce whole /etc/hosts file, removing entries
  861. that are not defined in model except defaults for both IPv4 and IPv6 localhost
  862. and hostname + fqdn.
  863. It's good to use this option if you want to ensure /etc/hosts is always in a
  864. clean state however it's not enabled by default for safety.
  865. .. code-block:: yaml
  866. linux:
  867. network:
  868. purge_hosts: true
  869. host:
  870. # No need to define this one if purge_hosts is true
  871. hostname:
  872. address: 127.0.1.1
  873. names:
  874. - ${linux:network:fqdn}
  875. - ${linux:network:hostname}
  876. node1:
  877. address: 192.168.10.200
  878. names:
  879. - node2.domain.com
  880. - service2.domain.com
  881. node2:
  882. address: 192.168.10.201
  883. names:
  884. - node2.domain.com
  885. - service2.domain.com
  886. Linux with hosts collected from mine
  887. In this case all dns records defined within infrastrucuture will be passed to
  888. local hosts records or any DNS server. Only hosts with `grain` parameter to
  889. true will be propagated to the mine.
  890. .. code-block:: yaml
  891. linux:
  892. network:
  893. purge_hosts: true
  894. mine_dns_records: true
  895. host:
  896. node1:
  897. address: 192.168.10.200
  898. grain: true
  899. names:
  900. - node2.domain.com
  901. - service2.domain.com
  902. Setup resolv.conf, nameservers, domain and search domains
  903. .. code-block:: yaml
  904. linux:
  905. network:
  906. resolv:
  907. dns:
  908. - 8.8.4.4
  909. - 8.8.8.8
  910. domain: my.example.com
  911. search:
  912. - my.example.com
  913. - example.com
  914. options:
  915. - ndots: 5
  916. - timeout: 2
  917. - attempts: 2
  918. setting custom TX queue length for tap interfaces
  919. .. code-block:: yaml
  920. linux:
  921. network:
  922. tap_custom_txqueuelen: 10000
  923. DPDK OVS interfaces
  924. **DPDK OVS NIC**
  925. .. code-block:: yaml
  926. linux:
  927. network:
  928. bridge: openvswitch
  929. dpdk:
  930. enabled: true
  931. driver: uio/vfio
  932. openvswitch:
  933. pmd_cpu_mask: "0x6"
  934. dpdk_socket_mem: "1024,1024"
  935. dpdk_lcore_mask: "0x400"
  936. memory_channels: 2
  937. interface:
  938. dpkd0:
  939. name: ${_param:dpdk_nic}
  940. pci: 0000:06:00.0
  941. driver: igb_uio/vfio-pci
  942. enabled: true
  943. type: dpdk_ovs_port
  944. n_rxq: 2
  945. pmd_rxq_affinity: "0:1,1:2"
  946. bridge: br-prv
  947. mtu: 9000
  948. br-prv:
  949. enabled: true
  950. type: dpdk_ovs_bridge
  951. **DPDK OVS Bond**
  952. .. code-block:: yaml
  953. linux:
  954. network:
  955. bridge: openvswitch
  956. dpdk:
  957. enabled: true
  958. driver: uio/vfio
  959. openvswitch:
  960. pmd_cpu_mask: "0x6"
  961. dpdk_socket_mem: "1024,1024"
  962. dpdk_lcore_mask: "0x400"
  963. memory_channels: 2
  964. interface:
  965. dpdk_second_nic:
  966. name: ${_param:primary_second_nic}
  967. pci: 0000:06: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. dpdk_first_nic:
  976. name: ${_param:primary_first_nic}
  977. pci: 0000:05:00.0
  978. driver: igb_uio/vfio-pci
  979. bond: dpdkbond0
  980. enabled: true
  981. type: dpdk_ovs_port
  982. n_rxq: 2
  983. pmd_rxq_affinity: "0:1,1:2"
  984. mtu: 9000
  985. dpdkbond0:
  986. enabled: true
  987. bridge: br-prv
  988. type: dpdk_ovs_bond
  989. mode: active-backup
  990. br-prv:
  991. enabled: true
  992. type: dpdk_ovs_bridge
  993. **DPDK OVS bridge for VXLAN**
  994. If VXLAN is used as tenant segmentation then ip address must be set on br-prv
  995. .. code-block:: yaml
  996. linux:
  997. network:
  998. ...
  999. interface:
  1000. br-prv:
  1001. enabled: true
  1002. type: dpdk_ovs_bridge
  1003. address: 192.168.50.0
  1004. netmask: 255.255.255.0
  1005. mtu: 9000
  1006. Linux storage
  1007. -------------
  1008. Linux with mounted Samba
  1009. .. code-block:: yaml
  1010. linux:
  1011. storage:
  1012. enabled: true
  1013. mount:
  1014. samba1:
  1015. - enabled: true
  1016. - path: /media/myuser/public/
  1017. - device: //192.168.0.1/storage
  1018. - file_system: cifs
  1019. - options: guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm
  1020. NFS mount
  1021. .. code-block:: yaml
  1022. linux:
  1023. storage:
  1024. enabled: true
  1025. mount:
  1026. nfs_glance:
  1027. enabled: true
  1028. path: /var/lib/glance/images
  1029. device: 172.16.10.110:/var/nfs/glance
  1030. file_system: nfs
  1031. opts: rw,sync
  1032. File swap configuration
  1033. .. code-block:: yaml
  1034. linux:
  1035. storage:
  1036. enabled: true
  1037. swap:
  1038. file:
  1039. enabled: true
  1040. engine: file
  1041. device: /swapfile
  1042. size: 1024
  1043. Partition swap configuration
  1044. .. code-block:: yaml
  1045. linux:
  1046. storage:
  1047. enabled: true
  1048. swap:
  1049. partition:
  1050. enabled: true
  1051. engine: partition
  1052. device: /dev/vg0/swap
  1053. LVM group `vg1` with one device and `data` volume mounted into `/mnt/data`
  1054. .. code-block:: yaml
  1055. parameters:
  1056. linux:
  1057. storage:
  1058. mount:
  1059. data:
  1060. enabled: true
  1061. device: /dev/vg1/data
  1062. file_system: ext4
  1063. path: /mnt/data
  1064. lvm:
  1065. vg1:
  1066. enabled: true
  1067. devices:
  1068. - /dev/sdb
  1069. volume:
  1070. data:
  1071. size: 40G
  1072. mount: ${linux:storage:mount:data}
  1073. Create partitions on disk. Specify size in MB. It expects empty
  1074. disk without any existing partitions.
  1075. .. code-block:: yaml
  1076. linux:
  1077. storage:
  1078. disk:
  1079. first_drive:
  1080. name: /dev/loop1
  1081. type: gpt
  1082. partitions:
  1083. - size: 200 #size in MB
  1084. type: fat32
  1085. - size: 300 #size in MB
  1086. mkfs: True
  1087. type: xfs
  1088. /dev/vda1:
  1089. partitions:
  1090. - size: 5
  1091. type: ext2
  1092. - size: 10
  1093. type: ext4
  1094. Multipath with Fujitsu Eternus DXL
  1095. .. code-block:: yaml
  1096. parameters:
  1097. linux:
  1098. storage:
  1099. multipath:
  1100. enabled: true
  1101. blacklist_devices:
  1102. - /dev/sda
  1103. - /dev/sdb
  1104. backends:
  1105. - fujitsu_eternus_dxl
  1106. Multipath with Hitachi VSP 1000
  1107. .. code-block:: yaml
  1108. parameters:
  1109. linux:
  1110. storage:
  1111. multipath:
  1112. enabled: true
  1113. blacklist_devices:
  1114. - /dev/sda
  1115. - /dev/sdb
  1116. backends:
  1117. - hitachi_vsp1000
  1118. Multipath with IBM Storwize
  1119. .. code-block:: yaml
  1120. parameters:
  1121. linux:
  1122. storage:
  1123. multipath:
  1124. enabled: true
  1125. blacklist_devices:
  1126. - /dev/sda
  1127. - /dev/sdb
  1128. backends:
  1129. - ibm_storwize
  1130. Multipath with multiple backends
  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. - /dev/sdc
  1141. - /dev/sdd
  1142. backends:
  1143. - ibm_storwize
  1144. - fujitsu_eternus_dxl
  1145. - hitachi_vsp1000
  1146. Disabled multipath (the default setup)
  1147. .. code-block:: yaml
  1148. parameters:
  1149. linux:
  1150. storage:
  1151. multipath:
  1152. enabled: false
  1153. Linux with local loopback device
  1154. .. code-block:: yaml
  1155. linux:
  1156. storage:
  1157. loopback:
  1158. disk1:
  1159. file: /srv/disk1
  1160. size: 50G
  1161. External config generation
  1162. --------------------------
  1163. You are able to use config support metadata between formulas and only generate
  1164. config files for external use, eg. docker, etc.
  1165. .. code-block:: yaml
  1166. parameters:
  1167. linux:
  1168. system:
  1169. config:
  1170. pillar:
  1171. jenkins:
  1172. master:
  1173. home: /srv/volumes/jenkins
  1174. approved_scripts:
  1175. - method java.net.URL openConnection
  1176. credentials:
  1177. - type: username_password
  1178. scope: global
  1179. id: test
  1180. desc: Testing credentials
  1181. username: test
  1182. password: test
  1183. Netconsole Remote Kernel Logging
  1184. --------------------------------
  1185. Netconsole logger could be configured for configfs-enabled kernels
  1186. (`CONFIG_NETCONSOLE_DYNAMIC` should be enabled). Configuration applies both in
  1187. runtime (if network is already configured), and on-boot after interface
  1188. initialization. Notes:
  1189. * receiver could be located only in same L3 domain
  1190. (or you need to configure gateway MAC manually)
  1191. * receiver's MAC is detected only on configuration time
  1192. * using broadcast MAC is not recommended
  1193. .. code-block:: yaml
  1194. parameters:
  1195. linux:
  1196. system:
  1197. netconsole:
  1198. enabled: true
  1199. port: 514 (optional)
  1200. loglevel: debug (optional)
  1201. target:
  1202. 192.168.0.1:
  1203. interface: bond0
  1204. mac: "ff:ff:ff:ff:ff:ff" (optional)
  1205. Usage
  1206. =====
  1207. Set mtu of network interface eth0 to 1400
  1208. .. code-block:: bash
  1209. ip link set dev eth0 mtu 1400
  1210. Read more
  1211. =========
  1212. * https://www.archlinux.org/
  1213. * http://askubuntu.com/questions/175172/how-do-i-configure-proxies-in-ubuntu-server-or-minimal-cli-ubuntu
  1214. Documentation and Bugs
  1215. ======================
  1216. To learn how to install and update salt-formulas, consult the documentation
  1217. available online at:
  1218. http://salt-formulas.readthedocs.io/
  1219. In the unfortunate event that bugs are discovered, they should be reported to
  1220. the appropriate issue tracker. Use Github issue tracker for specific salt
  1221. formula:
  1222. https://github.com/salt-formulas/salt-formula-linux/issues
  1223. For feature requests, bug reports or blueprints affecting entire ecosystem,
  1224. use Launchpad salt-formulas project:
  1225. https://launchpad.net/salt-formulas
  1226. You can also join salt-formulas-users team and subscribe to mailing list:
  1227. https://launchpad.net/~salt-formulas-users
  1228. Developers wishing to work on the salt-formulas projects should always base
  1229. their work on master branch and submit pull request against specific formula.
  1230. https://github.com/salt-formulas/salt-formula-linux
  1231. Any questions or feedback is always welcome so feel free to join our IRC
  1232. channel:
  1233. #salt-formulas @ irc.freenode.net