日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網營銷解決方案
CentOS7使用Ansible發(fā)布多個Tomcat服務

1,使用ansible

2,比如發(fā)布兩個tomcat

發(fā)布一個手機端,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,創(chuàng)建一個通用的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

然后創(chuàng)建 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,總結

執(zhí)行部署:
/usr/bin/ansible-playbook tomcat-mobile.yml。
ansible 使用include的解決了腳本的重復編寫問題。
將變量設置,可以同時部署多個tomcat。并且根據hosts的分組配置。當tomcat-web部署多臺之后,將ssh打通后配置即可。非常簡單的就按組進行擴展部署了。


文章標題:CentOS7使用Ansible發(fā)布多個Tomcat服務
網站鏈接:http://www.5511xx.com/article/djdsedo.html