salt.states.tomcat

This state uses the manager webapp to manage Apache tomcat webapps This state requires the manager webapp to be enabled

The following grains/pillar should be set:

tomcat-manager:user: admin user name
tomcat-manager:passwd: password

and also configure a user in the conf/tomcat-users.xml file:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
    <role rolename="manager-script"/>
    <user username="tomcat" password="tomcat" roles="manager-script"/>
</tomcat-users>

Notes:

salt.states.tomcat.mod_watch(name, url='http://localhost:8080/manager', timeout=180)

The tomcat watcher function. When called it will reload the webapp in question

salt.states.tomcat.undeployed(name, url='http://localhost:8080/manager', timeout=180)

Enforce that the WAR will be un-deployed from the server

name
the context path to deploy
url
: http://localhost:8080/manager
the URL of the server manager webapp
timeout
: 180
timeout for HTTP request to the tomcat manager

Example:

jenkins:
  tomcat.undeployed:
    - name: /ran
    - require:
      - service: application-service
salt.states.tomcat.wait(name, url='http://localhost:8080/manager', timeout=180)

Wait for the tomcat manager to load

Notice that if tomcat is not running we won't wait for it start and the state will fail. This state can be required in the tomcat.war_deployed state to make sure tomcat is running and that the manager is running as well and ready for deployment

url
: http://localhost:8080/manager
the URL of the server manager webapp
timeout
: 180
timeout for HTTP request to the tomcat manager

Example:

tomcat-service:
  service.running:
    - name: tomcat
    - enable: True

wait-for-tomcatmanager:
  tomcat.wait:
    - timeout: 300
    - require:
      - service: tomcat-service

jenkins:
  tomcat.war_deployed:
    - name: /ran
    - war: salt://jenkins-1.2.4.war
    - require:
      - tomcat: wait-for-tomcatmanager
salt.states.tomcat.war_deployed(name, war, force=False, url='http://localhost:8080/manager', timeout=180, temp_war_location=None, version='')

Enforce that the WAR will be deployed and started in the context path it will make use of WAR versions

for more info:
http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Naming
name
the context path to deploy
war
absolute path to WAR file (should be accessible by the user running tomcat) or a path supported by the salt.modules.cp.get_url function
force
force deploy even if version strings are the same, False by default.
url
: http://localhost:8080/manager
the URL of the server manager webapp
timeout
: 180
timeout for HTTP request to the tomcat manager
temp_war_location
: None
use another location to temporarily copy to war file by default the system's temp directory is used
version
: ''

Specify the war version. If this argument is provided, it overrides the version encoded in the war file name, if one is present.

New in version 2015.8.6.

Example:

jenkins:
  tomcat.war_deployed:
    - name: /ran
    - war: salt://jenkins-1.2.4.war
    - require:
      - service: application-service