1
0

modules.rst 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. .. _tutorial-remote-execution-modules:
  2. =========================
  3. Remote execution tutorial
  4. =========================
  5. .. include:: /_incl/requisite_incl.rst
  6. Order your minions around
  7. =========================
  8. Now that you have a :term:`master <Master>` and at least one :term:`minion <Minion>`
  9. communicating with each other you can perform commands on the minion via the
  10. :command:`salt` command. Salt calls are comprised of three main components:
  11. .. code-block:: bash
  12. salt '<target>' <function> [arguments]
  13. .. seealso:: :ref:`salt manpage <ref-cli-salt>`
  14. target
  15. ------
  16. The target component allows you to filter which minions should run the
  17. following function. The default filter is a glob on the minion id. For example:
  18. .. code-block:: bash
  19. salt '*' test.version
  20. salt '*.example.org' test.version
  21. Targets can be based on minion system information using the Grains system:
  22. .. code-block:: bash
  23. salt -G 'os:Ubuntu' test.version
  24. .. seealso:: :ref:`Grains system <targeting-grains>`
  25. Targets can be filtered by regular expression:
  26. .. code-block:: bash
  27. salt -E 'virtmach[0-9]' test.version
  28. Targets can be explicitly specified in a list:
  29. .. code-block:: bash
  30. salt -L 'foo,bar,baz,quo' test.version
  31. Or Multiple target types can be combined in one command:
  32. .. code-block:: bash
  33. salt -C 'G@os:Ubuntu and webser* or E@database.*' test.version
  34. function
  35. --------
  36. A function is some functionality provided by a module. Salt ships with a large
  37. collection of available functions. List all available functions on your
  38. minions:
  39. .. code-block:: bash
  40. salt '*' sys.doc
  41. Here are some examples:
  42. Show all currently available minions:
  43. .. code-block:: bash
  44. salt '*' test.version
  45. Run an arbitrary shell command:
  46. .. code-block:: bash
  47. salt '*' cmd.run 'uname -a'
  48. .. seealso:: :ref:`the full list of modules <all-salt.modules>`
  49. arguments
  50. ---------
  51. Space-delimited arguments to the function:
  52. .. code-block:: bash
  53. salt '*' cmd.exec_code python 'import sys; print sys.version'
  54. Optional, keyword arguments are also supported:
  55. .. code-block:: bash
  56. salt '*' pip.install salt timeout=5 upgrade=True
  57. They are always in the form of ``kwarg=argument``.