2016-12-15 22:36:44 +00:00
|
|
|
.. _state-providers:
|
|
|
|
|
2012-05-30 10:32:24 +00:00
|
|
|
===============
|
2012-02-25 08:52:48 +00:00
|
|
|
State Providers
|
|
|
|
===============
|
|
|
|
|
|
|
|
.. versionadded:: 0.9.8
|
|
|
|
|
|
|
|
Salt predetermines what modules should be mapped to what uses based on the
|
|
|
|
properties of a system. These determinations are generally made for modules
|
|
|
|
that provide things like package and service management.
|
|
|
|
|
2012-12-22 03:39:22 +00:00
|
|
|
Sometimes in states, it may be necessary to use an alternative module to
|
2016-04-09 02:58:11 +00:00
|
|
|
provide the needed functionality. For instance, an very old Arch Linux system
|
|
|
|
may not be running systemd, so instead of using the systemd service module, you
|
|
|
|
can revert to the default service module:
|
2012-02-25 08:52:48 +00:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
httpd:
|
2012-06-18 07:28:55 +00:00
|
|
|
service.running:
|
2012-02-25 08:52:48 +00:00
|
|
|
- enable: True
|
2012-12-22 03:39:22 +00:00
|
|
|
- provider: service
|
2012-02-25 08:52:48 +00:00
|
|
|
|
2013-08-21 22:49:25 +00:00
|
|
|
In this instance, the basic :py:mod:`~salt.modules.service` module (which
|
|
|
|
manages :program:`sysvinit`-based services) will replace the
|
|
|
|
:py:mod:`~salt.modules.systemd` module which is used by default on Arch Linux.
|
2012-10-11 20:44:23 +00:00
|
|
|
|
2016-04-09 03:05:36 +00:00
|
|
|
This change only affects this one state though. If it is necessary to make this
|
|
|
|
override for most or every service, it is better to just override the provider
|
|
|
|
in the minion config file, as described :ref:`here <module-provider-override>`.
|
|
|
|
|
|
|
|
Also, keep in mind that this only works for states with an identically-named
|
|
|
|
virtual module (:py:mod:`~salt.states.pkg`, :py:mod:`~salt.states.service`,
|
|
|
|
etc.).
|
2012-02-25 08:52:48 +00:00
|
|
|
|
|
|
|
Arbitrary Module Redirects
|
2012-05-23 04:43:12 +00:00
|
|
|
==========================
|
2012-02-25 08:52:48 +00:00
|
|
|
|
|
|
|
The provider statement can also be used for more powerful means, instead of
|
|
|
|
overwriting or extending the module used for the named service an arbitrary
|
|
|
|
module can be used to provide certain functionality.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
emacs:
|
2012-06-18 07:28:55 +00:00
|
|
|
pkg.installed:
|
2012-02-25 08:52:48 +00:00
|
|
|
- provider:
|
|
|
|
- cmd: customcmd
|
|
|
|
|
2014-01-18 03:08:44 +00:00
|
|
|
In this example, the state is being instructed to use a custom module to invoke
|
|
|
|
commands.
|
|
|
|
|
|
|
|
Arbitrary module redirects can be used to dramatically change the behavior of a
|
2016-04-09 02:58:11 +00:00
|
|
|
given state.
|