I want to copy a file from salt stack master server to minion servers. I found a script from https://stackoverflow.com/questions/27687886/copy-a-file-from-salt-master-to-minions. But I got an error.
copy_my_files:
file.recurse:
- source: salt://srv/salt/nginx.conf
- target: /etc/nginx
- makedirs: True
Error:-
ID: copy_my_files
Function: file.recurse
Result: False
Comment: Specified file copy_my_files is not an absolute path
Started: 09:46:24.850682
Duration: 1.473 ms
Changes:
I have given correct paths for both.
Best Answer
file.recurse is for copying the content of a directory if I'm correct. Here, what you have to do to copy just one file would be to use file.managed.
For instance reusing your example, this should be working:
Note that the nginx.conf file you want to copy has to be located in /srv/salt on the salt master. Thats the default place were the salt:// is pointing (unless you modified your configuration)
If you want to copy multiple file using the file.recurse it's also quite easy