In fact, most of them refer to other people's blog to do, their own modifications prepared tomcat.tar.gz after the optimization of the reference http://vekergu.blog.51cto.com/9966832/ 1672931 optimize Apr mode on Tomcat use the root default directory file Tomcat.shserver.xml to create some directories and give permission/opt/src/logs start sh /opt/ea/ tomcat.shcat tomcat.sh#!/bin/bashjava_opts= "-xms2048m -xmx2048m -xmn384m" Java_Home=/usr/java/ jdktomcat_home=/opt/ea/tomcattomcat_user=tomcatchown $Tomcat _user: $Tomcat _user -r /opt/ea/ tomcatchown $Tomcat _user: $Tomcat _user -r /opt/src/logsjava_home= ' echo $Java _home ' CATALINA_ Home= ' echo $Tomcat _home ' catalina_base= ' echo $New _instance ' export java_home java_opts catalina_home catalina_basesu ' echo $Tomcat _user ' $CATALINA _home/bin/startup.sh client/etc/ Profile added export java_home=/usr/java/jdkexport jre_home=/usr/java/jdk/jreexportclasspath=.: $JAVA _home /lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/libexport path= $JAVA _home/bin: $PATHexport maven_home= /usr/java/apache-maven-3.3.1 start, MKDIR -P&N.Bsp;playbook The following is the playbook example structure, specific reference http://lansgg.blog.51cto.com/5675165/1749179 reference Ansible deployment Tomcat and include mechanism written in very detailed. ├── hosts├── roles│ └── http│ ├── default│ ├── files│ │ ├── apache-tomcat-8.0.33.tar.gz│ │ ├── jdk-8u65-linux-x64.tar.gz│ │ └── root│ │ └── test.html│ ├── handlers│ │ └── main.yml│ ├── meta│ │ └── test│ │ &nbSp; └── test.html│ ├── tasks│ │ ├── bak.yml│ │ └── main.yml│ ├── templates│ │ └── test.yml│ └── vars└── site.ymlcd /etc/anisble/playbookmkdir -pv roles/http/{tasks, Handlers,files,vars,templates,meta,default}touch site.ymlmkdir -p roles/http/files/roottouch roles/http/files/ROOT/test.htmlecho "XX" >>./roles/http/files/root/test.htmlmkdir -p /etc/ansible/playbook/roles/http/meta/testecho "XX" >/etc/ansible/playbook/roles/http/meta/test/ test.htmlvim roles/http/tasks/main.yml- name: copy jdk copy: src=/opt/src/ Jdk.tar.gz dest=/usr/java/- name: tar shell: chdir=/usr/java tar xvzf jdk.tar.gz- name: rm file: dest=/usr/java/jdk.tar.gz state=absent- name: copy Maven copy: src=/opt/src/mvn.tar.gz dest=/usr/java/- name: tar shell : chdir=/usr/java tar xvzf mvn.tar.gz- name: rm file: dest=/usr/ java/mvn.tar.gz state=absent- name: copy tomcat copy: src=/opt/src/ Tomcat.tar.gz dest=/opt/ea/- name: tar shell: chdir=/opt/ea tar xvzf tomcat.tar.gz- name: rm file: dest=/opt/ea/tomcat.tar.gz state=absent- name: copy apr copy: src=/opt/src/apr.tar.gz dest=/usr/local- name: tar shell: chdir=/usr/local tar xvzf apr.tar.gz - name: rm file:&nbSp;dest=/usr/local/apr.tar.gz state=absent- name: copy tomcat.sh copy: src =/opt/src/tomcat.sh dest=/opt/ea/tomcat.sh- name: add user action: user name=tomcat password=fajxjj/6hkxps update_password=always shell=/bin/bash home=/opt/ ea- name: modify file: path=/opt/ea/tomcat/ owner=tomcat group= tomcat mode=0755- name: First start tomcat shell: chdir=/opt/ea nohup sh tomcat.sh &- name: copy test copy: src=/etc/ansible/playbook/ roles/http/meta/test dest=/opt/ea/tomcat/webapps/ tags: - updateconf notify: - stop tomcat service - start tomcat servicevim roles/http/handlers/main.yml- name: stop tomcat service shell: "Ps -ef |grep /opt/ea/tomcat |grep -v grep |awk ' {print $2} ' | Xargs kill -9 "- name: start tomcat service shell: chdir=/opt/ea nohup sh tomcat.sh &vim site.yml- hosts: web remote_ user: root roles: - httpansible-playbook -i hosts SITE.YML error 1.server.xml to change 2.-dapphome=/opt/src/xx/db cat setenv.shjava_opts= "$JAVA _opts -dapphome =/opt/src/xx/db "3.start boot cannot start, because there is no environment variable, so can only use the script 4.var variable example reference Listen {{listen.0}}:{{listen.1}}listen: - "{{ansible_all_ipv4_addresses.0}}" - 8080host_fqdn: - "{{ Ansible_nodename}} "5. Test echo " ABCDEFG " >> roles/http/meta/test/test.htmlansible-playbook -i hosts site.yml --tags=updateconfhttp://ip:8080/test/test.html
This article is from the "people, to have their own ideas" blog, please be sure to keep this source http://szgb2014.blog.51cto.com/340201/1782082
Ansible Deployment Tomcat8