Ansible Role: deploy-tomcat
部署war包至tomcat容器
要求
- 此角色僅在RHEL及其衍生產(chǎn)品上運行。
測試環(huán)境
ansible 2.3.0.0
os Centos 6.7 X64
python 2.6.6
角色變量
# 發(fā)布的代碼文件浙滤,包含絕對路徑掺涛,如:/tmp/test.war
deploy_file: ""
# tomcat服務的端口
deploy_port: "8080"
# tomcat服務用戶
deploy_service_user: "tomcat"
# tomcat服務的名稱
deploy_service_name: "tomcat{% if deploy_port != 8080 %}{{ deploy_port }}{% endif %}"
# 發(fā)布服務的家目錄
deploy_file_workpath: "/usr/local/{{ deploy_service_name }}/webapps/ROOT"
# 啟動腳本
deploy_service_start_script: "/etc/init.d/{{ deploy_service_name }}"
# 臨時目錄
deploy_file_path: "/tmp/{{ deploy_service_name }}-ansible-snap"
# 上線代碼的存儲目錄
deploy_new_path: "{{ deploy_file_path }}/new"
# 當前代碼(也就是上一版本的代碼)的存儲目錄
deploy_pre_path: "{{ deploy_file_path }}/pre"
# 歷史代碼存儲目錄
deploy_old_path: "{{ deploy_file_path }}/old"
# 是否回滾
deploy_rollback: false
# 驗證uri
deploy_verify_uri: ""
依賴
tomcat
github地址
https://github.com/kuailemy123/Ansible-roles/tree/master/deploy-tomcat
Example Playbook
# 發(fā)布代碼
- hosts: node1
roles:
- role: { role: deploy-tomcat, deploy_port: 8071, deploy_file:/root/tomcat_*_test.war }
# 回滾代碼
- hosts: node1
roles:
- role: { role: deploy-tomcat, deploy_rollback: true }