用于支持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.
configuration: |
|
---|
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>
注解
更多信息关于tomcat manager: http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html
如果你只是使用这个模块来部署,你可能想要限制一下manager的访问权限只能从localhost访问,更多信息: http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Configuring_Manager_Application_Access
测试:
Sun Microsystems Inc.
1.6.0_43-b01
amd64
Linux
2.6.32-358.el6.x86_64
Apache Tomcat/7.0.37
salt.modules.tomcat.
deploy_war
(war, context, force='no', url='http://localhost:8080/manager', saltenv='base', timeout=180, temp_war_location=None, version='')¶部署一个WAR文件
WAR文件的绝对路径(运行tomcat的账户应该可访问到)或者一个被salt.modules.cp.get_file功能支持的路径
部署的context路径
设置为True将webapp部署在context
服务器manager webapp的URL
WAR文件的环境变量被salt.modules.cp.get_url功能使用
HTTP请求超时时间
使用另外一个位置临时复制war包文件默认使用系统临时目录
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
2015.8.6 新版功能.
CLI范例:
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本地文件系统
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
()¶从catalina.sh version返回所有的服务器信息
CLI 范例:
salt '*' tomcat.fullversion
salt.modules.tomcat.
leaks
(url='http://localhost:8080/manager', timeout=180)¶在tomcat中找出内存泄漏
服务器manager webapp的URL
HTTP请求超时时间
CLI范例:
salt '*' tomcat.leaks
salt.modules.tomcat.
ls
(url='http://localhost:8080/manager', timeout=180)¶列出所有已部署的webapps
服务器manager webapp的URL
HTTP请求超时时间
CLI范例:
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范例:
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)¶重加载webapp
webapp的context路径
服务器manager webapp的URL
HTTP请求超时时间
CLI范例:
salt '*' tomcat.reload /jenkins
salt '*' tomcat.reload /jenkins http://localhost:8080/manager
salt.modules.tomcat.
serverinfo
(url='http://localhost:8080/manager', timeout=180)¶返回服务器的详细信息
服务器manager webapp的URL
HTTP请求超时时间
CLI范例:
salt '*' tomcat.serverinfo
salt '*' tomcat.serverinfo http://localhost:8080/manager
salt.modules.tomcat.
sessions
(app, url='http://localhost:8080/manager', timeout=180)¶返回webapp的sessions信息
webapp的context路径
服务器manager webapp的URL
HTTP请求超时时间
CLI范例:
salt '*' tomcat.sessions /jenkins
salt '*' tomcat.sessions /jenkins http://localhost:8080/manager
salt.modules.tomcat.
signal
(signal=None)¶给catalina发送start, stop, securestart, forcestop信号.
CLI 范例:
salt '*' tomcat.signal start
salt.modules.tomcat.
start
(app, url='http://localhost:8080/manager', timeout=180)¶启动webapp
webapp的context路径
服务器manager webapp的URL
HTTP请求超时时间
CLI范例:
salt '*' tomcat.start /jenkins
salt '*' tomcat.start /jenkins http://localhost:8080/manager
salt.modules.tomcat.
status
(url='http://localhost:8080/manager', timeout=180)¶如果tomcat manager开启时用来测试
服务器manager webapp的URL
HTTP请求超时时间
CLI范例:
salt '*' tomcat.status
salt '*' tomcat.status http://localhost:8080/manager
salt.modules.tomcat.
status_webapp
(app, url='http://localhost:8080/manager', timeout=180)¶返回webapp的状态(stopped | running | missing)
webapp的context路径
服务器manager webapp的URL
HTTP请求超时时间
CLI范例:
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)¶停止webapp
webapp的context路径
服务器manager webapp的URL
HTTP请求超时时间
CLI范例:
salt '*' tomcat.stop /jenkins
salt '*' tomcat.stop /jenkins http://localhost:8080/manager
salt.modules.tomcat.
undeploy
(app, url='http://localhost:8080/manager', timeout=180)¶取消部署webapp
webapp的context路径
服务器manager webapp的URL
HTTP请求超时时间
CLI范例:
salt '*' tomcat.undeploy /jenkins
salt '*' tomcat.undeploy /jenkins http://localhost:8080/manager
salt.modules.tomcat.
version
()¶从catalina.sh version返回服务器版本
CLI 范例:
salt '*' tomcat.version