salt.modules.tomcat

Support for Tomcat

This module uses the manager webapp to manage Apache tomcat webapps. If the manager webapp is not configured some of the functions won't work.

Note

The config format was changed in 2014.7.0, but backwards compatibility for the old-style config will be in the 2014.7.1 release.

The following grains/pillar should be set:

tomcat-manager:
  user: <username>
  passwd: <password>

or the old format:

tomcat-manager.user: <username>
tomcat-manager.passwd: <password>

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>

Note

salt.modules.tomcat.deploy_war(war, context, force='no', url='http://localhost:8080/manager', saltenv='base', timeout=180, env=None, temp_war_location=None)

Deploy a WAR file

war
absolute path to WAR file (should be accessible by the user running tomcat) or a path supported by the salt.modules.cp.get_file function
context
the context path to deploy
force : False
set True to deploy the webapp even one is deployed in the context
url : http://localhost:8080/manager
the URL of the server manager webapp
saltenv : base
the environment for WAR file in used by salt.modules.cp.get_url function
timeout : 180
timeout for HTTP request
temp_war_location : None
use another location to temporarily copy to war file by default the system's temp directory is used

CLI Examples:

cp module

salt '*' tomcat.deploy_war salt://application.war /api
salt '*' tomcat.deploy_war salt://application.war /api no
salt '*' tomcat.deploy_war salt://application.war /api yes http://localhost:8080/manager

minion local file system

salt '*' tomcat.deploy_war /tmp/application.war /api
salt '*' tomcat.deploy_war /tmp/application.war /api no
salt '*' tomcat.deploy_war /tmp/application.war /api yes http://localhost:8080/manager
salt.modules.tomcat.fullversion()

Return all server information from catalina.sh version

CLI Example:

salt '*' tomcat.fullversion
salt.modules.tomcat.leaks(url='http://localhost:8080/manager', timeout=180)

Find memory leaks in tomcat

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

CLI Examples:

salt '*' tomcat.leaks
salt.modules.tomcat.ls(url='http://localhost:8080/manager', timeout=180)

list all the deployed webapps

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

CLI Examples:

salt '*' tomcat.ls
salt '*' tomcat.ls http://localhost:8080/manager
salt.modules.tomcat.passwd(passwd, user='', alg='md5', realm=None)

This function replaces the $CATALINA_HOME/bin/digest.sh script convert a clear-text password to the $CATALINA_BASE/conf/tomcat-users.xml format

CLI Examples:

salt '*' tomcat.passwd secret
salt '*' tomcat.passwd secret tomcat sha1
salt '*' tomcat.passwd secret tomcat sha1 'Protected Realm'
salt.modules.tomcat.reload_(app, url='http://localhost:8080/manager', timeout=180)

Reload the webapp

app
the webapp context path
url : http://localhost:8080/manager
the URL of the server manager webapp
timeout : 180
timeout for HTTP request

CLI Examples:

salt '*' tomcat.reload /jenkins
salt '*' tomcat.reload /jenkins http://localhost:8080/manager
salt.modules.tomcat.serverinfo(url='http://localhost:8080/manager', timeout=180)

return details about the server

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

CLI Examples:

salt '*' tomcat.serverinfo
salt '*' tomcat.serverinfo http://localhost:8080/manager
salt.modules.tomcat.sessions(app, url='http://localhost:8080/manager', timeout=180)

return the status of the webapp sessions

app
the webapp context path
url : http://localhost:8080/manager
the URL of the server manager webapp
timeout : 180
timeout for HTTP request

CLI Examples:

salt '*' tomcat.sessions /jenkins
salt '*' tomcat.sessions /jenkins http://localhost:8080/manager
salt.modules.tomcat.signal(signal=None)

Signals catalina to start, stop, securestart, forcestop.

CLI Example:

salt '*' tomcat.signal start
salt.modules.tomcat.start(app, url='http://localhost:8080/manager', timeout=180)

Start the webapp

app
the webapp context path
url : http://localhost:8080/manager
the URL of the server manager webapp
timeout
timeout for HTTP request

CLI Examples:

salt '*' tomcat.start /jenkins
salt '*' tomcat.start /jenkins http://localhost:8080/manager
salt.modules.tomcat.status(url='http://localhost:8080/manager', timeout=180)

Used to test if the tomcat manager is up

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

CLI Examples:

salt '*' tomcat.status
salt '*' tomcat.status http://localhost:8080/manager
salt.modules.tomcat.status_webapp(app, url='http://localhost:8080/manager', timeout=180)

return the status of the webapp (stopped | running | missing)

app
the webapp context path
url : http://localhost:8080/manager
the URL of the server manager webapp
timeout : 180
timeout for HTTP request

CLI Examples:

salt '*' tomcat.status_webapp /jenkins
salt '*' tomcat.status_webapp /jenkins http://localhost:8080/manager
salt.modules.tomcat.stop(app, url='http://localhost:8080/manager', timeout=180)

Stop the webapp

app
the webapp context path
url : http://localhost:8080/manager
the URL of the server manager webapp
timeout : 180
timeout for HTTP request

CLI Examples:

salt '*' tomcat.stop /jenkins
salt '*' tomcat.stop /jenkins http://localhost:8080/manager
salt.modules.tomcat.undeploy(app, url='http://localhost:8080/manager', timeout=180)

Undeploy a webapp

app
the webapp context path
url : http://localhost:8080/manager
the URL of the server manager webapp
timeout : 180
timeout for HTTP request

CLI Examples:

salt '*' tomcat.undeploy /jenkins
salt '*' tomcat.undeploy /jenkins http://localhost:8080/manager
salt.modules.tomcat.version()

Return server version from catalina.sh version

CLI Example:

salt '*' tomcat.version