mc_state / module to execute functions on salt¶
-
mc_states.modules.mc_state.
sexec
(mod, func, *a, **kw)¶ Execute a function in a state module as if it is a state function, we dumb inject the salt variable globs on the fly. This is mainly only usable from other modules or runners as the first argument is a python module object.
- mod
- python module to search the function on
- func
- function to execute
- a
- positionnal arguments to pass to the function
- kw
- keyword arguments to pass to the function
Eg in an execution module:
- def func():
- “”“Wrapper to the user state”“” from salt.states import user as suser __salt__[‘mc_state.exec’](suser, ‘present’, ‘foo’)
Eg
from salt.states import file as sfile __salt__['mc_state.sexec']( sfile, 'managed', name = os.path.join(lgit, 'hooks/pre-receive'), source=( 'salt://makina-states/files/projects/2/' 'hooks/pre-receive'), defaults={'api_version': api_version, 'name': name}, user=user, group=group, mode='750', template='jinja')