Background: I have been working on setting up a salt-environment, and reached the point where I want to distribute not only files, but also directories. I've found that the most sensible way to do this is to place the directory I want copied in /srv/salt/path_to_dir on the master, and then use the cp.get_dir command to distribute it.

What I have done: To test the setup and command I created /srv/salt/tmp/foo and placed two files in it. Then when I run the command salt minion_name cp.get_dir salt://tmp/foo /tmp/foo on the master there is one line of output that reads exactly minion_name:. Somewhat strange that there is no output except the minion name, even error, but ok, I go to check the minion to see if anything has happened.

On the minion it has not appeared in /tmp/, and there is no new content in /etc/salt/ or /var/cache/salt/ either. I checked in /var/log/salt/minion, but there is nothing except my hour old attempts at figuring out why I couldn't use file.copy with recursion set to true for distributing files.

My question(s): Is there anything obvious that I have done wrong? According to the documentation I found what I have done should work. There doesn't seem to be any error output either. Should I try using a different command or approach to distribute folders with content from the master through salt instead?

Additional information: Both the master and all the minions are Debian-systems. The installed versions of salt are salt 2014.1.3 (Hydrogen) on the master and salt-minion 0.17.5 and salt-minion 2015.5.3 on the minions I have tried this approach with.

1 Answer 1


I'm not sure how you can do this using modules, I tried the same ones you did and had the same results, so possibly a bug, but if you want to set up an sls state you can use the file.recurse functionality, it looks like this:

as reference I'm using:

  • /srv/salt/test1/init.sls as my sls file,
  • inside test1 is the src directory testdir
  • our target on the machine we want to copy to is /test


  - source: salt://test1/testdir
  - include_empty: True

from that point you can

salt '<targetmachine>' state.sls test1
  • Thanks, it's nice to hear that it's not just something I messed up, and also your solution works nicely =) There is a slight typo though, I guess it was supposed to be '<targetmachine>' and not '<targetmachine>/, but I could not suggest an edit of only one char, so I'm just putting it down here.
    – simonra
    Sep 16, 2015 at 12:21
  • haha, Yeah, Definitely a typo, Fixed. Glad that it worked out for you. Hopefully whatever is wrong with the cp module will get fixed in the near future.
    – Gravy
    Sep 16, 2015 at 19:23

You must log in to answer this question.

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