The following are some commonly used commands in SaltStack:
- View help information:
salt --help
- Check Salt supported operating systems:
salt '*' test.ping
- Check the version number of Minion:
salt '*' test.version
- Excuting an order:
salt '*' cmd.run 'command'
- Install the package:
salt '*' pkg.install 'package_name'
- Upgrade package:
salt '*' pkg.upgrade
- Remove the package:
salt '*' pkg.remove 'package_name'
- List installed packages:
salt '*' pkg.list_pkgs
- Check the system load:
salt '*' status.loadavg
- Check memory usage:
salt '*' status.meminfo
- Check hard drive usage:
salt '*' status.diskusage
- View CPU information:
salt '*' status.cpuinfo
- Restart Minion:
salt '*' system.reboot
- Close Minion:
salt '*' system.shutdown
- Get Minion’s network interface information:
salt '*' network.interfaces
- Get the Minion’s IP address:
salt '*' network.ip_addrs
- Get the Minion’s hostname:
salt '*' network.get_hostname
- synchronised time:
salt '*' system.set_date
- Check service status:
salt '*' service.status 'service_name'
- Start the service:
salt '*' service.start 'service_name'
- Out of service:
salt '*' service.stop 'service_name'
- Restart the service:
salt '*' service.restart 'service_name'
- Reload the configuration file:
salt '*' service.reload 'service_name'
- Check the status of the Minion:
salt '*' status.status
- Run the Grains module:
salt '*' grains.ls
- Check the Minion’s IP address:
salt '*' grains.get ipv4
- Check Minion’s operating system:
salt '*' grains.get os
- View Minion’s CPU information:
salt '*' grains.get cpu_model
- Set Minion’s custom variables:
salt '*' grains.setval 'custom_var' 'value'
- Synchronize Grains information:
salt '*' saltutil.sync_grains
- Execute custom module:
salt '*' mymodule.run
- Execute State file:
salt '*' state.apply 'state_file'
- Check the State file for invalid configuration:
salt '*' state.show_highstate
- Verify State file syntax:
salt '*' state.show_sls 'state_file'
- View the Highstate file:
salt '*' state.show_highstate
- Apply Highstate file:
salt '*' state.highstate
- Check out Minion’s Mine function:
salt '*' mine.get 'target_minion' 'mine_function'
- Refresh Mine function:
salt '*' mine.flush
- View execution results:
salt '*' jobs.active
- To forcefully terminate a job:
salt '*' saltutil.kill_job 'job_id'
- Execute remote execution command:
salt-cp '*' '/path/to/source.file' '/path/to/destination.file'
- Copy files to Minion:
salt-cp '*' '/path/to/source.file' '/path/to/destination.file'
- Copy files to Salt Master:
salt-cp '*' '/path/to/source.file' 'salt://destination.file'
- Install the extension module:
salt '*' saltutil.sync_all
- Add new Minions:
salt-key -a 'new_minion'
- Remove an offline Minion:
salt-key -d 'offline_minion'
- List accepted minions:
salt-key -L
- List rejected minions:
salt-key -R
- List Minions waiting to be accepted:
salt-key -P
- Check the status of Salt Master:
salt-run manage.status
- Synchronize the keys of all Minions:
salt-run manage.up
- List all Minions on the Master:
salt-run manage.present
- List unconnected Minions:
salt-run manage.down
- Perform grayscale publishing:
salt-run cache.grains 'grain_key:grain_value'
- Send events to the event bus:
salt-call event.send 'event_tag' data='event_data'
- View events on the event bus:
salt-run event.fire_master 'event_tag' data='event_data'
- Run the scheduled task:
salt-cron '*' enable_job <job_name>
- Disable scheduled tasks:
salt-cron '*' disable_job <job_name>
Here are some commonly used SaltStack commands to help you with configuration management, software package management, and system management. For specific command usage and parameters, please refer to SaltStack official documentation.