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.

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