Some Saltstack related commands and tricks I want to quickly find again

Posted April 16, 2021 by Adrian Wyssmann

Below a summary of important Salt commands


Update the fileserver cache. If no backend is provided, then the cache for all configured backends will be updated.

salt-run fileserver.update
# Narrow fileserver backends to a subset of the enabled ones
salt-run fileserver.update backend=roots,git

Forcibly removes all caches on a minion.

salt '*' saltutil.clear_cache


Passing pillar data ad hoc

salt '*' state.apply ftpsync pillar='{"ftpusername": "test", "ftppassword": "0ydyfww3giq8"}'

Return a list of files from the salt fileserver

salt-run fileserver.file_list 
# Lists only files for fileserver environment 'prod'
salt-run fileserver.file_list saltenv=prod
# Narrow fileserver backends to git only
salt-run fileserver.file_list saltenv=dev backend=git

Apply a state or states to

# apply all configured states
salt '*' state.apply
# Custom Pillar values, passed as a dictionary of key-value pairs
salt '*' state.apply test pillar='{"foo": "bar"}'
# Exclude specific states from execution
salt '*' state.apply exclude="[{'id': 'id_to_exclude'}, {'sls': 'sls_to_exclude'}]"


We are going to use the Salt pillar value we just configured, so let’s first refresh Salt pillar data on all minions:

salt '*' saltutil.refresh_pillar


Available grains can and grain values can be listed

# list grains
salt '*'
# list grains data
salt '*' grains.items

List values for a specific grain for all minions

salt '*' grains.get os

Edit this page