ansible-playbook 进行批量安装tomcat8

ansible-playbook 进行安装tomcat操作

说明:

get_url  中下载的内容直接到目的主机

安装的时候需要指定copy: no,说明需直接从目标主机进行安装包

 


[root@ansible-test ansible-yaml]# vim tomcat-install.yml
---
- hosts: web
vars:
tomcat_version: 8.5.38
tomcat_install_dir: /usr/local

tasks:

- name: install jdk1.8
yum: name=java-1.8.0-openjdk
state=present

- name: download tomcat
get_url: url=http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v{{tomcat_version}}/bin/apache-tomcat-{{tomcat_version}}.tar.gz dest=/usr/local/src

- name: unarchive tomcat-{{tomcat_version}}.tar.gz
unarchive:
src: /usr/local/src/apache-tomcat-{{tomcat_version}}.tar.gz
dest: "{{tomcat_install_dir}}"
copy: no
- name: star tomcat
shell: cd {{tomcat_install_dir}} &&
mv apache-tomcat-{{tomcat_version}} tomcat8 &&
cd tomcat8/bin && nohup ./startup.sh &


 

posted @ 2019-03-22 13:08  zhouyuqiang  阅读(803)  评论(0编辑  收藏  举报