How do I output the contents of a file on all my minions using Salt Stack?

The only 'pull' functionality I can find is in this minion push commit, but this requires configuration changes on the master.

3 Answers 3


Solution using cmd.run module:

salt '*' cmd.run 'cat /path/to/file'
  • This will only work if the file is small enough, otherwise you'll get "no response" timeouts. Jul 6, 2015 at 22:26

Get the contents of a file without using external commands:

sudo salt '*' cp.get_file_str file:///etc/hosts

This feature was added on a later version of Salt, you can find it in the salt official documentation on this link.

You can push a file from a salt minion to the master by issuing this command:

salt '*' cp.push /path/to/file

Keep in mind that you need to enable it on the salt master configuration file before by setting the file_recv option to True

  • where does the file end up?
    – eMBee
    Feb 25, 2019 at 4:20
  • By default, the file ends up under /var/cache/salt/master/minions/minion-id/files But it's also possible to set it with the upload_path='/new/path/fstab' option. Feb 25, 2019 at 13:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .