站在巨人的肩膀上
Part.0 系统信息
系统版本: Centos 7
jdk版本: 1.6.0_20
tomcat版本: 7.0.78
Part.1 安装jdk脚本
---
- name: copy java bin
copy:
src: "jdk-6u20-linux-x64.bin"
dest: "/usr/local"
- name: chmod jdk bin
file:
path: /usr/local/jdk-6u20-linux-x64.bin
mode: 0777
- name: Run jdk bin to install java
shell: cd /usr/local && \
echo 'yes' | ./jdk-6u20-linux-x64.bin &>/dev/null
#添加jdk信息到环境变量
- name: add java PATH to profile
lineinfile:
dest: /etc/profile
state: present
line: "{{ item }}"
with_items:
- "export JAVA_HOME=/usr/local/jdk1.6.0_20"
- "export JRE_HOME=/usr/local/jdk1.6.0_20/jre"
- "export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH"
- "export PATH=$JAVA_HOME/bin:$PATH"
- name: delete jdk bin
file:
path: /usr/local/jdk-6u20-linux-x64.bin
state: absent
Part.2 tomcat 安装并启动
- include: java.yml
when: jdk_installed == false
- name: unarchive tomcat7 zip
unarchive:
src: "apache-tomcat-7.0.78.tar.gz"
dest: "/usr/local"
- name: rename tomcat
shell: cd /usr/local && \
mv apache-tomcat-7.0.78 tomcat7
- name: unarchive catalina.jar
unarchive:
src: /usr/local/tomcat7/lib/catalina.jar
dest: /usr/local/tomcat7/lib
copy: no
#修改版本号
- name: create ServerInfo.properties
template:
src: "ServerInfo.properties.j2"
dest: "/usr/local/tomcat7/lib/org/apache/catalina/util/ServerInfo.properties"
- name: add information back to jar
shell: cd /usr/local/tomcat7/lib && \
/usr/local/jdk1.6.0_20/bin/jar uvf catalina.jar org/apache/catalina/util/ServerInfo.properties
#修改内存
- name: create setenv sh file
template:
src: "setenv.sh.j2"
dest: "/usr/local/tomcat7/bin/setenv.sh"
- name: sh startup.sh
shell: chdir=/usr/local/tomcat7/bin nohup ./startup.sh start &
Part.3 tomcat脚本说明
tomcat安装脚本中,设计到内存的修改和版本号的修改,相关的修改方法参考。
[Centos7] 利用setenv进行tomcat 内存设置
[Centos7] Tomcat版本号修改