Ansible Role: deploy-tomcat
部署war包至tomcat容器
要求
- 此角色僅在RHEL及其衍生產(chǎn)品上運(yùn)行。
測試環(huán)境
ansible 2.3.0.0
os Centos 6.7 X64
python 2.6.6
角色變量
# 發(fā)布的代碼文件,包含絕對(duì)路徑,如:/tmp/test.war
deploy_file: ""
# tomcat服務(wù)的端口
deploy_port: "8080"
# tomcat服務(wù)用戶
deploy_service_user: "tomcat"
# tomcat服務(wù)的名稱
deploy_service_name: "tomcat{% if deploy_port != 8080 %}{{ deploy_port }}{% endif %}"
# 發(fā)布服務(wù)的家目錄
deploy_file_workpath: "/usr/local/{{ deploy_service_name }}/webapps/ROOT"
# 啟動(dòng)腳本
deploy_service_start_script: "/etc/init.d/{{ deploy_service_name }}"
# 臨時(shí)目錄
deploy_file_path: "/tmp/{{ deploy_service_name }}-ansible-snap"
# 上線代碼的存儲(chǔ)目錄
deploy_new_path: "{{ deploy_file_path }}/new"
# 當(dāng)前代碼(也就是上一版本的代碼)的存儲(chǔ)目錄
deploy_pre_path: "{{ deploy_file_path }}/pre"
# 歷史代碼存儲(chǔ)目錄
deploy_old_path: "{{ deploy_file_path }}/old"
# 是否回滾
deploy_rollback: false
# 驗(yàn)證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 }