mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
adding sudo exec module docs
This commit is contained in:
parent
e4a40b7bd8
commit
a9269c072a
1 changed files with 36 additions and 3 deletions
|
@ -1,6 +1,31 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Allow for the calling of execution modules via sudo
|
||||
Allow for the calling of execution modules via sudo.
|
||||
|
||||
This module is invoked by the minion if the ``sudo_user`` minion config is
|
||||
present.
|
||||
|
||||
Example minion config:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
sudo_user: saltdev
|
||||
|
||||
Once this setting is made, any execution module call done by the minion will be
|
||||
run under ``sudo -u <sudo_user> salt-call``. For example, with the above
|
||||
minion config,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt sudo_minion cmd.run 'cat /etc/sudoers'
|
||||
|
||||
is equivalent to
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo -u saltdev salt-call cmd.run 'cat /etc/sudoers'
|
||||
|
||||
being run on ``sudo_minion``.
|
||||
'''
|
||||
# Import python libs
|
||||
import json
|
||||
|
@ -21,9 +46,17 @@ def salt_call(runas, fun, *args, **kwargs):
|
|||
'''
|
||||
Wrap a shell execution out to salt call with sudo
|
||||
|
||||
CLI Example::
|
||||
Example:
|
||||
|
||||
salt '*' sudo.salt_call root test.ping
|
||||
/etc/salt/minion
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
sudo_user: saltdev
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' test.ping # is run as saltdev user
|
||||
'''
|
||||
cmd = ['sudo',
|
||||
'-u', runas,
|
||||
|
|
Loading…
Add table
Reference in a new issue