salt-minion: - cmd.call - cmd.mod_run_check - cmd.mod_watch - cmd.run - cmd.script - cmd.wait - cmd.wait_call - cmd.wait_script - cmd.watch
cmd.run: 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 true 仅仅 onlyif 返回 true,才执行。 unless A command to run as a check, only run the named command if the command passed to the ``unless`` option returns false 仅仅 unless 返回 false, 才执行。 cwd The current working directory to execute the command in, defaults to /root user The user name to run the command as group The group context 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: 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 :doc:`here </topics/troubleshooting/yaml_idiosyncrasies>`. stateful The command being executed is expected to return data about executing a state umask The umask (in octal) to use when running the command. output_loglevel Control the loglevel at which the output from the command is logged. Note that the command being run will still be logged (loglevel: DEBUG) regardless, unless ``quiet`` is used for this value. quiet The command will be executed quietly, meaning no log entries of the actual command or its return data. This is deprecated as of the **2014.1.0** release, and is being replaced with ``output_loglevel: quiet``. timeout If the command has not terminated after timeout seconds, send the subprocess sigterm, and if sigterm is ignored, follow up with sigkill creates Only run if the file specified by ``creates`` does not exist. New in version 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. 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. 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: TrueES:test: cmd.run: - name: `which nginx` -s reload - onlyif: rpm -qa nginx
cmd.script: 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 user The name of the user to run the command as group The group context 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: 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 :doc:`here </topics/troubleshooting/yaml_idiosyncrasies>`. 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 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 specified by ``creates`` does not exist. New in version 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. output_loglevel Control the loglevel at which the output from the command is logged. Note that the command being run will still be logged (loglevel: DEBUG) regardless, unless ``quiet`` is used for this value.
时间: 2024-10-25 21:46:23