New version of salt-formula from Saltstack
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

README.rst 18KB

il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 8 ans
il y a 8 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 8 ans
il y a 9 ans
il y a 8 ans
il y a 8 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 8 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
il y a 9 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. ============
  2. Salt Formula
  3. ============
  4. Salt is a new approach to infrastructure management. Easy enough to get
  5. running in minutes, scalable enough to manage tens of thousands of servers,
  6. and fast enough to communicate with them in seconds.
  7. Salt delivers a dynamic communication bus for infrastructures that can be used
  8. for orchestration, remote execution, configuration management and much more.
  9. Sample Metadata
  10. ===============
  11. Salt Master
  12. -----------
  13. Salt master with base formulas and pillar metadata backend
  14. .. literalinclude:: tests/pillar/master_single_pillar.sls
  15. :language: yaml
  16. Salt master with reclass ENC metadata backend
  17. .. literalinclude:: tests/pillar/master_single_reclass.sls
  18. :language: yaml
  19. Salt master with Architect ENC metadata backend
  20. .. code-block:: yaml
  21. salt:
  22. master:
  23. enabled: true
  24. pillar:
  25. engine: architect
  26. project: project-name
  27. host: architect-api
  28. port: 8181
  29. username: salt
  30. password: password
  31. Salt master with multiple ext_pillars
  32. .. literalinclude:: tests/pillar/master_single_extpillars.sls
  33. :language: yaml
  34. Salt master with API
  35. .. literalinclude:: tests/pillar/master_api.sls
  36. :language: yaml
  37. Salt master with defined user ACLs
  38. .. literalinclude:: tests/pillar/master_acl.sls
  39. :language: yaml
  40. Salt master with preset minions
  41. .. code-block:: yaml
  42. salt:
  43. master:
  44. enabled: true
  45. minions:
  46. - name: 'node1.system.location.domain.com'
  47. Salt master with pip based installation (optional)
  48. .. code-block:: yaml
  49. salt:
  50. master:
  51. enabled: true
  52. ...
  53. source:
  54. engine: pip
  55. version: 2016.3.0rc2
  56. Install formula through system package management
  57. .. code-block:: yaml
  58. salt:
  59. master:
  60. enabled: true
  61. ...
  62. environment:
  63. prd:
  64. keystone:
  65. source: pkg
  66. name: salt-formula-keystone
  67. nova:
  68. source: pkg
  69. name: salt-formula-keystone
  70. version: 0.1+0~20160818133412.24~1.gbp6e1ebb
  71. postresql:
  72. source: pkg
  73. name: salt-formula-postgresql
  74. version: purged
  75. Formula keystone is installed latest version and the formulas without version are installed in one call to aptpkg module.
  76. If the version attribute is present sls iterates over formulas and take action to install specific version or remove it.
  77. The version attribute may have these values ``[latest|purged|removed|<VERSION>]``.
  78. Clone master branch of keystone formula as local feature branch
  79. .. code-block:: yaml
  80. salt:
  81. master:
  82. enabled: true
  83. ...
  84. environment:
  85. dev:
  86. formula:
  87. keystone:
  88. source: git
  89. address: git@github.com:openstack/salt-formula-keystone.git
  90. revision: master
  91. branch: feature
  92. Salt master with specified formula refs (for example for Gerrit review)
  93. .. code-block:: yaml
  94. salt:
  95. master:
  96. enabled: true
  97. ...
  98. environment:
  99. dev:
  100. formula:
  101. keystone:
  102. source: git
  103. address: https://git.openstack.org/openstack/salt-formula-keystone
  104. revision: refs/changes/56/123456/1
  105. Salt master with logging handlers
  106. .. code-block:: yaml
  107. salt:
  108. master:
  109. enabled: true
  110. handler:
  111. handler01:
  112. engine: udp
  113. bind:
  114. host: 127.0.0.1
  115. port: 9999
  116. minion:
  117. handler:
  118. handler01:
  119. engine: udp
  120. bind:
  121. host: 127.0.0.1
  122. port: 9999
  123. handler02:
  124. engine: zmq
  125. bind:
  126. host: 127.0.0.1
  127. port: 9999
  128. Salt engine definition for saltgraph metadata collector
  129. .. code-block:: yaml
  130. salt:
  131. master:
  132. engine:
  133. graph_metadata:
  134. engine: saltgraph
  135. host: 127.0.0.1
  136. port: 5432
  137. user: salt
  138. password: salt
  139. database: salt
  140. Salt engine definition for Architect service
  141. .. code-block:: yaml
  142. salt:
  143. master:
  144. engine:
  145. architect:
  146. engine: architect
  147. project: project-name
  148. host: architect-api
  149. port: 8181
  150. username: salt
  151. password: password
  152. Salt engine definition for sending events from docker events
  153. .. code-block:: yaml
  154. salt:
  155. master:
  156. engine:
  157. docker_events:
  158. docker_url: unix://var/run/docker.sock
  159. Salt master peer setup for remote certificate signing
  160. .. code-block:: yaml
  161. salt:
  162. master:
  163. peer:
  164. ".*":
  165. - x509.sign_remote_certificate
  166. Salt master backup configuration
  167. .. code-block:: yaml
  168. salt:
  169. master:
  170. backup: true
  171. initial_data:
  172. engine: backupninja
  173. home_dir: remote-backup-home-dir
  174. source: backup-node-host
  175. host: original-salt-master-id
  176. Configure verbosity of state output (used for `salt` command)
  177. .. code-block:: yaml
  178. salt:
  179. master:
  180. state_output: changes
  181. Pass pillar render error to minion log
  182. .. note:: When set to `False` this option is great for debuging.
  183. However it is not recomended for any production environment as it may contain
  184. templating data as passwords, etc... , that minion should not expose.
  185. .. code-block:: yaml
  186. salt:
  187. master:
  188. pillar_safe_render_error: False
  189. Event/Reactor Systems
  190. ~~~~~~~~~~~~~~~~~~~~~
  191. Salt synchronise node pillar and modules after start
  192. .. code-block:: yaml
  193. salt:
  194. master:
  195. reactor:
  196. salt/minion/*/start:
  197. - salt://salt/reactor/node_start.sls
  198. Trigger basic node install
  199. .. code-block:: yaml
  200. salt:
  201. master:
  202. reactor:
  203. salt/minion/install:
  204. - salt://salt/reactor/node_install.sls
  205. Sample event to trigger the node installation
  206. .. code-block:: bash
  207. salt-call event.send 'salt/minion/install'
  208. Run any defined orchestration pipeline
  209. .. code-block:: yaml
  210. salt:
  211. master:
  212. reactor:
  213. salt/orchestrate/start:
  214. - salt://salt/reactor/orchestrate_start.sls
  215. Event to trigger the orchestration pipeline
  216. .. code-block:: bash
  217. salt-call event.send 'salt/orchestrate/start' "{'orchestrate': 'salt/orchestrate/infra_install.sls'}"
  218. Synchronise modules and pillars on minion start.
  219. .. code-block:: yaml
  220. salt:
  221. master:
  222. reactor:
  223. 'salt/minion/*/start':
  224. - salt://salt/reactor/minion_start.sls
  225. Add and/or remove the minion key
  226. .. code-block:: yaml
  227. salt:
  228. master:
  229. reactor:
  230. salt/key/create:
  231. - salt://salt/reactor/key_create.sls
  232. salt/key/remove:
  233. - salt://salt/reactor/key_remove.sls
  234. Event to trigger the key creation
  235. .. code-block:: bash
  236. salt-call event.send 'salt/key/create' \
  237. > "{'node_id': 'id-of-minion', 'node_host': '172.16.10.100', 'orch_post_create': 'kubernetes.orchestrate.compute_install', 'post_create_pillar': {'node_name': 'id-of-minion'}}"
  238. .. note::
  239. You can add pass additional `orch_pre_create`, `orch_post_create`,
  240. `orch_pre_remove` or `orch_post_remove` parameters to the event to call
  241. extra orchestrate files. This can be useful for example for
  242. registering/unregistering nodes from the monitoring alarms or dashboards.
  243. The key creation event needs to be run from other machine than the one
  244. being registered.
  245. Event to trigger the key removal
  246. .. code-block:: bash
  247. salt-call event.send 'salt/key/remove'
  248. Control VM provisioning
  249. .. code-block:: yaml
  250. virt:
  251. disk:
  252. three_disks:
  253. - system:
  254. size: 4096
  255. image: ubuntu.qcow
  256. - repository_snapshot:
  257. size: 8192
  258. image: snapshot.qcow
  259. - cinder-volume:
  260. size: 2048
  261. salt:
  262. control:
  263. enabled: true
  264. virt_enabled: true
  265. size:
  266. medium_three_disks:
  267. cpu: 2
  268. ram: 4
  269. disk_profile: three_disks
  270. cluster:
  271. mycluster:
  272. domain: neco.virt.domain.com
  273. engine: virt
  274. node:
  275. ubuntu1:
  276. provider: node01.domain.com
  277. image: ubuntu.qcow
  278. size: medium
  279. img_dest: /var/lib/libvirt/ssdimages
  280. rng:
  281. backend: /dev/urandom
  282. model: random
  283. rate:
  284. period: '1800'
  285. bytes: '1500'
  286. Jinja options
  287. -------------
  288. Use following options to update default jinja renderer options. Salt recognize Jinja options for templates and for sls files.
  289. For full list of options check jinja documentation: http://jinja.pocoo.org/docs/api/#high-level-api.
  290. .. code-block:: yaml
  291. salt:
  292. renderer:
  293. # for templates
  294. jinja: &jina_env
  295. # Default Jinja environment options
  296. block_start_string: '{%'
  297. block_end_string: '%}'
  298. variable_start_string: '{{'
  299. variable_end_string: '}}'
  300. comment_start_string: '{#'
  301. comment_end_string: '#}'
  302. keep_trailing_newline: False
  303. newline_sequence: '\n'
  304. # Next two are enabled by default in Salt
  305. trim_blocks: True
  306. lstrip_blocks: True
  307. # Next two are not enabled by default in Salt
  308. # but worth to consider to enable in future for salt-formulas
  309. line_statement_prefix: '%'
  310. line_comment_prefix: '##'
  311. # for .sls state files
  312. jinja_sls: *jinja_env
  313. With the line_statement/comment* _prefix options enabled following code statements are valid:
  314. .. code-block:: yaml
  315. %- set myvar = 'one'
  316. ## You can mix even with '{%'
  317. {%- set myvar = 'two' %} ## comment
  318. %- set mylist = ['one', 'two', 'three'] ## comment
  319. ## comment
  320. %- for item in mylist: ## comment
  321. {{- item }}
  322. %- endfor
  323. Encrypted pillars
  324. ~~~~~~~~~~~~~~~~~
  325. Note: NACL + below configuration will be available in Salt > 2017.7.
  326. External resources:
  327. - Tutorial to configure salt + reclass ext_pillar and nacl: http://apealive.net/post/2017-09-salt-nacl-ext-pillar/
  328. - Saltstack documentation: https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.nacl.html
  329. Configure salt NACL module:
  330. .. code-block:: shell
  331. pip install --upgrade libnacl===1.5.2
  332. salt-call --local nacl.keygen /etc/salt/pki/master/nacl
  333. local:
  334. saved sk_file:/etc/salt/pki/master/nacl pk_file: /etc/salt/pki/master/nacl.pub
  335. .. code-block:: yaml
  336. salt:
  337. master:
  338. pillar:
  339. reclass: *reclass
  340. nacl:
  341. index: 99
  342. nacl:
  343. box_type: sealedbox
  344. sk_file: /etc/salt/pki/master/nacl
  345. pk_file: /etc/salt/pki/master/nacl.pub
  346. #sk: None
  347. #pk: None
  348. NACL encrypt secrets:
  349. salt-call --local nacl.enc 'my_secret_value' pk_file=/etc/salt/pki/master/nacl.pub
  350. hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q
  351. # or
  352. salt-run nacl.enc 'myotherpass'
  353. ADDFD0Rav6p6+63sojl7Htfrncp5rrDVyeE4BSPO7ipq8fZuLDIVAzQLf4PCbDqi+Fau5KD3/J/E+Pw=
  354. NACL encrypted values on pillar:
  355. Use Boxed syntax `NACL[CryptedValue=]` to encode value on pillar:
  356. .. code-block:: yaml
  357. my_pillar:
  358. my_nacl:
  359. key0: unencrypted_value
  360. key1: NACL[hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q]
  361. NACL large files:
  362. .. code-block:: shell
  363. salt-call nacl.enc_file /tmp/cert.crt out=/srv/salt/env/dev/cert.nacl
  364. # or more advanced
  365. cert=$(cat /tmp/cert.crt)
  366. salt-call --out=newline_values_only nacl.enc_pub data="$cert" > /srv/salt/env/dev/cert.nacl
  367. NACL within template/native pillars:
  368. pillarexample:
  369. user: root
  370. password1: {{salt.nacl.dec('DRB7Q6/X5gGSRCTpZyxS6hlbWj0llUA+uaVyvou3vJ4=')|json}}
  371. cert_key: {{salt.nacl.dec_file('/srv/salt/env/dev/certs/example.com/cert.nacl')|json}}
  372. cert_key2: {{salt.nacl.dec_file('salt:///certs/example.com/cert2.nacl')|json}}
  373. Salt Syndic
  374. -----------
  375. The master of masters
  376. .. code-block:: yaml
  377. salt:
  378. master:
  379. enabled: true
  380. order_masters: True
  381. Lower syndicated master
  382. .. code-block:: yaml
  383. salt:
  384. syndic:
  385. enabled: true
  386. master:
  387. host: master-of-master-host
  388. timeout: 5
  389. Syndicated master with multiple master of masters
  390. .. code-block:: yaml
  391. salt:
  392. syndic:
  393. enabled: true
  394. masters:
  395. - host: master-of-master-host1
  396. - host: master-of-master-host2
  397. timeout: 5
  398. Salt Minion
  399. -----------
  400. Simplest Salt minion setup with central configuration node
  401. .. code-block:: yaml
  402. .. literalinclude:: tests/pillar/minion_master.sls
  403. :language: yaml
  404. Multi-master Salt minion setup
  405. .. literalinclude:: tests/pillar/minion_multi_master.sls
  406. :language: yaml
  407. Salt minion with salt mine options
  408. .. literalinclude:: tests/pillar/minion_mine.sls
  409. :language: yaml
  410. Salt minion with graphing dependencies
  411. .. literalinclude:: tests/pillar/minion_graph.sls
  412. :language: yaml
  413. Salt minion behind HTTP proxy
  414. .. code-block:: yaml
  415. salt:
  416. minion:
  417. proxy:
  418. host: 127.0.0.1
  419. port: 3128
  420. Salt minion to specify non-default HTTP backend. The default tornado backend
  421. does not respect HTTP proxy settings set as environment variables. This is
  422. useful for cases where you need to set no_proxy lists.
  423. .. code-block:: yaml
  424. salt:
  425. minion:
  426. backend: urllib2
  427. Salt minion with PKI certificate authority (CA)
  428. .. literalinclude:: tests/pillar/minion_pki_ca.sls
  429. :language: yaml
  430. Salt minion using PKI certificate
  431. .. literalinclude:: tests/pillar/minion_pki_cert.sls
  432. :language: yaml
  433. Salt minion trust CA certificates issued by salt CA on a specific host (ie: salt-master node)
  434. .. code-block:: yaml
  435. salt:
  436. minion:
  437. trusted_ca_minions:
  438. - cfg01
  439. Salt Minion Proxy
  440. ~~~~~~~~~~~~~~~~~
  441. Salt proxy pillar
  442. .. code-block:: yaml
  443. salt:
  444. minion:
  445. proxy_minion:
  446. master: localhost
  447. device:
  448. vsrx01.mydomain.local:
  449. enabled: true
  450. engine: napalm
  451. csr1000v.mydomain.local:
  452. enabled: true
  453. engine: napalm
  454. .. note:: This is pillar of the the real salt-minion
  455. Proxy pillar for IOS device
  456. .. code-block:: yaml
  457. proxy:
  458. proxytype: napalm
  459. driver: ios
  460. host: csr1000v.mydomain.local
  461. username: root
  462. passwd: r00tme
  463. .. note:: This is pillar of the node thats not able to run salt-minion itself
  464. Proxy pillar for JunOS device
  465. .. code-block:: yaml
  466. proxy:
  467. proxytype: napalm
  468. driver: junos
  469. host: vsrx01.mydomain.local
  470. username: root
  471. passwd: r00tme
  472. optional_args:
  473. config_format: set
  474. .. note:: This is pillar of the node thats not able to run salt-minion itself
  475. Salt SSH
  476. ~~~~~~~~
  477. Salt SSH with sudoer using key
  478. .. literalinclude:: tests/pillar/master_ssh_minion_key.sls
  479. :language: yaml
  480. Salt SSH with sudoer using password
  481. .. literalinclude:: tests/pillar/master_ssh_minion_password.sls
  482. :language: yaml
  483. Salt SSH with root using password
  484. .. literalinclude:: tests/pillar/master_ssh_minion_root.sls
  485. :language: yaml
  486. Salt control (cloud/kvm/docker)
  487. -------------------------------
  488. Salt cloud with local OpenStack provider
  489. .. literalinclude:: tests/pillar/control_cloud_openstack.sls
  490. :language: yaml
  491. Salt cloud with Digital Ocean provider
  492. .. literalinclude:: tests/pillar/control_cloud_digitalocean.sls
  493. :language: yaml
  494. Salt virt with KVM cluster
  495. .. literalinclude:: tests/pillar/control_virt.sls
  496. :language: yaml
  497. salt virt with custom destination for image file
  498. .. literalinclude:: tests/pillar/control_virt_custom.sls
  499. :language: yaml
  500. Usage
  501. =====
  502. Working with salt-cloud
  503. .. code-block:: bash
  504. salt-cloud -m /path/to/map --assume-yes
  505. Debug LIBCLOUD for salt-cloud connection
  506. .. code-block:: bash
  507. export LIBCLOUD_DEBUG=/dev/stderr; salt-cloud --list-sizes provider_name --log-level all
  508. References
  509. ==========
  510. * http://salt.readthedocs.org/en/latest/
  511. * https://github.com/DanielBryan/salt-state-graph
  512. * http://karlgrz.com/testing-salt-states-rapidly-with-docker/
  513. * https://mywushublog.com/2013/03/configuration-management-with-salt-stack/
  514. * http://russell.ballestrini.net/replace-the-nagios-scheduler-and-nrpe-with-salt-stack/
  515. * https://github.com/saltstack-formulas/salt-formula
  516. * http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html
  517. salt-cloud
  518. ----------
  519. * http://www.blog.sandro-mathys.ch/2013/07/setting-user-password-when-launching.html
  520. * http://cloudinit.readthedocs.org/en/latest/topics/examples.html
  521. * http://salt-cloud.readthedocs.org/en/latest/topics/install/index.html
  522. * http://docs.saltstack.com/topics/cloud/digitalocean.html
  523. * http://salt-cloud.readthedocs.org/en/latest/topics/rackspace.html
  524. * http://salt-cloud.readthedocs.org/en/latest/topics/map.html
  525. * http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html
  526. Documentation and Bugs
  527. ======================
  528. To learn how to install and update salt-formulas, consult the documentation
  529. available online at:
  530. http://salt-formulas.readthedocs.io/
  531. In the unfortunate event that bugs are discovered, they should be reported to
  532. the appropriate issue tracker. Use Github issue tracker for specific salt
  533. formula:
  534. https://github.com/salt-formulas/salt-formula-salt/issues
  535. For feature requests, bug reports or blueprints affecting entire ecosystem,
  536. use Launchpad salt-formulas project:
  537. https://launchpad.net/salt-formulas
  538. You can also join salt-formulas-users team and subscribe to mailing list:
  539. https://launchpad.net/~salt-formulas-users
  540. Developers wishing to work on the salt-formulas projects should always base
  541. their work on master branch and submit pull request against specific formula.
  542. https://github.com/salt-formulas/salt-formula-salt
  543. Any questions or feedback is always welcome so feel free to join our IRC
  544. channel:
  545. #salt-formulas @ irc.freenode.net