1. roles/tomcat/tasks/main.yml
# 安装tomcat (web1 web2 web3)
yum -y install tomcat
# 修改配置文件使站点目录支持软连接
sed -i '/^<Context>/c<Context allowLinking="true">' /etc/tomcat/context.xml
# 启动服务并加入自启动
systemctl start tomcat
systemctl enable tomcat
- name: Install tomcat
yum:
name: tomcat
state: installed
- name: Modify tomcat configure on context.xml
replace
path: /etc/tomcat/context.xml
regexp: '/^<Context>'
replace: '/<Context allowLinking="true">'
notify: Restart tomcat
- name: Start tomcat
systemd:
name: tomcat
state: started
enabled: yes
2.roles/tomcat/tasks/main.yml
# 重启服务,使配置文件生效
systemctl restart tomcat
- name: Restart tomcat
systemd:
name: tomcat
state: restarted