Saltstack file.manage_file not finding the source file

51 Views Asked by At

I am running the command

salt-ssh 'my-vm' file.manage_file /home/file.txt '' '{}' salt://file.txt '{}' root root '700' '' myenv ''

But i get the following error message

comment: Source file 'salt://file.txt' not found

N.B that when putting this in a state file and running apply state there is no error and the file is placed on my-vm as expected

Salt master has the configuration

file_roots:
  myenv:
    - /srv/salt/states/base

and my file.txt lives in

/srv/salt/states/base/file.txt
1

There are 1 best solutions below

3
OrangeDog On

file.manage_file is an execution function, not a state, and not designed for direct use. For example, it requires file.get_managed to have been called first.

To manage a single file from the command line, use the state.single function:

salt-ssh 'my-vm' state.single file.managed name=/home/file.txt source=salt://file.txt saltenv=myenv