noob saltstack question
I have a file that is created in a salt state (a war file) and I want to copy that file to the server's deploy directory when it changes. I was thinking file.managed
would be the right approach, so something like:
/var/lib/tomcat7/webapps/app.war:
file.managed:
- source: /home/user/project/build/release/app.war
- user: tomcat7
- group: tomcat7
The file is built via a separate state, which seems to be running properly.
When salt exec's state.highstate
, the output is
"Unable to determine upstream hash of source file /home/user/project/build/release/app.war"
Is there a better way to do this? Build a file in one state (so it is local) and then update a target when the built file changes? Thanks for any advice.
You need to change that to a file.copy
instead, as file.managed
is for fetching files over from the salt master or HTTP/FTP servers.
/var/lib/tomcat7/webapps/app.war:
file.copy:
- source: /home/user/project/build/release/app.war
- force: True
- user: tomcat7
- group: tomcat7
- require:
- cmd: the_build_state
As for linking it to the build, you need to use require
, as in the modified state above, which assumes that your build state is defined like this:
the_build_state:
- cmd.run:
...