我们需要用到的文件jdk以及tomcat安装包
下载链接:https://pan.baidu.com/s/1sjG8Yl8k-SUbOv7KwKXZMA
提取码:t71z
vim /etc/ansible/hosts
---
- name: tomcat
hosts: weball
user: root
vars_files:
- /tmp/varsfile/tomcat_vars.yml
tasks:
- name: jdk
copy: src={{jdk_src_path}} dest={{jdk_dest_path}}
- name: rpm
shell: rpm -ivh {{jdk_src_path}}
- name: echo
shell: echo {{item}} >> /etc/profile
with_items:
- export JAVA_HOME=/usr/java/default
- export PATH=$PATH:$JAVA_HOME/bin
- export CLASSPATH=.
- name: source
shell: source /etc/profile
- name: copy
copy: src={{copy_src_path}} dest={{copy_dest_path}}
- name: tar
shell: tar -zxvf {{copy_src_path}} -C /tmp
- name: start
shell: nohup {{copy_name}}/bin/startup.sh &
jdk_src_path: /tmp/jdk-8u171-linux-x64.rpm
jdk_dest_path: /tmp/
copy_src_path: /tmp/apache-tomcat-8.5.78.tar.gz
copy_dest_path: /tmp/
copy_name: /tmp/apache-tomcat-8.5.78
[root@localhost tmp]# ansible-playbook --syntax-check tomcat.yml
ansible-playbook tomcat.yml
那么至此,ansible(playbook)部署tomcat就完成了,觉得有帮助点赞关注加收藏,谢谢小伙伴们的支持!!!