Salt Commands
This page provides a comprehensive guide to essential Salt commands for DevOps professionals. SaltStack is a powerful open-source automation and remote execution engine that simplifies system administration and configuration management across large fleets of servers.
Key Management with Salt
Efficiently manage Salt keys to establish secure communication between the Salt master and its minions. This section covers commands for listing, accepting, and removing keys.
# Show pending keys to be accepted:
salt-key -L
# Accept all pending keys:
salt-key -A
# Accept pending key by name:
salt-key -a <target>
# Remove key by name:
salt-key -D <target>
Remote Execution and Job Management
Execute commands on one or more minions and manage active jobs. Learn how to test minion connectivity and monitor or terminate running Salt jobs.
# Test minion connection:
salt <target> test.ping
# Show active salt jobs
salt-run jobs.active
# Kill active job
salt <target> saltutil.kill_job <job_id>
File Transfer with Salt
Transfer files between the Salt master and minions using Salt's built-in file copying capabilities. This includes commands for both small and large files, as well as pushing files from minions to the master.
# Copy small file (< 100kb) from master to minion
salt-cp <target> <source> <dest>
# Copy large file from master (/srv/salt/<source>) directory to minion
salt <target> cp.get_file salt://<source> <destination>
# Copy file from minion to master (will be stored at /var/cache/salt/master/minions/<minion_name>/files
salt <target> cp.push <source>
Deploying Salt States
Apply Salt states to configure and manage the desired state of your minions. This is a core function of SaltStack for declarative configuration management.
# Deploy state
salt <target> state.apply <state_name>