Search code examples
salt-projectdevops

Using 'salt.module.tomcat' for deploying war file


I am trying to deploy war file using salt module tomcat.deploy_war but get following error ... 'KeyError' seems like it doesn't recognize tomcat.deploy_war

enter image description here

Talking of sls file, the module file.managed worked fine

enter image description here

Seems like I will need to upgrade my salt master and version. Tried doing the same, got response that it's already upgraded.

Not sure what is the issue ?

enter image description here


Solution

  • tomcat.deploy_war is an execution module, not a state module. In general, execution modules like tomcat.deploy_war are always named imperatively ("deploy!", "delete!", "install!"). You cannot use execution modules in states directly; instead, they are intended to be used in ad-hoc Salt commands, for example to quickly deploy a WAR file using a command-line statement:

    salt 'tomcatminion' tomcat.deploy_war salt://path/to/app.war
    

    On the other hand state modules are intended to be used in states and are named declaratively (by the desired end state). In many cases, an execution module has a corresponding state module -- in your case tomcat.deploy_war and tomcat.war_deployed (or pkg.install and pkg.installed and so on):

    sample.war:
      tomcat.war_deployed:
        - war: salt://path/to/app.war
    

    See the respective documentations for the salt.modules.tomcat execution module and the salt.states.tomcat state module.