salt.resources.ssh.modules.cmd#
Execution module override for the ssh resource type.
This module is loaded into the per-type execution-module loader whenever the
resource_type in opts is "ssh". It shadows the standard
salt.modules.cmdmod and salt.modules.test functions for jobs that
are dispatched to SSH resources, delegating the actual work to
salt.resources.ssh via __resource_funcs__.
Because this loader is only ever used for resource jobs, there is no need
for the call-time proxy-style guard (if salt.utils.platform.is_proxy()).
The managing minion's own jobs continue to use the standard execution modules
loaded in the regular self.functions loader.
Usage#
Any execution module function that should behave differently when targeting an SSH resource can be implemented here. Functions not defined in this module fall through to the standard execution modules in the resource loader.
Example
# Ping an SSH resource
salt -C 'T@ssh:web-01' test.ping
# Run a shell command on an SSH resource
salt -C 'T@ssh:web-01' cmd.run 'uptime'
salt -C 'T@ssh' cmd.run 'df -h'
- salt.resources.ssh.modules.cmd.retcode(cmd, timeout=None, **kwargs)#
Execute a shell command on the targeted SSH resource and return only the exit code.
- Parameters:
- Return type:
CLI Example:
salt -C 'T@ssh:web-01' cmd.retcode 'test -f /etc/salt/minion'
- salt.resources.ssh.modules.cmd.run(cmd, timeout=None, **kwargs)#
Execute a shell command on the targeted SSH resource and return its standard output.
This is the SSH-resource equivalent of
salt.modules.cmdmod.run(). The command is executed directly on the remote host via the SSH Shell transport — no Salt thin deployment required.- Parameters:
- Return type:
str — stdout from the remote command
CLI Example:
salt -C 'T@ssh:web-01' cmd.run 'uptime' salt -C 'T@ssh' cmd.run 'df -h' timeout=60
- salt.resources.ssh.modules.cmd.run_all(cmd, timeout=None, **kwargs)#
Execute a shell command on the targeted SSH resource and return a dict containing
stdout,stderr, andretcode.This mirrors
salt.modules.cmdmod.run_all()for SSH resources.- Parameters:
- Return type:
CLI Example:
salt -C 'T@ssh:web-01' cmd.run_all 'uptime'