第 5.5 章 Playbook基本使用-案例:自动部署Tomcat
Playbook基本使用-案例:自动部署Tomcat
示例如下:
vim tomcat.yml --- - hosts: web gather_facts: no vars: tomcat_version: 8.5.57 tomcat_install_dir: /usr/local tasks: - name: Install jdk1.8 yum: name=java-1.8.0-openjdk state=present - name: Download tomcat #根据实际情况调整Tomcat下载地址和版本:https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.70/bin/apache-tomcat-8.5.70.tar.gz get_url: url=https://soft.l-t.top/Tomcat%E5%92%8CJDK/Apache%20Tomcat%20{{ tomcat_version }}/apache-tomcat-{{ tomcat_version }}.tar.gz dest=/tmp - name: Unarchive tomcat-{{ tomcat_version }}.tar.gz unarchive: src: /tmp/apache-tomcat-{{ tomcat_version }}.tar.gz dest: "{{ tomcat_install_dir }}" copy: no - name: Start tomcat shell: cd {{ tomcat_install_dir }} && mv apache-tomcat-{{ tomcat_version }} tomcat8 && cd tomcat8/bin && nohup ./startup.sh &
文章目录
关闭