forked from saltstack/salt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
171 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
''' | ||
Docker executor module | ||
.. versionadded: Fluorine | ||
Used with the docker proxy minion. | ||
''' | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
|
||
DOCKER_MOD_MAP = { | ||
'state.sls': 'docker.sls', | ||
'state.apply': 'docker.apply', | ||
'state.highstate': 'docker.highstate', | ||
} | ||
|
||
|
||
def execute(opts, data, func, args, kwargs): | ||
''' | ||
Directly calls the given function with arguments | ||
''' | ||
if data['fun'] == 'saltutil.find_job': | ||
return __executors__['direct_call.execute'](opts, data, func, args, kwargs) | ||
if data['fun'] in DOCKER_MOD_MAP: | ||
return __executors__['direct_call.execute'](opts, data, __salt__[DOCKER_MOD_MAP[data['fun']]], [opts['proxy']['name']] + args, kwargs) | ||
return __salt__['docker.call'](opts['proxy']['name'], data['fun'], *args, **kwargs) | ||
|
||
|
||
def allow_missing_funcs(): | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# -*- coding: utf-8 -*- | ||
''' | ||
Docker Proxy Minion | ||
.. versionadded: Fluorine | ||
:depends: docker | ||
This proxy minion is just a shim to the docker executor, which will use the | ||
:py:func:`docker.call <salt.modules.dockermod.call>` for everything except | ||
state runs. | ||
To configure the proxy minion: | ||
.. code-block:: yaml | ||
proxy: | ||
proxytype: docker | ||
name: festive_leakey | ||
It is also possible to just name the proxy minion the same name as the | ||
container, and use grains to configure the proxy minion: | ||
.. code-block:: yaml | ||
proxy: | ||
proxytype: docker | ||
name: {{grains['id']}} | ||
name | ||
Name of the docker container | ||
''' | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
__proxyenabled__ = ['docker'] | ||
__virtualname__ = 'docker' | ||
|
||
|
||
def __virtual__(): | ||
if __opts__.get('proxy', {}).get('proxytype') != __virtualname__: | ||
return False, 'Proxytype does not match: {0}'.format(__virtualname__) | ||
return True | ||
|
||
|
||
def module_executors(): | ||
''' | ||
List of module executors to use for this Proxy Minion | ||
''' | ||
return ['docker', ] | ||
|
||
|
||
def init(opts): | ||
''' | ||
Always initialize | ||
''' | ||
__context__['initialized'] = True | ||
|
||
|
||
def initialized(): | ||
''' | ||
This should always be initialized | ||
''' | ||
return __context__.get('initialized', False) | ||
|
||
|
||
def shutdown(opts): | ||
''' | ||
Nothing needs to be done to shutdown | ||
''' | ||
__context__['initialized'] = False |