首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用ansible下载和解压apache tomcat并重命名unzaip文件

如何使用ansible下载和解压apache tomcat并重命名unzaip文件
EN

Stack Overflow用户
提问于 2019-08-24 22:22:06
回答 1查看 203关注 0票数 1

我正在为tomcat设置一个新的设置。

我想下载和解压apache tomcat使用ansible到linux的几个节点,但事情是解压缩文件应该被看到或重命名为apache。什么是tomcat的版本并不重要?

代码语言:javascript
复制
- name: variable check
  hosts: all
  become: yes
  vars:
    tomcat_url: 'http://mirrors.estointernet.in/apache/tomcat/tomcat-8/v8.5.45/bin/apache-tomcat-8.5.45.tar.gz'
  tasks:
  - name:
    get_url:
      url: "{{tomcat_url}}"
      dest: /opt
EN

回答 1

Stack Overflow用户

发布于 2019-08-26 02:34:50

下面是完整的工作示例:

代码语言:javascript
复制
---
- hosts: all
  become: yes
  vars:
    tomcat_url: 'http://mirrors.estointernet.in/apache/tomcat/tomcat-8/v8.5.45/bin/apache-tomcat-8.5.45.tar.gz'

  tasks:
    - name: Download and Extract apache tomcat
      unarchive:
        src: "{{ tomcat_url }}"
        dest: "/opt/"
        remote_src: yes

    - name: Synchronize the "{{ tomcat_url.split('/')[-1].rstrip('.tar.gz') }}" directory to apache on one remote host
      synchronize:
        src: "/opt/{{ tomcat_url.split('/')[-1].rstrip('.tar.gz') }}"
        dest: "/opt/apache"
      delegate_to: "{{ inventory_hostname }}"

    - name: Remove the {{ tomcat_url.split('/')[-1].rstrip('.tar.gz') }} directory
      file:
        path: "/opt/{{ tomcat_url.split('/')[-1].rstrip('.tar.gz') }}"
        state: absent
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57638807

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档