mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Set dynamically all possible Ansible callers as functions
This commit is contained in:
parent
48b79c03b6
commit
f48a363011
@ -109,6 +109,29 @@ class AnsibleModuleResolver(object):
|
||||
|
||||
_resolver = None
|
||||
|
||||
|
||||
def _set_callables(modules):
|
||||
'''
|
||||
Set all Ansible modules callables
|
||||
:return:
|
||||
'''
|
||||
def _mkf(cmd_name, doc):
|
||||
'''
|
||||
Create a Salt function for the Ansible module.
|
||||
'''
|
||||
def _cmd(*args, **kw):
|
||||
'''
|
||||
Call an Ansible module as a function from the Salt.
|
||||
'''
|
||||
global _caller
|
||||
return _caller.call(cmd_name)
|
||||
_cmd.__doc__ = doc
|
||||
return _cmd
|
||||
|
||||
for mod in modules:
|
||||
setattr(sys.modules[__name__], mod, _mkf(mod, 'Available'))
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
Ansible module caller.
|
||||
@ -121,6 +144,8 @@ def __virtual__():
|
||||
else:
|
||||
global _resolver
|
||||
_resolver = AnsibleModuleResolver(__opts__).resolve().install()
|
||||
_set_callables(list())
|
||||
|
||||
return ret, msg
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user