centos 7 使用Ansible 发布多个 tomcat 服务
2016-04-28 20:15
148 查看
本文的原文连接是: /article/7549505.html 未经博主允许不得转载。
博主地址是:http://blog.csdn.net/freewebsys
发现发布的脚步是可以共用的。使用参数规定区分tomcat服务。
tomcat-mobile
tomcat-web
tomcat-admin
假设分别在 3个服务器上面
192.168.100.101
192.168.100.102
192.168.100.103
tomcat 线上的目录是:
/data/tomcat-mobile
/data/tomcat-web
/data/tomcat-admin
配置/etc/ansible/hosts
在每一个类型的部署yml中定义。
然后创建 3 个yml
tomcat-mobile.yml
tomcat-web.yml:
tomcat-admin.yml:
博主地址是:http://blog.csdn.net/freewebsys
执行部署:
/usr/bin/ansible-playbook tomcat-mobile.yml。
ansible 使用include的解决了脚本的重复编写问题。
将变量设置,可以同时部署多个tomcat。并且根据hosts的分组配置。当tomcat-web部署多台之后,将ssh打通后配置即可。非常简单的就按组进行扩展部署了。
博主地址是:http://blog.csdn.net/freewebsys
1,使用ansible
上次使用 ansible 发布了一个tomcat。发现发布的脚步是可以共用的。使用参数规定区分tomcat服务。
2,比如发布两个tomcat
发布一个手机端,web的和admin的tomcat。tomcat-mobile
tomcat-web
tomcat-admin
假设分别在 3个服务器上面
192.168.100.101
192.168.100.102
192.168.100.103
tomcat 线上的目录是:
/data/tomcat-mobile
/data/tomcat-web
/data/tomcat-admin
配置/etc/ansible/hosts
[tomcat-mobile] tomcat-mobile-01 ansible_ssh_host=192.168.100.101 ansible_ssh_port=22 ansible_ssh_user=root [tomcat-web] tomcat-web-01 ansible_ssh_host=192.168.100.101 ansible_ssh_port=22 ansible_ssh_user=root [tomcat-admin] tomcat-admin-01 ansible_ssh_host=192.168.100.101 ansible_ssh_port=22 ansible_ssh_user=root
3,创建一个通用的tomcat.yml
tomcat部署模板。其中tomcat_root 和 war_file是变量。在每一个类型的部署yml中定义。
- name: stop tomcat. command: /bin/sh {{ tomcat_root }}/../../bin/catalina.sh stop -force ignore_errors: yes async: 10 - name: rm ROOT. file: state: absent dest: "{{ tomcat_root }}" - name: mkdir ROOT. file: state: directory dest: "{{ tomcat_root }}" - name: unzip war. unarchive: src: "{{ war_file }}" dest: "{{ tomcat_root }}" copy: yes - name: rm war. file: state: absent dest: "{{ war_file }}" - name: start tomcat. command: /bin/sh {{ tomcat_root }}/../../bin/catalina.sh start ignore_errors: yes async: 10
然后创建 3 个yml
tomcat-mobile.yml
--- - name: install tomcat-mobile hosts: tomcat-mobile sudo: False vars: war_file: /data/build/tomcat-mobile.war tomcat_root: /data/tomcat-mobile/webapps/ROOT tasks: - name: Include local facts tasks include: tomcat.yml
tomcat-web.yml:
--- - name: install tomcat-web hosts: tomcat-web sudo: False vars: war_file: /data/build/tomcat-web.war tomcat_root: /data/tomcat-web/webapps/ROOT tasks: - name: Include local facts tasks include: tomcat.yml
tomcat-admin.yml:
--- - name: install tomcat-admin hosts: tomcat-admin sudo: False vars: war_file: /data/build/tomcat-admin.war tomcat_root: /data/tomcat-admin/webapps/ROOT tasks: - name: Include local facts tasks include: tomcat.yml
4,总结
本文的原文连接是: /article/7549505.html 未经博主允许不得转载。博主地址是:http://blog.csdn.net/freewebsys
执行部署:
/usr/bin/ansible-playbook tomcat-mobile.yml。
ansible 使用include的解决了脚本的重复编写问题。
将变量设置,可以同时部署多个tomcat。并且根据hosts的分组配置。当tomcat-web部署多台之后,将ssh打通后配置即可。非常简单的就按组进行扩展部署了。
相关文章推荐
- 项目通过myeclipse 布署到Tomcat 后无JSP等文件
- tomcat 部署项目 there are no resources that can be add
- Ubuntu 配置 Tomcat
- Jenkins部署Web项目到远程tomcat
- 在Eclipse中调试Tomcat发布的工程
- tomcat部署web项目的3中方法
- Eclipse中web项目部署至Tomcat步骤
- eclipse如何正确部署tomcat7
- eclipse如何正确部署tomcat7
- JENKINS+MAVEN+GIT+TOMCAT自动构建部署记录
- 利用cors,实现js跨域访问Tomcat下资源
- tomcat添加输出日志到指定文件
- TOMCAT启动错误:严重: Error filterStart
- Linux下配置tomcat(jdk安装+tomcat安装+故障排除)
- tomcat安装并设置开机启动
- tomcat server.xml中文版
- Eclipse导入tomcat服务器
- Tomcat 内存溢出,堆栈配置各种调整
- 学习配置tomcat虚拟主机
- 下载tomcat安装版