Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy a file from salt master to minions

Tags:

salt-project

Using the Salt python client API, is there a way to copy files from the master to minion without using Salt File Server?

I don't want to use the cp module or source salt://.

like image 926
bijalcm Avatar asked Jan 29 '26 15:01

bijalcm


1 Answers

You could create salt state to do this: Contents of /srv/salt/copyfiles.sls:

copy_my_files:
  file.recurse:
    - source: salt://DIR_TO_COPY
    - target: /home/DESTINATION_DIR
    - makedirs: True

Then run salt \* state.sls copyfiles

or

ret = local.cmd('*', 'state.sls', ['copyfiles', ])
print json.dumps(ret, indent=2)

Test the syntax of the local.cmd above. I haven't tried it on my system, but it should be similar to that.

like image 122
Utah_Dave Avatar answered Feb 01 '26 17:02

Utah_Dave