%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/states/cmd.pyo

�
���^c@@sdZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlZ	ddlm
Z
mZddlmZeje�Zd�Zd�Zd�Zd	�Zdddddddedd
eedd�
Ze	jjjed�Zddddddddeded
ed
�
Zddddddddedd
edeedd�Z dddddddddedded
edddd�Z!dddddd
eed�Z"dddddeed
ed�	Z#d�Z$dS(u�
Execution of arbitrary commands
===============================

The cmd state module manages the enforcement of executed commands, this
state can tell a command to run under certain circumstances.


A simple example to execute a command:

.. code-block:: yaml

    # Store the current date in a file
    'date > /tmp/salt-run':
      cmd.run

Only run if another execution failed, in this case truncate syslog if there is
no disk space:

.. code-block:: yaml

    '> /var/log/messages/:
      cmd.run:
        - unless: echo 'foo' > /tmp/.test && rm -f /tmp/.test

Only run if the file specified by ``creates`` does not exist, in this case
touch /tmp/foo if it does not exist:

.. code-block:: yaml

    touch /tmp/foo:
      cmd.run:
        - creates: /tmp/foo

``creates`` also accepts a list of files:

.. code-block:: yaml

    "echo 'foo' | tee /tmp/bar > /tmp/baz":
      cmd.run:
        - creates:
          - /tmp/bar
          - /tmp/baz

.. note::

    The ``creates`` option was added to version 2014.7.0

Sometimes when running a command that starts up a daemon, the init script
doesn't return properly which causes Salt to wait indefinitely for a response.
In situations like this try the following:

.. code-block:: yaml

    run_installer:
      cmd.run:
        - name: /tmp/installer.bin > /dev/null 2>&1

Salt determines whether the ``cmd`` state is successfully enforced based on the exit
code returned by the command. If the command returns a zero exit code, then salt
determines that the state was successfully enforced. If the script returns a non-zero
exit code, then salt determines that it failed to successfully enforce the state.
If a command returns a non-zero exit code but you wish to treat this as a success,
then you must place the command in a script and explicitly set the exit code of
the script to zero.

Please note that the success or failure of the state is not affected by whether a state
change occurred nor the stateful argument.

When executing a command or script, the state (i.e., changed or not)
of the command is unknown to Salt's state system. Therefore, by default, the
``cmd`` state assumes that any command execution results in a changed state.

This means that if a ``cmd`` state is watched by another state then the
state that's watching will always be executed due to the `changed` state in
the ``cmd`` state.

.. _stateful-argument:

Using the "Stateful" Argument
-----------------------------

Many state functions in this module now also accept a ``stateful`` argument.
If ``stateful`` is specified to be true then it is assumed that the command
or script will determine its own state and communicate it back by following
a simple protocol described below:

1. :strong:`If there's nothing in the stdout of the command, then assume no
   changes.` Otherwise, the stdout must be either in JSON or its `last`
   non-empty line must be a string of key=value pairs delimited by spaces (no
   spaces on either side of ``=``).

2. :strong:`If it's JSON then it must be a JSON object (e.g., {}).` If it's
   key=value pairs then quoting may be used to include spaces.  (Python's shlex
   module is used to parse the key=value string)

   Two special keys or attributes are recognized in the output::

    changed: bool (i.e., 'yes', 'no', 'true', 'false', case-insensitive)
    comment: str  (i.e., any string)

   So, only if ``changed`` is ``True`` then assume the command execution has
   changed the state, and any other key values or attributes in the output will
   be set as part of the changes.

3. :strong:`If there's a comment then it will be used as the comment of the
   state.`

   Here's an example of how one might write a shell script for use with a
   stateful command:

   .. code-block:: bash

       #!/bin/bash
       #
       echo "Working hard..."

       # writing the state line
       echo  # an empty line here so the next line will be the last.
       echo "changed=yes comment='something has changed' whatever=123"

   And an example SLS file using this module:

   .. code-block:: yaml

       Run myscript:
         cmd.run:
           - name: /path/to/myscript
           - cwd: /
           - stateful: True

       Run only if myscript changed something:
         cmd.run:
           - name: echo hello
           - cwd: /
           - onchanges:
               - cmd: Run myscript

   Note that if the second ``cmd.run`` state also specifies ``stateful: True`` it can
   then be watched by some other states as well.

4. :strong:`The stateful argument can optionally include a test_name parameter.`

   This is used to specify a command to run in test mode.  This command should
   return stateful data for changes that would be made by the command in the
   name parameter.

   .. versionadded:: 2015.2.0

   .. code-block:: yaml

       Run myscript:
         cmd.run:
           - name: /path/to/myscript
           - cwd: /
           - stateful:
             - test_name: /path/to/myscript test

       Run masterscript:
         cmd.script:
           - name: masterscript
           - source: salt://path/to/masterscript
           - cwd: /
           - stateful:
             - test_name: masterscript test


Should I use :mod:`cmd.run <salt.states.cmd.run>` or :mod:`cmd.wait <salt.states.cmd.wait>`?
--------------------------------------------------------------------------------------------

.. note::

    Use :mod:`cmd.run <salt.states.cmd.run>` together with :ref:`onchanges <requisites-onchanges>`
    instead of :mod:`cmd.wait <salt.states.cmd.wait>`.

These two states are often confused. The important thing to remember about them
is that :mod:`cmd.run <salt.states.cmd.run>` states are run each time the SLS
file that contains them is applied. If it is more desirable to have a command
that only runs after some other state changes, then :mod:`cmd.wait
<salt.states.cmd.wait>` does just that. :mod:`cmd.wait <salt.states.cmd.wait>`
is designed to :ref:`watch <requisites-watch>` other states, and is
executed when the state it is watching changes. Example:

.. code-block:: yaml

    /usr/local/bin/postinstall.sh:
      cmd.wait:
        - watch:
          - pkg: mycustompkg
      file.managed:
        - source: salt://utils/scripts/postinstall.sh

    mycustompkg:
      pkg.installed:
        - require:
          - file: /usr/local/bin/postinstall.sh

``cmd.wait`` itself does not do anything; all functionality is inside its ``mod_watch``
function, which is called by ``watch`` on changes.

The preferred format is using the :ref:`onchanges Requisite <requisites-onchanges>`, which
works on ``cmd.run`` as well as on any other state. The example would then look as follows:

.. code-block:: yaml

    /usr/local/bin/postinstall.sh:
      cmd.run:
        - onchanges:
          - pkg: mycustompkg
      file.managed:
        - source: salt://utils/scripts/postinstall.sh

    mycustompkg:
      pkg.installed:
        - require:
          - file: /usr/local/bin/postinstall.sh

How do I create an environment from a pillar map?
-------------------------------------------------

The map that comes from a pillar can be directly consumed by the env option!
To use it, one may pass it like this. Example:

.. code-block:: yaml

    printenv:
      cmd.run:
        - env: {{ salt['pillar.get']('example:key', {}) }}

i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionErrortSaltRenderError(tsixc
C@s�|d}i|d<d|d<|jd�}|sW|jd�rS|d|d<n|St}y;tjjj|�}t|t�s�t|d�St	}Wn�t
k
r[|j�jd�}|dkr�||d	}ni}yCx<tjj
j|�D]%}|jd
�\}}|||<q�WWq\t
k
rWt|d�}|dj|�|SXnXt|jdd
��}	d|kr�|d|d<|d=n|	r�x"|D]}|j|||�q�W|r�dn|jdd�| |d<||d<n|S(uO
    Re-interpret the state returned by salt.state.run using our protocol.
    uchangesuucommentustdoutustderru4script JSON output must be a JSON object (e.g., {})!u
i����iu=uPFailed parsing script output! Stdout must be JSON or a line of name=value pairs.uchangeduno(tgettFalsetsalttutilstjsontloadst
isinstancetdictt_failouttTruet
ValueErrortrstriptrfindtargstshlex_splittsplittupdatet_is_truet
setdefault(
tstatetrettouttis_jsontdatatidxtitemtkeytvaltchanged((s3/usr/lib/python2.7/site-packages/salt/states/cmd.pyt_reinterpreted_state�sR





		

&
cC@s||d<t|d<|S(Nucommenturesult(R(Rtmsg((s3/usr/lib/python2.7/site-packages/salt/states/cmd.pyR8s

cC@s]|r%tj|�j�dkr%tStj|�j�d	krDtStdj|���dS(
Nutrueuyesu1ufalseunou0u!Failed parsing boolean value: {0}(utrueuyesu1(ufalseunou0(Rt	text_typetlowerRRRtformat(R!((s3/usr/lib/python2.7/site-packages/salt/states/cmd.pyR>s
!c	C@s\tj|�}t|d<t|d<|dk	rkt|tj�r�td|dtdt|�}t	j
dj|��|dkrhidd	6td
6td6Sqkt|t�r'x�|D]l}td|dtdt|�}t	j
dj||��|dkr�id
j|�d	6td
6td6Sq�Wqkt|tj�sk|sht	j
d�idd	6td
6td6Sqkn|dk	r�t|tj�r�td|dtdt|�}t	j
dj|��|dkr�idd	6td
6td6Sq�t|t�r�g}xJ|D]B}|j
td|dtdt|��t	j
dj|��qWtg|D]}|dk^qR�r�idd	6td
6td6Sq�t|tj�s�|r�t	j
d�idd	6td
6td6Sq�nt|tj�rtjj|�ridj|�d	6td6St|t�rXtg|D]}tjj|�^q%�rXidd	6td6StS(u�
    Execute the onlyif and unless logic.
    Return a result dict if:
    * onlyif failed (onlyif != 0)
    * unless succeeded (unless == 0)
    else return True
    uuse_vtubgucmd.retcodetignore_retcodetpython_shelluLast command return code: {0}iuonlyif condition is falseucommentu
skip_watchuresultu#Last command '{0}' return code: {1}uonlyif condition is false: {0}u7Command not run: onlyif did not evaluate to string_typeuunless condition is trueu7Command not run: unless did not evaluate to string_typeu
{0} existsuAll files in creates existN(tcopytdeepcopyRtNoneRRtstring_typest__salt__RtlogtdebugR'tlisttappendtalltostpathtexists(t
cmd_kwargstonlyiftunlesstcreatestcmdtentrytcR5((s3/usr/lib/python2.7/site-packages/salt/states/cmd.pyt
mod_run_checkFsp








&%


$(
udebugcK@s i|d6id6td6dd6S(u�

    Run the given command only if the watch statement calls it.

    .. note::

        Use :mod:`cmd.run <salt.states.cmd.run>` together with :mod:`onchanges </ref/states/requisites#onchanges>`
        instead of :mod:`cmd.wait <salt.states.cmd.wait>`.

    name
        The command to execute, remember that the command will execute with the
        path and permissions of the salt-minion.

    onlyif
        A command to run as a check, run the named command only if the command
        passed to the ``onlyif`` option returns true

    unless
        A command to run as a check, only run the named command if the command
        passed to the ``unless`` option returns false

    cwd
        The current working directory to execute the command in, defaults to
        /root

    runas
        The user name to run the command as

    shell
        The shell to use for execution, defaults to /bin/sh

    env
        A list of environment variables to be set prior to execution.
        Example:

        .. code-block:: yaml

            script-foo:
              cmd.wait:
                - env:
                  - BATCH: 'yes'

        .. warning::

            The above illustrates a common PyYAML pitfall, that **yes**,
            **no**, **on**, **off**, **true**, and **false** are all loaded as
            boolean ``True`` and ``False`` values, and must be enclosed in
            quotes to be used as strings. More info on this (and other) PyYAML
            idiosyncrasies can be found :ref:`here <yaml-idiosyncrasies>`.

        Variables as values are not evaluated. So $PATH in the following
        example is a literal '$PATH':

        .. code-block:: yaml

            script-bar:
              cmd.wait:
                - env: "PATH=/some/path:$PATH"

        One can still use the existing $PATH by using a bit of Jinja:

        .. code-block:: jinja

            {% set current_path = salt['environ.get']('PATH', '/bin:/usr/bin') %}

            mycommand:
              cmd.run:
                - name: ls -l /
                - env:
                  - PATH: {{ [current_path, '/my/special/bin']|join(':') }}

    umask
         The umask (in octal) to use when running the command.

    stateful
        The command being executed is expected to return data about executing
        a state. For more information, see the :ref:`stateful-argument` section.

    creates
        Only run if the file or files specified by ``creates`` do not exist.

        .. versionadded:: 2014.7.0

    output_loglevel : debug
        Control the loglevel at which the output from the command is logged to
        the minion log.

        .. note::
            The command being run will still be logged at the ``debug``
            loglevel regardless, unless ``quiet`` is used for this value.

    hide_output : False
        Suppress stdout and stderr in the state's results.

        .. note::
            This is separate from ``output_loglevel``, which only handles how
            Salt logs to the minion log.

        .. versionadded:: 2018.3.0

    use_vt
        Use VT utils (saltstack) to stream the command output more
        interactively to the console and the logs.
        This is experimental.

    success_retcodes: This parameter will be allow a list of
        non-zero return codes that should be considered a success.  If the
        return code returned from the run matches any in the provided list,
        the return code will be overridden with zero.

      .. versionadded:: 2019.2.0
    unameuchangesuresultuucomment(R(tnameR8R9R:tcwdtrunastshelltenvtstatefultumasktoutput_loglevelthide_outputtuse_vttsuccess_retcodestkwargs((s3/usr/lib/python2.7/site-packages/salt/states/cmd.pytwait�s
uwatchcK@s i|d6id6td6dd6S(u�
    Download a script from a remote source and execute it only if a watch
    statement calls it.

    source
        The source script being downloaded to the minion, this source script is
        hosted on the salt master server.  If the file is located on the master
        in the directory named spam, and is called eggs, the source string is
        salt://spam/eggs

    template
        If this setting is applied then the named templating engine will be
        used to render the downloaded file, currently jinja, mako, and wempy
        are supported

    name
        The command to execute, remember that the command will execute with the
        path and permissions of the salt-minion.

    onlyif
        A command to run as a check, run the named command only if the command
        passed to the ``onlyif`` option returns true

    unless
        A command to run as a check, only run the named command if the command
        passed to the ``unless`` option returns false

    cwd
        The current working directory to execute the command in, defaults to
        /root

    runas
        The user name to run the command as

    shell
        The shell to use for execution, defaults to the shell grain

    env
        A list of environment variables to be set prior to execution.
        Example:

        .. code-block:: yaml

            salt://scripts/foo.sh:
              cmd.wait_script:
                - env:
                  - BATCH: 'yes'

        .. warning::

            The above illustrates a common PyYAML pitfall, that **yes**,
            **no**, **on**, **off**, **true**, and **false** are all loaded as
            boolean ``True`` and ``False`` values, and must be enclosed in
            quotes to be used as strings. More info on this (and other) PyYAML
            idiosyncrasies can be found :ref:`here <yaml-idiosyncrasies>`.

        Variables as values are not evaluated. So $PATH in the following
        example is a literal '$PATH':

        .. code-block:: yaml

            salt://scripts/bar.sh:
              cmd.wait_script:
                - env: "PATH=/some/path:$PATH"

        One can still use the existing $PATH by using a bit of Jinja:

        .. code-block:: jinja

            {% set current_path = salt['environ.get']('PATH', '/bin:/usr/bin') %}

            mycommand:
              cmd.run:
                - name: ls -l /
                - env:
                  - PATH: {{ [current_path, '/my/special/bin']|join(':') }}

    umask
         The umask (in octal) to use when running the command.

    stateful
        The command being executed is expected to return data about executing
        a state. For more information, see the :ref:`stateful-argument` section.

    use_vt
        Use VT utils (saltstack) to stream the command output more
        interactively to the console and the logs.
        This is experimental.

    output_loglevel : debug
        Control the loglevel at which the output from the command is logged to
        the minion log.

        .. note::
            The command being run will still be logged at the ``debug``
            loglevel regardless, unless ``quiet`` is used for this value.

    hide_output : False
        Suppress stdout and stderr in the state's results.

        .. note::
            This is separate from ``output_loglevel``, which only handles how
            Salt logs to the minion log.

        .. versionadded:: 2018.3.0

    success_retcodes: This parameter will be allow a list of
        non-zero return codes that should be considered a success.  If the
        return code returned from the run matches any in the provided list,
        the return code will be overridden with zero.

      .. versionadded:: 2019.2.0
    unameuchangesuresultuucomment(R(R?tsourcettemplateR8R9R@RARBRCRDRERHRFRGRJ((s3/usr/lib/python2.7/site-packages/salt/states/cmd.pytwait_scripts�
c
K@sWi|d6id6td6dd6}d|kru|jd�}d}tjjjd|�|jd	g�j|�nt}d"}t	|	t
�s�|	tk}	n0t	|	t
�r�d
|	dkr�|	dd
}ntdr�|r�|}n|d"k	rt	|t
t
f�rd
|d<|Stj|�}|ji|d6|d6|d6|pRtdd6|d6|d6|
d6|d6|d6|d6|d6�t||||�}t	|t
�r�|j|�|Stdr|rd"|d<dj|�|d<|	r�t|�S|S|r2tjj|�r2dj|�|d<|Sy#td|d|
dt|�}Wn'tk
r~}tj|�|d<|SX||d<t|d�|d<dj|�|d<|r
d}|djd�d kr
||djd!�kr
d|dd<t|d<q
n|	r"t|�}ntdrS|ddkrS|drSd"|d<n|S(#u�
    Run a command if certain circumstances are met.  Use ``cmd.wait`` if you
    want to use the ``watch`` requisite.

    name
        The command to execute, remember that the command will execute with the
        path and permissions of the salt-minion.

    onlyif
        A command to run as a check, run the named command only if the command
        passed to the ``onlyif`` option returns a zero exit status

    unless
        A command to run as a check, only run the named command if the command
        passed to the ``unless`` option returns a non-zero exit status

    cwd
        The current working directory to execute the command in, defaults to
        /root

    runas
        The user name to run the command as

    shell
        The shell to use for execution, defaults to the shell grain

    env
        A list of environment variables to be set prior to execution.
        Example:

        .. code-block:: yaml

            script-foo:
              cmd.run:
                - env:
                  - BATCH: 'yes'

        .. warning::

            The above illustrates a common PyYAML pitfall, that **yes**,
            **no**, **on**, **off**, **true**, and **false** are all loaded as
            boolean ``True`` and ``False`` values, and must be enclosed in
            quotes to be used as strings. More info on this (and other) PyYAML
            idiosyncrasies can be found :ref:`here <yaml-idiosyncrasies>`.

        Variables as values are not evaluated. So $PATH in the following
        example is a literal '$PATH':

        .. code-block:: yaml

            script-bar:
              cmd.run:
                - env: "PATH=/some/path:$PATH"

        One can still use the existing $PATH by using a bit of Jinja:

        .. code-block:: jinja

            {% set current_path = salt['environ.get']('PATH', '/bin:/usr/bin') %}

            mycommand:
              cmd.run:
                - name: ls -l /
                - env:
                  - PATH: {{ [current_path, '/my/special/bin']|join(':') }}

    prepend_path
        $PATH segment to prepend (trailing ':' not necessary) to $PATH. This is
        an easier alternative to the Jinja workaround.

        .. versionadded:: 2018.3.0

    stateful
        The command being executed is expected to return data about executing
        a state. For more information, see the :ref:`stateful-argument` section.

    umask
        The umask (in octal) to use when running the command.

    output_loglevel : debug
        Control the loglevel at which the output from the command is logged to
        the minion log.

        .. note::
            The command being run will still be logged at the ``debug``
            loglevel regardless, unless ``quiet`` is used for this value.

    hide_output : False
        Suppress stdout and stderr in the state's results.

        .. note::
            This is separate from ``output_loglevel``, which only handles how
            Salt logs to the minion log.

        .. versionadded:: 2018.3.0

    quiet
        This option no longer has any functionality and will be removed, please
        set ``output_loglevel`` to ``quiet`` to suppress logging of the
        command.

        .. deprecated:: 2014.1.0

    timeout
        If the command has not terminated after timeout seconds, send the
        subprocess sigterm, and if sigterm is ignored, follow up with sigkill

    ignore_timeout
        Ignore the timeout of commands, which is useful for running nohup
        processes.

        .. versionadded:: 2015.8.0

    creates
        Only run if the file or files specified by ``creates`` do not exist.

        .. versionadded:: 2014.7.0

    use_vt : False
        Use VT utils (saltstack) to stream the command output more
        interactively to the console and the logs.
        This is experimental.

    bg : False
        If ``True``, run command in background and do not await or deliver its
        results.

        .. versionadded:: 2016.3.6

    success_retcodes: This parameter will be allow a list of
        non-zero return codes that should be considered a success.  If the
        return code returned from the run matches any in the provided list,
        the return code will be overridden with zero.

      .. versionadded:: 2019.2.0

    .. note::

        cmd.run supports the usage of ``reload_modules``. This functionality
        allows you to force Salt to reload all modules. You should only use
        ``reload_modules`` if your cmd.run does some sort of installation
        (such as ``pip``), if you do not reload the modules future items in
        your state which rely on the software being installed will fail.

        .. code-block:: yaml

            getpip:
              cmd.run:
                - name: /usr/bin/python /usr/local/sbin/get-pip.py
                - unless: which pip
                - require:
                  - pkg: python
                  - file: /usr/local/sbin/get-pip.py
                - reload_modules: True

    unameuchangesuresultuucommentuquietu�The 'quiet' argument for cmd.run has been deprecated since 2014.1.0 and will be removed as of the Neon release. Please set 'output_loglevel' to 'quiet' instead.uNeonuwarningsu	test_nameiutestu7Invalidly-formatted 'env' parameter. See documentation.ucwdurunasuuse_vtushelluenvuprepend_pathuumaskuoutput_logleveluhide_outputusuccess_retcodesu&Command "{0}" would have been executedu0Desired working directory "{0}" is not availableucmd.run_allttimeoutR)uretcodeuCommand "{0}" runuTimed out afteriustdoutN(RtpopRR	tversionst
warn_untilRR2R,RR1Rt__opts__R
R*R+Rt
__grains__R>R'R#R4R5tisdirR.RRR%tboolR(R?R8R9R:R@RARBRCtprepend_pathRDRERFRGROtignore_timeoutRHRIRJRtquietR$t	test_nameR7tcrettcmd_allterrttrigger((s3/usr/lib/python2.7/site-packages/salt/states/cmd.pytrun�s~�

	"




2$
cK@sd&}t|
t�s$|
tk}
n0t|
t�rTd|
dkrT|
dd}ntdrm|rm|}ni|d6id6td6dd6}|	d&k	r�t|	ttf�r�d	|d<|S|r�t|t�r�d
|d<|S|rt|t�rd|d<|S|r|ni}|r/|j|�ntj	|�}|ji|d6|p[t
d
d
6|	d6|d6|d6|d6|d6|d6|d6|d6|d6|
d6|d6td6|d6�i|d6|d6|p�t
d
d
6}|d&kr�|}n|jdd&�rJt
|j��dkrJ|ji|jdd�dd6�nt||||�}t|t�r|j|�|Stdr�|r�d&|d<dj|�|d<|
r�t|�S|S|r�tjj|�r�dj|�|d<|Sytd |d!t|�}Wn0tttfk
r@}tj|�|d<|SX||d<|jd"t�rqt|�|d<nt|d"�|d<|jdi�jd#�r�d$j|t�|d<nd%j|�|d<|
r�t|�}ntdr|d"dkr|drd&|d<n|S('u*
    Download a script and execute it with specified arguments.

    source
        The location of the script to download. If the file is located on the
        master in the directory named spam, and is called eggs, the source
        string is salt://spam/eggs

    template
        If this setting is applied then the named templating engine will be
        used to render the downloaded file. Currently jinja, mako, and wempy
        are supported

    name
        Either "cmd arg1 arg2 arg3..." (cmd is not used) or a source
        "salt://...".

    onlyif
        Run the named command only if the command passed to the ``onlyif``
        option returns true

    unless
        Run the named command only if the command passed to the ``unless``
        option returns false

    cwd
        The current working directory to execute the command in, defaults to
        /root

    runas
        The name of the user to run the command as

    shell
        The shell to use for execution. The default is set in grains['shell']

    env
        A list of environment variables to be set prior to execution.
        Example:

        .. code-block:: yaml

            salt://scripts/foo.sh:
              cmd.script:
                - env:
                  - BATCH: 'yes'

        .. warning::

            The above illustrates a common PyYAML pitfall, that **yes**,
            **no**, **on**, **off**, **true**, and **false** are all loaded as
            boolean ``True`` and ``False`` values, and must be enclosed in
            quotes to be used as strings. More info on this (and other) PyYAML
            idiosyncrasies can be found :ref:`here <yaml-idiosyncrasies>`.

        Variables as values are not evaluated. So $PATH in the following
        example is a literal '$PATH':

        .. code-block:: yaml

            salt://scripts/bar.sh:
              cmd.script:
                - env: "PATH=/some/path:$PATH"

        One can still use the existing $PATH by using a bit of Jinja:

        .. code-block:: jinja

            {% set current_path = salt['environ.get']('PATH', '/bin:/usr/bin') %}

            mycommand:
              cmd.run:
                - name: ls -l /
                - env:
                  - PATH: {{ [current_path, '/my/special/bin']|join(':') }}

    saltenv : ``base``
        The Salt environment to use

    umask
         The umask (in octal) to use when running the command.

    stateful
        The command being executed is expected to return data about executing
        a state. For more information, see the :ref:`stateful-argument` section.

    timeout
        If the command has not terminated after timeout seconds, send the
        subprocess sigterm, and if sigterm is ignored, follow up with sigkill

    args
        String of command line args to pass to the script.  Only used if no
        args are specified as part of the `name` argument. To pass a string
        containing spaces in YAML, you will need to doubly-quote it:  "arg1
        'arg two' arg3"

    creates
        Only run if the file or files specified by ``creates`` do not exist.

        .. versionadded:: 2014.7.0

    use_vt
        Use VT utils (saltstack) to stream the command output more
        interactively to the console and the logs.
        This is experimental.

    context
        .. versionadded:: 2016.3.0

        Overrides default context variables passed to the template.

    defaults
        .. versionadded:: 2016.3.0

        Default context passed to the template.

    output_loglevel : debug
        Control the loglevel at which the output from the command is logged to
        the minion log.

        .. note::
            The command being run will still be logged at the ``debug``
            loglevel regardless, unless ``quiet`` is used for this value.

    hide_output : False
        Suppress stdout and stderr in the state's results.

        .. note::
            This is separate from ``output_loglevel``, which only handles how
            Salt logs to the minion log.

        .. versionadded:: 2018.3.0

    success_retcodes: This parameter will be allow a list of
        non-zero return codes that should be considered a success.  If the
        return code returned from the run matches any in the provided list,
        the return code will be overridden with zero.

      .. versionadded:: 2019.2.0

    u	test_nameiutestunameuchangesuresultuucommentu7Invalidly-formatted 'env' parameter. See documentation.uBInvalidly-formatted 'context' parameter. Must be formed as a dict.uCInvalidly-formatted 'defaults' parameter. Must be formed as a dict.urunasushelluenvuonlyifuunlessucwdutemplateuumaskutimeoutuoutput_logleveluhide_outputuuse_vtucontextusaltenvusuccess_retcodesuargsiu u&Command '{0}' would have been executedu0Desired working directory "{0}" is not availableu
cmd.scriptR)uretcodeucache_erroru-Unable to cache script {0} from saltenv '{1}'uCommand '{0}' runN(R,RR1RRSRR
RR*R+RTt__env__RtlenRR>R'R#R4R5RUR.RRtIOErrorRR%RV(R?RLRMR8R9R:R@RARBRCRDRERORHRFRGtdefaultstcontextRIRJRZRttmpctxR7trun_check_cmd_kwargsR[R\R]((s3/usr/lib/python2.7/site-packages/salt/states/cmd.pytscript�s��	

"


	+'




$
c
K@sdi|d6id6td6dd6}i|
jd�d6|
jd�d6|
jd	�p[td	d	6|
jd
�d
6|	d6|d6|d
6|
jd�d6}t||||�}
t|
t�r�|j|
�|S|s�i}n|||�}t|t�r
|j|�|Si|d6|d<|dkr-tn	t	|�|d<t|t
j�r\||d<n|SdS(u
    Invoke a pre-defined Python function with arguments specified in the state
    declaration. This function is mainly used by the
    :mod:`salt.renderers.pydsl` renderer.

    The interpretation of ``onlyif`` and ``unless`` arguments are identical to
    those of :mod:`cmd.run <salt.states.cmd.run>`, and all other
    arguments(``cwd``, ``runas``, ...) allowed by :mod:`cmd.run
    <salt.states.cmd.run>` are allowed here, except that their effects apply
    only to the commands specified in `onlyif` and `unless` rather than to the
    function to be invoked.

    In addition, the ``stateful`` argument has no effects here.

    The return value of the invoked function will be interpreted as follows.

    If it's a dictionary then it will be passed through to the state system,
    which expects it to have the usual structure returned by any salt state
    function.

    Otherwise, the return value (denoted as ``result`` in the code below) is
    expected to be a JSON serializable object, and this dictionary is returned:

    .. code-block:: python

        {
            'name': name
            'changes': {'retval': result},
            'result': True if result is None else bool(result),
            'comment': result if isinstance(result, six.string_types) else ''
        }
    unameuchangesuresultuucommentucwduuserurunasushelluenvuuse_vtuoutput_logleveluhide_outputuumaskuretvalN(RRRTR>RR
RR,RRVRR-(R?tfuncRtkwsR8R9R:RFRGRHRJRR7R[tresult((s3/usr/lib/python2.7/site-packages/salt/states/cmd.pytcall�s6+


	
"
cK@s i|d6id6td6dd6S(Nunameuchangesuresultuucomment(R(R?RhRRiR8R9R:RDRHRFRGRJ((s3/usr/lib/python2.7/site-packages/salt/states/cmd.pyt	wait_calls
cK@sK|ddkrL|jd�r?|jd�tt||��St||�S|ddksl|ddkr�|jd�r�|jd�tt||��St||�S|ddks�|dd	kr"|jd
�r�|jd
�}t|||�Si|d6id6d
j|�d6td6Sni|d6id6dj|�d6td6S(u'
    Execute a cmd function based on a watch call

    .. note::
        This state exists to support special handling of the ``watch``
        :ref:`requisite <requisites>`. It should not be called directly.

        Parameters for this function should be set by the state being triggered.
    usfunuwaiturunuwatchustatefuluwait_scriptuscriptu	wait_callucallufuncunameuchangesu*cmd.{0[sfun]} needs a named parameter funcucommenturesultu\cmd.{0[sfun]} does not work with the watch requisite, please use cmd.wait or cmd.wait_script(uwaiturunuwatch(RRPR#R_RgRkR'R(R?RJRh((s3/usr/lib/python2.7/site-packages/salt/states/cmd.pyt	mod_watchs0


 

 



((((%t__doc__t
__future__RRRR4R*tloggingtsalt.utils.argsRtsalt.utils.functoolstsalt.utils.jsontsalt.exceptionsRRtsalt.extRt	getLoggert__name__R/R#RRR>R,RRKR	t	functoolstalias_functiontwatchRNR_RgRkRlRm(((s3/usr/lib/python2.7/site-packages/salt/states/cmd.pyt<module>�s�	>			Ky{��F	

Zerion Mini Shell 1.0