1
0

providers.rst 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. .. _state-providers:
  2. ===============
  3. State Providers
  4. ===============
  5. .. versionadded:: 0.9.8
  6. Salt predetermines what modules should be mapped to what uses based on the
  7. properties of a system. These determinations are generally made for modules
  8. that provide things like package and service management.
  9. Sometimes in states, it may be necessary to use an alternative module to
  10. provide the needed functionality. For instance, an very old Arch Linux system
  11. may not be running systemd, so instead of using the systemd service module, you
  12. can revert to the default service module:
  13. .. code-block:: yaml
  14. httpd:
  15. service.running:
  16. - enable: True
  17. - provider: service
  18. In this instance, the basic :py:mod:`~salt.modules.service` module (which
  19. manages :program:`sysvinit`-based services) will replace the
  20. :py:mod:`~salt.modules.systemd` module which is used by default on Arch Linux.
  21. This change only affects this one state though. If it is necessary to make this
  22. override for most or every service, it is better to just override the provider
  23. in the minion config file, as described :ref:`here <module-provider-override>`.
  24. Also, keep in mind that this only works for states with an identically-named
  25. virtual module (:py:mod:`~salt.states.pkg`, :py:mod:`~salt.states.service`,
  26. etc.).
  27. Arbitrary Module Redirects
  28. ==========================
  29. The provider statement can also be used for more powerful means, instead of
  30. overwriting or extending the module used for the named service an arbitrary
  31. module can be used to provide certain functionality.
  32. .. code-block:: yaml
  33. emacs:
  34. pkg.installed:
  35. - provider:
  36. - cmd: customcmd
  37. In this example, the state is being instructed to use a custom module to invoke
  38. commands.
  39. Arbitrary module redirects can be used to dramatically change the behavior of a
  40. given state.