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.
Java bin path should be in default path
If ipv6 is enabled make sure you permit manager access to ipv6 interface "0:0:0:0:0:0:0:1"
If you are using tomcat.tar.gz it has to be installed or symlinked under
/opt
, preferably using name tomcat
"tomcat.signal start/stop" works but it does not use the startup scripts
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
More information about tomcat manager: http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html
if you use only this module for deployments you've might want to strict access to the manager only from localhost for more info: http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Configuring_Manager_Application_Access
Tested on:
Sun Microsystems Inc.
1.6.0_43-b01
amd64
Linux
2.6.32-358.el6.x86_64
Apache Tomcat/7.0.37
Deploy a WAR file
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
the context path to deploy
set True to deploy the webapp even one is deployed in the context
the URL of the server manager webapp
the environment for WAR file in used by salt.modules.cp.get_url function
timeout for HTTP request
use another location to temporarily copy to war file by default the system's temp directory is used
Specify the war version. If this argument is provided, it overrides the version encoded in the war file name, if one is present.
Examples:
salt '*' tomcat.deploy_war salt://salt-2015.8.6.war version=2015.08.r6
New in version 2015.8.6.
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
Extract the version from the war file name. There does not seem to be a standard for encoding the version into the war file name
Examples:
/path/salt-2015.8.6.war -> 2015.8.6
/path/V6R2013xD5.war -> None
Return all server information from catalina.sh version
CLI Example:
salt '*' tomcat.fullversion
Find memory leaks in tomcat
the URL of the server manager webapp
timeout for HTTP request
CLI Examples:
salt '*' tomcat.leaks
list all the deployed webapps
the URL of the server manager webapp
timeout for HTTP request
CLI Examples:
salt '*' tomcat.ls
salt '*' tomcat.ls http://localhost:8080/manager
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'
Reload the webapp
the webapp context path
the URL of the server manager webapp
timeout for HTTP request
CLI Examples:
salt '*' tomcat.reload /jenkins
salt '*' tomcat.reload /jenkins http://localhost:8080/manager
return details about the server
the URL of the server manager webapp
timeout for HTTP request
CLI Examples:
salt '*' tomcat.serverinfo
salt '*' tomcat.serverinfo http://localhost:8080/manager
return the status of the webapp sessions
the webapp context path
the URL of the server manager webapp
timeout for HTTP request
CLI Examples:
salt '*' tomcat.sessions /jenkins
salt '*' tomcat.sessions /jenkins http://localhost:8080/manager
Signals catalina to start, stop, securestart, forcestop.
CLI Example:
salt '*' tomcat.signal start
Start the webapp
the webapp context path
the URL of the server manager webapp
timeout for HTTP request
CLI Examples:
salt '*' tomcat.start /jenkins
salt '*' tomcat.start /jenkins http://localhost:8080/manager
Used to test if the tomcat manager is up
the URL of the server manager webapp
timeout for HTTP request
CLI Examples:
salt '*' tomcat.status
salt '*' tomcat.status http://localhost:8080/manager
return the status of the webapp (stopped | running | missing)
the webapp context path
the URL of the server manager webapp
timeout for HTTP request
CLI Examples:
salt '*' tomcat.status_webapp /jenkins
salt '*' tomcat.status_webapp /jenkins http://localhost:8080/manager
Stop the webapp
the webapp context path
the URL of the server manager webapp
timeout for HTTP request
CLI Examples:
salt '*' tomcat.stop /jenkins
salt '*' tomcat.stop /jenkins http://localhost:8080/manager
Undeploy a webapp
the webapp context path
the URL of the server manager webapp
timeout for HTTP request
CLI Examples:
salt '*' tomcat.undeploy /jenkins
salt '*' tomcat.undeploy /jenkins http://localhost:8080/manager
Return server version from catalina.sh version
CLI Example:
salt '*' tomcat.version