Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow loading executor modules from the fileserver #51427

Merged
merged 1 commit into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions doc/topics/development/modules/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Sync Via the saltutil Module
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The saltutil module has a number of functions that can be used to sync all
or specific dynamic modules. The ``saltutil.sync_*``
or specific dynamic modules. The ``saltutil.sync_*``
:py:mod:`execution functions <salt.modules.saltutil>` and
:py:mod:`runner functions <salt.runners.saltutil>` can be used to sync modules
to minions and the master, respectively.
Expand Down Expand Up @@ -110,7 +110,7 @@ This is done via setuptools entry points:
)

Note that these are not synced from the Salt Master to the Minions. They must be
installed indepdendently on each Minion.
installed independently on each Minion.

Module Types
============
Expand All @@ -129,7 +129,7 @@ Cache ``salt.cache`` (:ref:`index <all-salt.cache>`) ``
Cloud ``salt.cloud.clouds`` (:ref:`index <all-salt.clouds>`) ``clouds`` ``cloud_dirs``
Engine ``salt.engines`` (:ref:`index <engines>`) ``engines`` ``engines_dirs``
Execution ``salt.modules`` (:ref:`index <all-salt.modules>`) ``modules`` ``module_dirs``
Executor ``salt.executors`` (:ref:`index <all-salt.executors>`) ``executors`` [#no-fs]_ ``executor_dirs``
Executor ``salt.executors`` (:ref:`index <all-salt.executors>`) ``executors`` ``executor_dirs``
File Server ``salt.fileserver`` (:ref:`index <file-server>`) ``fileserver`` ``fileserver_dirs``
Grain ``salt.grains`` (:ref:`index <all-salt.grains>`) ``grains`` ``grains_dirs``
Log Handler ``salt.log.handlers`` (:ref:`index <external-logging-handlers>`) ``log_handlers`` ``log_handlers_dirs``
Expand Down Expand Up @@ -395,7 +395,7 @@ the state system.
Util
----

Just utility modules to use with other modules via ``__utils__`` (see
Just utility modules to use with other modules via ``__utils__`` (see
:ref:`Dunder Dictionaries <dunder-dictionaries>`).

Wheel
Expand Down
40 changes: 40 additions & 0 deletions salt/modules/saltutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,45 @@ def sync_serializers(saltenv=None, refresh=True, extmod_whitelist=None, extmod_b
return ret


def sync_executors(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist=None):
'''
.. versionadded:: Neon

Sync executors from ``salt://_executors`` to the minion

saltenv
The fileserver environment from which to sync. To sync from more than
one environment, pass a comma-separated list.

If not passed, then all environments configured in the :ref:`top files
<states-top>` will be checked for executor modules to sync. If no top
files are found, then the ``base`` environment will be synced.

refresh : True
If ``True``, refresh the available execution modules on the minion.
This refresh will be performed even if no new serializer modules are
synced. Set to ``False`` to prevent this refresh.

extmod_whitelist : None
comma-seperated list of modules to sync

extmod_blacklist : None
comma-seperated list of modules to blacklist based on type

CLI Examples:

.. code-block:: bash

salt '*' saltutil.sync_executors
salt '*' saltutil.sync_executors saltenv=dev
salt '*' saltutil.sync_executors saltenv=base,dev
'''
ret = _sync('executors', saltenv, extmod_whitelist, extmod_blacklist)
if refresh:
refresh_modules()
return ret


def list_extmods():
'''
.. versionadded:: 2017.7.0
Expand Down Expand Up @@ -986,6 +1025,7 @@ def sync_all(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blacklist
ret['thorium'] = sync_thorium(saltenv, False, extmod_whitelist, extmod_blacklist)
ret['serializers'] = sync_serializers(saltenv, False, extmod_whitelist, extmod_blacklist)
ret['matchers'] = sync_matchers(saltenv, False, extmod_whitelist, extmod_blacklist)
ret['executors'] = sync_executors(saltenv, False, extmod_whitelist, extmod_blacklist)
if __opts__['file_client'] == 'local':
ret['pillar'] = sync_pillar(saltenv, False, extmod_whitelist, extmod_blacklist)
if refresh:
Expand Down
14 changes: 14 additions & 0 deletions salt/states/saltutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ def sync_engines(name, **kwargs):
return _sync_single(name, "engines", **kwargs)


def sync_executors(name, **kwargs):
'''
Performs the same task as saltutil.sync_executors module
See :mod:`saltutil module for full list of options <salt.modules.saltutil>`

.. code-block:: yaml

sync_everything:
saltutil.sync_executors:
- refresh: True
'''
return _sync_single(name, "executors", **kwargs)


def sync_grains(name, **kwargs):
'''
Performs the same task as saltutil.sync_grains module
Expand Down
12 changes: 8 additions & 4 deletions tests/integration/modules/test_saltutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def test_sync_all(self):
'proxymodules': [],
'output': [],
'thorium': [],
'serializers': []}
'serializers': [],
'executors': []}
ret = self.run_function('saltutil.sync_all')
self.assertEqual(ret, expected_return)

Expand All @@ -130,7 +131,8 @@ def test_sync_all_whitelist(self):
'proxymodules': [],
'output': [],
'thorium': [],
'serializers': []}
'serializers': [],
'executors': []}
ret = self.run_function('saltutil.sync_all', extmod_whitelist={'modules': ['salttest']})
self.assertEqual(ret, expected_return)

Expand All @@ -156,7 +158,8 @@ def test_sync_all_blacklist(self):
'proxymodules': [],
'output': [],
'thorium': [],
'serializers': []}
'serializers': [],
'executors': []}
ret = self.run_function('saltutil.sync_all', extmod_blacklist={'modules': ['runtests_decorators']})
self.assertEqual(ret, expected_return)

Expand All @@ -179,7 +182,8 @@ def test_sync_all_blacklist_and_whitelist(self):
'proxymodules': [],
'output': [],
'thorium': [],
'serializers': []}
'serializers': [],
'executors': []}
ret = self.run_function('saltutil.sync_all', extmod_whitelist={'modules': ['runtests_decorators']},
extmod_blacklist={'modules': ['runtests_decorators']})
self.assertEqual(ret, expected_return)
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/states/test_saltutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_saltutil_sync_all_nochange(self):
sync_output = {
'clouds': [],
'engines': [],
'executors': [],
'grains': [],
'beacons': [],
'utils': [],
Expand Down Expand Up @@ -61,6 +62,7 @@ def test_saltutil_sync_all_test(self):
sync_output = {
'clouds': [],
'engines': [],
'executors': [],
'grains': [],
'beacons': [],
'utils': [],
Expand Down Expand Up @@ -92,6 +94,7 @@ def test_saltutil_sync_all_change(self):
sync_output = {
'clouds': [],
'engines': [],
'executors': [],
'grains': [],
'beacons': [],
'utils': [],
Expand Down