← 返回命令列表

Linux command

salt 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Ping all minions

salt '*' test.ping

Run command on minions

salt '*' cmd.run '[command]'

Target specific minion

salt '[minion-id]' test.ping

Apply state

salt '*' state.apply

Apply specific state

salt '*' state.apply [webserver]

Install package

salt '*' pkg.install [nginx]

Show grains

salt '[minion]' grains.items

Copy file

salt '*' cp.get_file [salt://file.txt] [/tmp/file.txt]

说明

salt is the primary command-line interface for SaltStack, a remote execution and configuration management system. It sends commands from the Salt master to minions (managed nodes), executing them in parallel across potentially thousands of systems simultaneously and returning results. Targeting determines which minions receive commands, using glob patterns (default), regular expressions (-E), grain-based matching (-G) for targeting by OS or hardware properties, or compound expressions (-C) combining multiple criteria. Execution modules provide hundreds of functions covering package management, file operations, service control, and system administration. States define the desired configuration of systems declaratively using YAML files. The state.apply function ensures minions converge to the defined state, making Salt suitable for both ad-hoc command execution and systematic infrastructure management.

参数

-G _GRAIN_
Target by grain.
-E
Regex target.
-L
List target.
-C
Compound target.
--async
Async execution.
--timeout _SECS_
Command timeout.
-v, --verbose
Verbose output.

FAQ

What is the salt command used for?

salt is the primary command-line interface for SaltStack, a remote execution and configuration management system. It sends commands from the Salt master to minions (managed nodes), executing them in parallel across potentially thousands of systems simultaneously and returning results. Targeting determines which minions receive commands, using glob patterns (default), regular expressions (-E), grain-based matching (-G) for targeting by OS or hardware properties, or compound expressions (-C) combining multiple criteria. Execution modules provide hundreds of functions covering package management, file operations, service control, and system administration. States define the desired configuration of systems declaratively using YAML files. The state.apply function ensures minions converge to the defined state, making Salt suitable for both ad-hoc command execution and systematic infrastructure management.

How do I run a basic salt example?

Run `salt '*' test.ping` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -G _GRAIN_ do in salt?

Target by grain.