hbellahc
hbellahc

Reputation: 91

SaltStack : How I can copy file from minion to SaltStack File Server

I need to copy a file from a minion to the saltstack server file (salt://)

How can I achieve this ?

I tried a state like this but is not working.

copy:
  file.managed:
    - name: salt://a.txt
    - source: /tmp/a.txt

Hicham

Upvotes: 2

Views: 2500

Answers (1)

blhsing
blhsing

Reputation: 106881

You can use cp.push:

copy:
  module.run:
    - name: cp.push
    - path: /tmp/a.txt
    - upload_path: /tmp

Note that as documented, for security purposes, you have to set file_recv to True in the master configuration file, and restart the master, in order to enable this feature, and even then the minion is only allowed to upload the file to the minion's cache directory (/var/cache/salt/master/minions/minion-id/files). Specifying upload_path would upload the file to a sub-directory inside the cache directory.

Upvotes: 3

Related Questions