New Saltstack Salt formula
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

README.rst 13KB

hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 8 años
hace 8 años
hace 9 años
hace 9 años
hace 9 años
hace 8 años
hace 9 años
hace 8 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 8 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 8 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  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 multiple ext_pillars
  20. .. literalinclude:: tests/pillar/master_single_extpillars.sls
  21. :language: yaml
  22. Salt master with API
  23. .. literalinclude:: tests/pillar/master_api.sls
  24. :language: yaml
  25. Salt master with defined user ACLs
  26. .. literalinclude:: tests/pillar/master_acl.sls
  27. :language: yaml
  28. Salt master with preset minions
  29. .. code-block:: yaml
  30. salt:
  31. master:
  32. enabled: true
  33. minions:
  34. - name: 'node1.system.location.domain.com'
  35. Salt master with pip based installation (optional)
  36. .. code-block:: yaml
  37. salt:
  38. master:
  39. enabled: true
  40. ...
  41. source:
  42. engine: pip
  43. version: 2016.3.0rc2
  44. Install formula through system package management
  45. .. code-block:: yaml
  46. salt:
  47. master:
  48. enabled: true
  49. ...
  50. environment:
  51. prd:
  52. keystone:
  53. source: pkg
  54. name: salt-formula-keystone
  55. nova:
  56. source: pkg
  57. name: salt-formula-keystone
  58. version: 0.1+0~20160818133412.24~1.gbp6e1ebb
  59. postresql:
  60. source: pkg
  61. name: salt-formula-postgresql
  62. version: purged
  63. Formula keystone is installed latest version and the formulas without version are installed in one call to aptpkg module.
  64. If the version attribute is present sls iterates over formulas and take action to install specific version or remove it.
  65. The version attribute may have these values ``[latest|purged|removed|<VERSION>]``.
  66. Clone master branch of keystone formula as local feature branch
  67. .. code-block:: yaml
  68. salt:
  69. master:
  70. enabled: true
  71. ...
  72. environment:
  73. dev:
  74. formula:
  75. keystone:
  76. source: git
  77. address: git@github.com:openstack/salt-formula-keystone.git
  78. revision: master
  79. branch: feature
  80. Salt master with specified formula refs (for example for Gerrit review)
  81. .. code-block:: yaml
  82. salt:
  83. master:
  84. enabled: true
  85. ...
  86. environment:
  87. dev:
  88. formula:
  89. keystone:
  90. source: git
  91. address: https://git.openstack.org/openstack/salt-formula-keystone
  92. revision: refs/changes/56/123456/1
  93. Salt master with logging handlers
  94. .. code-block:: yaml
  95. salt:
  96. master:
  97. enabled: true
  98. handler:
  99. handler01:
  100. engine: udp
  101. bind:
  102. host: 127.0.0.1
  103. port: 9999
  104. minion:
  105. handler:
  106. handler01:
  107. engine: udp
  108. bind:
  109. host: 127.0.0.1
  110. port: 9999
  111. handler02:
  112. engine: zmq
  113. bind:
  114. host: 127.0.0.1
  115. port: 9999
  116. Salt master peer setup for remote certificate signing
  117. .. code-block:: yaml
  118. salt:
  119. master:
  120. peer:
  121. ".*":
  122. - x509.sign_remote_certificate
  123. Configure verbosity of state output (used for `salt` command)
  124. .. code-block:: yaml
  125. salt:
  126. master:
  127. state_output: changes
  128. Salt synchronise node pillar and modules after start
  129. .. code-block:: yaml
  130. salt:
  131. master:
  132. reactor:
  133. salt/minion/*/start:
  134. - salt://salt/reactor/node_start.sls
  135. Trigger basic node install
  136. .. code-block:: yaml
  137. salt:
  138. master:
  139. reactor:
  140. salt/minion/install:
  141. - salt://salt/reactor/node_install.sls
  142. Sample event to trigger the node installation
  143. .. code-block:: bash
  144. salt-call event.send 'salt/minion/install'
  145. Run any orchestration pipeline
  146. .. code-block:: yaml
  147. salt:
  148. master:
  149. reactor:
  150. salt/orchestrate/start:
  151. - salt://salt/reactor/orchestrate_start.sls
  152. Event to trigger the orchestration pipeline
  153. .. code-block:: bash
  154. salt-call event.send 'salt/orchestrate/start' "{'orchestrate': 'salt/orchestrate/infra_install.sls'}"
  155. Classify node after start
  156. .. code-block:: yaml
  157. salt:
  158. master:
  159. reactor:
  160. reclass/minion/classify:
  161. - salt://reclass/reactor/node_register.sls
  162. Event to trigger the node classification
  163. .. code-block:: bash
  164. salt-call event.send 'reclass/minion/classify' "{'node_master_ip': '$config_host', 'node_ip': '${node_ip}', 'node_domain': '$node_domain', 'node_cluster': '$node_cluster', 'node_hostname': '$node_hostname', 'node_os': '$node_os'}"
  165. Encrypted pillars
  166. -----------------
  167. Note: NACL + below configuration will be available in Salt > 2017.7.
  168. External resources:
  169. - Tutorial to configure salt + reclass ext_pillar and nacl: http://apealive.net/post/2017-09-salt-nacl-ext-pillar/
  170. - Saltstack documentation: https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.nacl.html
  171. Configure salt NACL module:
  172. .. code-block:: shell
  173. pip install --upgrade libnacl===1.5.2
  174. salt-call --local nacl.keygen /etc/salt/pki/master/nacl
  175. local:
  176. saved sk_file:/etc/salt/pki/master/nacl pk_file: /etc/salt/pki/master/nacl.pub
  177. .. code-block:: yaml
  178. salt:
  179. master:
  180. pillar:
  181. reclass: *reclass
  182. nacl:
  183. index: 99
  184. nacl:
  185. box_type: sealedbox
  186. sk_file: /etc/salt/pki/master/nacl
  187. pk_file: /etc/salt/pki/master/nacl.pub
  188. #sk: None
  189. #pk: None
  190. NACL encrypt secrets:
  191. salt-call --local nacl.enc 'my_secret_value' pk_file=/etc/salt/pki/master/nacl.pub
  192. hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q
  193. # or
  194. salt-run nacl.enc 'myotherpass'
  195. ADDFD0Rav6p6+63sojl7Htfrncp5rrDVyeE4BSPO7ipq8fZuLDIVAzQLf4PCbDqi+Fau5KD3/J/E+Pw=
  196. NACL encrypted values on pillar:
  197. Use Boxed syntax `NACL[CryptedValue=]` to encode value on pillar:
  198. .. code-block:: yaml
  199. my_pillar:
  200. my_nacl:
  201. key0: unencrypted_value
  202. key1: NACL[hXTkJpC1hcKMS7yZVGESutWrkvzusXfETXkacSklIxYjfWDlMJmR37MlmthdIgjXpg4f2AlBKb8tc9Woma7q]
  203. NACL large files:
  204. .. code-block:: shell
  205. salt-call nacl.enc_file /tmp/cert.crt out=/srv/salt/env/dev/cert.nacl
  206. # or more advanced
  207. cert=$(cat /tmp/cert.crt)
  208. salt-call --out=newline_values_only nacl.enc_pub data="$cert" > /srv/salt/env/dev/cert.nacl
  209. NACL within template/native pillars:
  210. pillarexample:
  211. user: root
  212. password1: {{salt.nacl.dec('DRB7Q6/X5gGSRCTpZyxS6hlbWj0llUA+uaVyvou3vJ4=')|json}}
  213. cert_key: {{salt.nacl.dec_file('/srv/salt/env/dev/certs/example.com/cert.nacl')|json}}
  214. cert_key2: {{salt.nacl.dec_file('salt:///certs/example.com/cert2.nacl')|json}}
  215. Salt syndic
  216. -----------
  217. The master of masters
  218. .. code-block:: yaml
  219. salt:
  220. master:
  221. enabled: true
  222. order_masters: True
  223. Lower syndicated master
  224. .. code-block:: yaml
  225. salt:
  226. syndic:
  227. enabled: true
  228. master:
  229. host: master-of-master-host
  230. timeout: 5
  231. Syndicated master with multiple master of masters
  232. .. code-block:: yaml
  233. salt:
  234. syndic:
  235. enabled: true
  236. masters:
  237. - host: master-of-master-host1
  238. - host: master-of-master-host2
  239. timeout: 5
  240. Salt-minion proxy
  241. -----------------
  242. Salt proxy pillar
  243. .. code-block:: yaml
  244. salt:
  245. minion:
  246. proxy_minion:
  247. master: localhost
  248. device:
  249. vsrx01.mydomain.local:
  250. enabled: true
  251. engine: napalm
  252. csr1000v.mydomain.local:
  253. enabled: true
  254. engine: napalm
  255. .. note:: This is pillar of the the real salt-minion
  256. Proxy pillar for IOS device
  257. .. code-block:: yaml
  258. proxy:
  259. proxytype: napalm
  260. driver: ios
  261. host: csr1000v.mydomain.local
  262. username: root
  263. passwd: r00tme
  264. .. note:: This is pillar of the node thats not able to run salt-minion itself
  265. Proxy pillar for JunOS device
  266. .. code-block:: yaml
  267. proxy:
  268. proxytype: napalm
  269. driver: junos
  270. host: vsrx01.mydomain.local
  271. username: root
  272. passwd: r00tme
  273. optional_args:
  274. config_format: set
  275. .. note:: This is pillar of the node thats not able to run salt-minion itself
  276. Salt SSH
  277. --------
  278. Salt SSH with sudoer using key
  279. .. literalinclude:: tests/pillar/master_ssh_minion_key.sls
  280. :language: yaml
  281. Salt SSH with sudoer using password
  282. .. literalinclude:: tests/pillar/master_ssh_minion_password.sls
  283. :language: yaml
  284. Salt SSH with root using password
  285. .. literalinclude:: tests/pillar/master_ssh_minion_root.sls
  286. :language: yaml
  287. Salt minion
  288. -----------
  289. Simplest Salt minion setup with central configuration node
  290. .. code-block:: yaml
  291. .. literalinclude:: tests/pillar/minion_master.sls
  292. :language: yaml
  293. Multi-master Salt minion setup
  294. .. literalinclude:: tests/pillar/minion_multi_master.sls
  295. :language: yaml
  296. Salt minion with salt mine options
  297. .. literalinclude:: tests/pillar/minion_mine.sls
  298. :language: yaml
  299. Salt minion with graphing dependencies
  300. .. literalinclude:: tests/pillar/minion_graph.sls
  301. :language: yaml
  302. Salt minion behind HTTP proxy
  303. .. code-block:: yaml
  304. salt:
  305. minion:
  306. proxy:
  307. host: 127.0.0.1
  308. port: 3128
  309. Salt minion to specify non-default HTTP backend. The default tornado backend
  310. does not respect HTTP proxy settings set as environment variables. This is
  311. useful for cases where you need to set no_proxy lists.
  312. .. code-block:: yaml
  313. salt:
  314. minion:
  315. backend: urllib2
  316. Salt minion with PKI certificate authority (CA)
  317. .. literalinclude:: tests/pillar/minion_pki_ca.sls
  318. :language: yaml
  319. Salt minion using PKI certificate
  320. .. literalinclude:: tests/pillar/minion_pki_cert.sls
  321. :language: yaml
  322. Salt minion trust CA certificates issued by salt CA on a specific host (ie: salt-master node)
  323. .. code-block:: yaml
  324. salt:
  325. minion:
  326. trusted_ca_minions:
  327. - cfg01
  328. Salt control (cloud/kvm/docker)
  329. -------------------------------
  330. Salt cloud with local OpenStack provider
  331. .. literalinclude:: tests/pillar/control_cloud_openstack.sls
  332. :language: yaml
  333. Salt cloud with Digital Ocean provider
  334. .. literalinclude:: tests/pillar/control_cloud_digitalocean.sls
  335. :language: yaml
  336. Salt virt with KVM cluster
  337. .. literalinclude:: tests/pillar/control_virt.sls
  338. :language: yaml
  339. Usage
  340. =====
  341. Working with salt-cloud
  342. .. code-block:: bash
  343. salt-cloud -m /path/to/map --assume-yes
  344. Debug LIBCLOUD for salt-cloud connection
  345. .. code-block:: bash
  346. export LIBCLOUD_DEBUG=/dev/stderr; salt-cloud --list-sizes provider_name --log-level all
  347. More Information
  348. ================
  349. * http://salt.readthedocs.org/en/latest/
  350. * https://github.com/DanielBryan/salt-state-graph
  351. * http://karlgrz.com/testing-salt-states-rapidly-with-docker/
  352. * https://mywushublog.com/2013/03/configuration-management-with-salt-stack/
  353. * http://russell.ballestrini.net/replace-the-nagios-scheduler-and-nrpe-with-salt-stack/
  354. * https://github.com/saltstack-formulas/salt-formula
  355. * http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html
  356. salt-cloud
  357. ----------
  358. * http://www.blog.sandro-mathys.ch/2013/07/setting-user-password-when-launching.html
  359. * http://cloudinit.readthedocs.org/en/latest/topics/examples.html
  360. * http://salt-cloud.readthedocs.org/en/latest/topics/install/index.html
  361. * http://docs.saltstack.com/topics/cloud/digitalocean.html
  362. * http://salt-cloud.readthedocs.org/en/latest/topics/rackspace.html
  363. * http://salt-cloud.readthedocs.org/en/latest/topics/map.html
  364. * http://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html
  365. Documentation and Bugs
  366. ======================
  367. To learn how to install and update salt-formulas, consult the documentation
  368. available online at:
  369. http://salt-formulas.readthedocs.io/
  370. In the unfortunate event that bugs are discovered, they should be reported to
  371. the appropriate issue tracker. Use Github issue tracker for specific salt
  372. formula:
  373. https://github.com/salt-formulas/salt-formula-salt/issues
  374. For feature requests, bug reports or blueprints affecting entire ecosystem,
  375. use Launchpad salt-formulas project:
  376. https://launchpad.net/salt-formulas
  377. You can also join salt-formulas-users team and subscribe to mailing list:
  378. https://launchpad.net/~salt-formulas-users
  379. Developers wishing to work on the salt-formulas projects should always base
  380. their work on master branch and submit pull request against specific formula.
  381. https://github.com/salt-formulas/salt-formula-salt
  382. Any questions or feedback is always welcome so feel free to join our IRC
  383. channel:
  384. #salt-formulas @ irc.freenode.net